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 /src | |
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 'src')
-rw-r--r-- | src/chgrp.c | 10 | ||||
-rw-r--r-- | src/chown-core.c | 3 | ||||
-rw-r--r-- | src/chown.c | 10 |
3 files changed, 6 insertions, 17 deletions
diff --git a/src/chgrp.c b/src/chgrp.c index 7e96b4c36..faf58d36b 100644 --- a/src/chgrp.c +++ b/src/chgrp.c @@ -260,20 +260,14 @@ main (int argc, char **argv) if (dereference == 1) error (EXIT_FAILURE, 0, _("-R --dereference requires either -H or -L")); - chopt.affect_symlink_referent = false; - } - else - { - if (dereference == 0) - error (EXIT_FAILURE, 0, _("-R -h requires -P")); - chopt.affect_symlink_referent = true; + dereference = 0; } } else { bit_flags = FTS_PHYSICAL; - chopt.affect_symlink_referent = (dereference != 0); } + chopt.affect_symlink_referent = (dereference != 0); if (argc - optind < (reference_file ? 1 : 2)) { diff --git a/src/chown-core.c b/src/chown-core.c index 606db39ea..b39061091 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -261,7 +261,8 @@ change_file_owner (FTS *fts, FTSENT *ent, { if (ROOT_DEV_INO_CHECK (chopt->root_dev_ino, ent->fts_statp)) { - /* This happens e.g., with "chown -R --preserve-root /". */ + /* This happens e.g., with "chown -R --preserve-root 0 /" + and with "chown -RH --preserve-root 0 symlink-to-root". */ ROOT_DEV_INO_WARN (file_full_name); /* Tell fts not to traverse into this hierarchy. */ fts_set (fts, ent, FTS_SKIP); diff --git a/src/chown.c b/src/chown.c index c2850ee13..63a32f5bf 100644 --- a/src/chown.c +++ b/src/chown.c @@ -273,20 +273,14 @@ main (int argc, char **argv) if (dereference == 1) error (EXIT_FAILURE, 0, _("-R --dereference requires either -H or -L")); - chopt.affect_symlink_referent = false; - } - else - { - if (dereference == 0) - error (EXIT_FAILURE, 0, _("-R -h requires -P")); - chopt.affect_symlink_referent = true; + dereference = 0; } } else { bit_flags = FTS_PHYSICAL; - chopt.affect_symlink_referent = (dereference != 0); } + chopt.affect_symlink_referent = (dereference != 0); if (argc - optind < (reference_file ? 1 : 2)) { |