diff options
author | Pádraig Brady <P@draigBrady.com> | 2014-05-18 17:20:06 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2014-05-21 11:18:27 +0100 |
commit | 0c4729516baa2fbefb0af66c38f434b1f7519078 (patch) | |
tree | 53401704e3202224cac326298cff134180d65f1e /tests/misc/chroot-fail.sh | |
parent | aa1a72706bb9581fc08c63efc3bc03b908407124 (diff) | |
download | coreutils-0c4729516baa2fbefb0af66c38f434b1f7519078.tar.xz |
chroot: make changing root check more robust
* src/chroot.c (is_root): A new helper function to
determine if the passed argument is the root directory
based on inode comparison.
(main): Use the new helper rather than comparing strings.
* tests/misc/chroot-fail.sh: Add cases for alternative root paths.
Diffstat (limited to 'tests/misc/chroot-fail.sh')
-rwxr-xr-x | tests/misc/chroot-fail.sh | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/misc/chroot-fail.sh b/tests/misc/chroot-fail.sh index 56be8e231..b171ec40c 100755 --- a/tests/misc/chroot-fail.sh +++ b/tests/misc/chroot-fail.sh @@ -39,7 +39,9 @@ test $? = 127 || fail=1 # Ensure we don't chdir("/") when not changing root # to allow only changing user ids for a command. -curdir=$(chroot / env pwd) || fail=1 -test "$curdir" = '/' && fail=1 +for dir in '/' '/.' '/../'; do + curdir=$(chroot "$dir" env pwd) || fail=1 + test "$curdir" = '/' && fail=1 +done Exit $fail |