]> git.ipfire.org Git - thirdparty/coreutils.git/commit
chroot: don't chdir() if not changing root
authorPádraig Brady <P@draigBrady.com>
Tue, 13 May 2014 14:56:34 +0000 (15:56 +0100)
committerPádraig Brady <P@draigBrady.com>
Fri, 16 May 2014 21:01:31 +0000 (22:01 +0100)
commit99960eeab9bf7fb479ab9f5342fc12a1fae629e6
tree451f8fc6ba8c3ce9214d14eb24bd848c86b15597
parentffd1a1d8dee921e20db515e7d4b3c3e47006c8b4
chroot: don't chdir() if not changing root

This allows chroot to be used as a light weight tool
to change user identification for a command,
while not changing the current working directory.
It also makes `chroot / true` consistently succeed on
all platforms for non root users.

* src/chroot.c (main): If the same root is specified. i.e. '/'
then don't change the current working directory, and avoid the
overhead of the other redundant calls.
* tests/misc/chroot-fail.sh: Remove failure guard previously
needed on some systems.  Also add an explicit case to ensure
we don't change directory.
* NEWS: Mention the change in behavior.
NEWS
src/chroot.c
tests/misc/chroot-fail.sh