From c3154b2947abbb8d03a412d5874fcceb1fc29393 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 14 Dec 2006 15:41:05 +0100 Subject: 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. --- tests/chown/preserve-root | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/chown') 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 -- cgit v1.2.3-70-g09d2