diff options
author | Jim Meyering <jim@meyering.net> | 2006-12-14 15:41:05 +0100 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2006-12-14 15:41:50 +0100 |
commit | c3154b2947abbb8d03a412d5874fcceb1fc29393 (patch) | |
tree | 228cca8b905de2e2542887e211fec68bb2a298ba /tests | |
parent | 24852bf5b5e7fd954f2e4d1d08d58575453b48b0 (diff) | |
download | coreutils-c3154b2947abbb8d03a412d5874fcceb1fc29393.tar.xz |
chgrp, chown: Don't prohibit -RLh, aka -RL with --no-dereference.
* src/chgrp.c (main): Don't prohibit -RLh, aka -RL with --no-dereference.
* src/chown.c (main): Likewise.
* src/chown-core.c (change_file_owner): Add to a comment.
* tests/chown/preserve-root: Add tests.
* doc/coreutils.texi (Treating / specially): With --preserve-root,
chgrp and chown will not modify "/", even through a symlink.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/chown/preserve-root | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/chown/preserve-root b/tests/chown/preserve-root index 152f59c30..4f8fe4f7f 100755 --- a/tests/chown/preserve-root +++ b/tests/chown/preserve-root @@ -55,6 +55,18 @@ chgrp -R --preserve-root 0 / >> out 2>&1 && fail=1 # and then, only to make them readable by owner. chmod -R --preserve-root u+r / >> out 2>&1 && fail=1 +# With -RHh, --preserve-root should trigger nothing, +# since the symlink in question is not a command line argument. +# Contrary to the above commands, these two should succeed. +echo '==== test -RHh' >> out +chown -RHh --preserve-root `id -u` d >> out 2>&1 || fail=1 +chgrp -RHh --preserve-root `id -g` d >> out 2>&1 || fail=1 + +# These must fail. +echo '==== test -RLh' >> out +chown -RLh --preserve-root `id -u` d >> out 2>&1 && fail=1 +chgrp -RLh --preserve-root `id -g` d >> out 2>&1 && fail=1 + cat <<\EOF > exp || fail=1 chown: it is dangerous to operate recursively on `/' chown: use --no-preserve-root to override this failsafe @@ -62,6 +74,12 @@ chgrp: it is dangerous to operate recursively on `/' chgrp: use --no-preserve-root to override this failsafe chmod: it is dangerous to operate recursively on `/' chmod: use --no-preserve-root to override this failsafe +==== test -RHh +==== test -RLh +chown: it is dangerous to operate recursively on `d/slink-to-root' (same as `/') +chown: use --no-preserve-root to override this failsafe +chgrp: it is dangerous to operate recursively on `d/slink-to-root' (same as `/') +chgrp: use --no-preserve-root to override this failsafe EOF cmp out exp || fail=1 |