{"id":25871261,"url":"https://github.com/vadimkantorov/packfs","last_synced_at":"2025-07-01T04:05:15.059Z","repository":{"id":255684319,"uuid":"853394279","full_name":"vadimkantorov/packfs","owner":"vadimkantorov","description":"Demo of abusing libarchive to make LD_PRELOAD-based overrides of file-related functions","archived":false,"fork":false,"pushed_at":"2025-03-06T16:04:23.000Z","size":433,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-06T20:07:57.890Z","etag":null,"topics":["ld-preload","libarchive","virtual-file-system","zip"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vadimkantorov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-06T15:10:24.000Z","updated_at":"2025-03-06T16:04:26.000Z","dependencies_parsed_at":"2025-02-20T16:28:29.186Z","dependency_job_id":"a8d5ce8e-b71a-46c1-82a0-3bdc9a7b9848","html_url":"https://github.com/vadimkantorov/packfs","commit_stats":null,"previous_names":["vadimkantorov/libarchivepreload","vadimkantorov/packfs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vadimkantorov/packfs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimkantorov%2Fpackfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimkantorov%2Fpackfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimkantorov%2Fpackfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimkantorov%2Fpackfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vadimkantorov","download_url":"https://codeload.github.com/vadimkantorov/packfs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimkantorov%2Fpackfs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262893638,"owners_count":23380710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ld-preload","libarchive","virtual-file-system","zip"],"created_at":"2025-03-02T06:46:49.121Z","updated_at":"2025-07-01T04:05:15.023Z","avatar_url":"https://github.com/vadimkantorov.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# License\nMIT\n\n# libarchivepreload\nDemo of abusing https://github.com/libarchive/libarchive to make `LD_PRELOAD`-based overrides of file-related functions. The `LD_PRELOAD`-based approach is useful when one doesn't have FUSE kernel module installed or does not have root permissions do use https://github.com/google/fuse-archive/ and it's wasteful to decompress a given archive.\n\n**Limitations:** This demo does not optimize for iterative entry reads or iterative seeks, https://github.com/google/fuse-archive/ makes an attempt in that direction; also see https://github.com/libarchive/libarchive/issues/2306 for future support of fast seeks in ZIP / TAR / CPIO in libarchive\n\n\n```shell\ncc -shared -fPIC libarchivepreload.c -o libarchivepreload.so -ldl libarchive/.libs/libarchive.a zlib/libz.a xz/src/liblzma/.libs/liblzma.a -Ilibarchive -Ilibarchive/libarchive\n\nzip -r   libarchivepreload.zip    libarchivepreload.c .git\ntar -cJf libarchivepreload.tar.xz libarchivepreload.c .git\n\nLD_PRELOAD=$PWD/libarchivepreload.so /usr/bin/ls -lah libarchivepreload.zip/\nLD_PRELOAD=$PWD/libarchivepreload.so /usr/bin/ls -lah libarchivepreload.zip\nLD_PRELOAD=$PWD/libarchivepreload.so /usr/bin/ls -lah libarchivepreload.zip/libarchivepreload.c\nLD_PRELOAD=$PWD/libarchivepreload.so /usr/bin/cat libarchivepreload.zip/libarchivepreload.c\nLD_PRELOAD=$PWD/libarchivepreload.so /usr/bin/find libarchivepreload.zip\n          \nLD_PRELOAD=$PWD/libarchivepreload.so /usr/bin/ls -lah libarchivepreload.tar.xz/\nLD_PRELOAD=$PWD/libarchivepreload.so /usr/bin/ls -lah libarchivepreload.tar.xz\nLD_PRELOAD=$PWD/libarchivepreload.so /usr/bin/ls -lah libarchivepreload.tar.xz/libarchivepreload.c\nLD_PRELOAD=$PWD/libarchivepreload.so /usr/bin/cat libarchivepreload.tar.xz/libarchivepreload.c\nLD_PRELOAD=$PWD/libarchivepreload.so /usr/bin/find libarchivepreload.tar.xz\n```\n\n# Overridden libc / posix functions\n- [`open`](https://man7.org/linux/man-pages/man2/open.2.html)\n- [`openat`](https://man7.org/linux/man-pages/man2/openat.2.html)\n- [`close`](https://man7.org/linux/man-pages/man2/close.2.html)\n- [`read`](https://man7.org/linux/man-pages/man2/read.2.html)\n- [`access`](https://man7.org/linux/man-pages/man2/access.2.html)\n- [`lseek`](https://man7.org/linux/man-pages/man2/lseek.2.html)\n- [`stat`](https://man7.org/linux/man-pages/man2/stat.2.html)\n- [`fstat`](https://man7.org/linux/man-pages/man2/fstat.2.html)\n- [`fstatat`](https://man7.org/linux/man-pages/man2/fstatat.2.html)\n- [`statx`](https://man7.org/linux/man-pages/man2/statx.2.html)\n- [`fopen`](https://en.cppreference.com/w/c/io/fopen)\n- [`fclose`](https://en.cppreference.com/w/c/io/fclose)\n- [`fileno`](https://man7.org/linux/man-pages/man3/fileno.3.html)\n- [`fcntl`](https://man7.org/linux/man-pages/man2/fcntl.2.html) - only `F_DUPFD` and `F_DUPFD_CLOEXEC` is emulated\n- [`opendir`](https://man7.org/linux/man-pages/man3/opendir.3.html)\n- [`fdopendir`](https://man7.org/linux/man-pages/man3/fdopendir.3p.html)\n- [`readdir`](https://man7.org/linux/man-pages/man3/readdir.3.html)\n- [`closedir`](https://man7.org/linux/man-pages/man3/closedir.3.html)\n\n# References\n- https://mropert.github.io/2018/02/02/pic_pie_sanitizers/\n- https://github.com/google/fuse-archive/\n- https://gist.github.com/vadimkantorov/2a4e092889b7132acd3b7ddfc2f2f907\n- https://github.com/libarchive/libarchive/issues/2306\n- https://github.com/coreutils/coreutils/blob/master/src/ls.c\n- https://github.com/coreutils/coreutils/blob/master/src/cat.c\n- https://git.busybox.net/busybox/tree/coreutils/ls.c\n- https://git.busybox.net/busybox/tree/coreutils/cat.c\n- https://git.musl-libc.org/cgit/musl/tree/src/dirent/opendir.c\n- https://git.musl-libc.org/cgit/musl/tree/src/dirent/readdir.c\n\n- https://stackoverflow.com/questions/77100299/implementing-a-simple-version-of-readdir-with-system-call\n- https://stackoverflow.com/questions/74890409/what-happens-in-c-function-readdir-from-dirent-h\n- https://stackoverflow.com/questions/24103009/is-it-possible-to-implement-readdir-in-ubuntu-12-10-kernel-3-5\n- https://unix.stackexchange.com/questions/625899/correctly-implementing-seeking-in-fuse-readdir-operation\n- https://github.com/facebook/sapling/blob/5cc682e8ff24ef182be2dbe07e484396539e80f4/eden/fs/inodes/TreeInode.cpp#L1798-L1833\n- https://github.com/facebook/sapling/blob/main/eden/fs/docs/InodeLifetime.md\n- https://lwn.net/Articles/544520/\n- https://lwn.net/Articles/544298/\n- https://github.com/TheAssassin/AppImageLauncher/issues/361\n- https://github.com/sholtrop/ldpfuse/\n- https://github.com/google/fuse-archive/blob/main/src/main.cc\n- https://superuser.com/questions/1601311/fuse-fs-without-root-privileges-e-g-a-ld-preload-gateway-or-a-proot-plugin\n- https://theses.liacs.nl/pdf/2021-2022-HoltropS.pdf\n- https://github.com/fritzw/ld-preload-open\n- https://github.com/strace/strace/blob/8399328f628182cf236a1c39a074d601babdeaa4/src/fcntl.c#L102\n- https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/fcntl.c;h=7cd3a0f976d9f9c9fbb1b5cab5b57780a72cec58;hb=HEAD\n- https://savannah.gnu.org/bugs/?48169\n- https://github.com/coreutils/gnulib/blob/master/lib/fcntl.c\n- https://github.com/coreutils/gnulib/blob/master/lib/cloexec.c\n- https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/fcntl.c\n- https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/cloexec.c\n- https://man7.org/linux/man-pages/man2/fcntl.2.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvadimkantorov%2Fpackfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvadimkantorov%2Fpackfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvadimkantorov%2Fpackfs/lists"}