Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ UNRELEASED

* The `chroot`(8) wrapper and `fakechroot`(1) command can work with POSIX
shell.
* The `fakechroot`(1) command now supports an environment variable called
`FAKECHROOT_NOEXPAND_SYMLINK_TARGET`, which disables path expansion on
the targets of symlink syscalls. This more closely resmebles traditional
`chroot` behavior, which treats the target of a symlink as an opaque
string rather than a path.

## Version 2.19

Expand Down
10 changes: 10 additions & 0 deletions man/fakechroot.pod
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ to make debootstrap(8) working correctly.
To prevent some looping, the command substitution is done only if
C<FAKECHROOT_CMD_ORIG> variable is not set currently.

=item B<FAKECHROOT_NOEXPAND_SYMLINK_TARGET>

Fakechroot defaults to expanding the target of a symlink so that any absolute
symlinks created inside a fakechroot session will continue to work outside of
it. If that behavior is undesirable, setting this environment variable will
cause the symlink and symlinkat syscalls to create symlinks with the raw target
paths requested by the invoker. Note that this does not affect the path of the
symlink being created in any way, which still gets expanded according to the
usual chroot rules.

=item B<LD_LIBRARY_PATH>, B<LD_PRELOAD>

Fakechroot is implemented by wrapping system calls. This is accomplished by
Expand Down
1 change: 1 addition & 0 deletions src/libfakechroot.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ char *preserve_env_list[] = {
"FAKECHROOT_ELFLOADER_OPT_ARGV0",
"FAKECHROOT_EXCLUDE_PATH",
"FAKECHROOT_LDLIBPATH",
"FAKECHROOT_NOEXPAND_SYMLINK_TARGET",
"FAKECHROOT_VERSION",
"FAKEROOTKEY",
"FAKED_MODE",
Expand Down
5 changes: 4 additions & 1 deletion src/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ wrapper(symlink, int, (const char * oldpath, const char * newpath))
{
char tmp[FAKECHROOT_PATH_MAX];
debug("symlink(\"%s\", \"%s\")", oldpath, newpath);
expand_chroot_rel_path(oldpath);
char *noexpand_symlink_target = getenv("FAKECHROOT_NOEXPAND_SYMLINK_TARGET");
if (!noexpand_symlink_target)
expand_chroot_rel_path(oldpath);

strcpy(tmp, oldpath);
oldpath = tmp;
expand_chroot_path(newpath);
Expand Down
5 changes: 4 additions & 1 deletion src/symlinkat.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ wrapper(symlinkat, int, (const char * oldpath, int newdirfd, const char * newpat
{
char tmp[FAKECHROOT_PATH_MAX];
debug("symlinkat(\"%s\", %d, \"%s\")", oldpath, newdirfd, newpath);
expand_chroot_rel_path(oldpath);
char *noexpand_symlink_target = getenv("FAKECHROOT_NOEXPAND_SYMLINK_TARGET");
if (!noexpand_symlink_target)
expand_chroot_rel_path(oldpath);

strcpy(tmp, oldpath);
oldpath = tmp;
expand_chroot_path_at(newdirfd, newpath);
Expand Down