{"id":19831919,"url":"https://github.com/nixie-dev/fakedir","last_synced_at":"2025-05-01T16:32:39.957Z","repository":{"id":122968109,"uuid":"600858342","full_name":"nixie-dev/fakedir","owner":"nixie-dev","description":"Substitutes a directory elsewhere on macOS by replacing system calls","archived":false,"fork":false,"pushed_at":"2024-08-12T14:43:59.000Z","size":104,"stargazers_count":10,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-12T17:06:31.776Z","etag":null,"topics":["c","darwin","macos","namespaces","userns"],"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/nixie-dev.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}},"created_at":"2023-02-12T19:59:29.000Z","updated_at":"2024-08-12T14:44:03.000Z","dependencies_parsed_at":"2024-06-27T17:45:52.471Z","dependency_job_id":"ab00fbaa-73f2-4b00-93a9-60fd728a8ce3","html_url":"https://github.com/nixie-dev/fakedir","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nixie-dev%2Ffakedir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nixie-dev%2Ffakedir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nixie-dev%2Ffakedir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nixie-dev%2Ffakedir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nixie-dev","download_url":"https://codeload.github.com/nixie-dev/fakedir/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224267565,"owners_count":17283346,"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":["c","darwin","macos","namespaces","userns"],"created_at":"2024-11-12T11:35:42.006Z","updated_at":"2024-11-12T11:35:42.588Z","avatar_url":"https://github.com/nixie-dev.png","language":"C","readme":"# fakedir, because who needs namespaces anyway?\n\nFakedir is a simple library, meant to trick as many `libSystem` calls into believing a given directory exists in another place. To achieve that, we resolve symlinks and rewrite paths until the resulting system calls points towards the original directory. _(what do you mean, \"malware\"?)_\n\nThis project's intended purpose is for use within [nixie](https://github.com/nixie-dev/nixie), but it is generic enough for anyone to use.\n\n## How to use\n\nFakedir only supports macOS. If you're on Linux or any other sensible operating system, look into `bwrap` or `unshare` instead.\n\nFakedir also does not work for notarized binaries (macOS builtins or signed app bundles), unless System Integrity Protection is disabled (not recommended).\n\nIn order to start using fakedir, you need to inject the library, then tell it which directory it should fake and where.\n\n```sh\nDYLD_INSERT_LIBRARIES=/path/to/libfakedir.dylib FAKEDIR_PATTERN=/nix FAKEDIR_TARGET=$HOME/Library/nix ./myprogram\n```\n\nIn the above example, the directory at `~/Library/nix` is faked as root directory `/nix`.\n\n## Configuration\n\nAs you've seen above, the only way to configure fakedir is through environment variables.\n\n- `FAKEDIR_PATTERN` is the path that should be matched and replaced whenever accessed. **This parameter is mandatory and must be an absolute path.**\n- `FAKEDIR_TARGET` is the actual path that should be used whenever `FAKEDIR_PATTERN` is met. **This parameter is mandatory and must be an absolute path.**\n- `FAKEDIR_DEBUG` enables debug output to standard error. This variable's value is not taken into account, and debug output will be enabled as long as it is set. (i.e. `FAKEDIR_DEBUG=0` will still enable debug output).\n\n## Pitfalls\n\nAs mentioned above, fakedir does not work on executables under System Integrity Protection, since macOS prevents library injection for those.\n\nThe faked directory will not appear in its parent's directory listing, as we do not attempt to modify `readdir()`'s output.\n\nCyclic symbolic links are not detected and will result in a stack overflow, due to limitations with the in-library resolver.\n\nThe fakedir library itself may not be located in the fake directory.\n\nCalling fakedir's `execve()` may result in a very large `DYLD_INSERT_LIBRARIES` environment variable, as we currently cannot hook into `dyld`'s own understanding of the filesystem.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnixie-dev%2Ffakedir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnixie-dev%2Ffakedir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnixie-dev%2Ffakedir/lists"}