mirror of
https://github.com/coreutils/coreutils.git
synced 2024-11-27 03:44:26 +08:00
07a69fc3ba
There have been various requests to add -h to avoid following symlinks for security reasons. This wasn't provided previously as chmod(1) already ignored symlinks unless specified on the command line. Note chmod defaults to -H mode rather than the chown default of -P, as usually chown can work directly on symlinks and so defaults to not traversing those specified on the command line. Note FreeBSD chmod does default to -P mode, but we retain the -H mode default also for compatibility with existing chmod behavior. Adding -HLP will allow chmod to disable traversing CLI symlinks to dirs. Adding -h will allow to disable following CLI symlinks to files/dirs, also operating on all symlinks on systems that support that. Adding --dereference will be significant with -H (the default). I.e. symlinks to dirs not recursed, but symlinks are dereferenced. Adding these options will also be consistent with chown(1), chgrp(1), and chmod(1) on other systems. Note since chmod(1) currently ignores symlinks by default, and -h is primarily a mechanism to avoid following symlinks, rather than for operating on the symlink itself, we make -h try to chmod a symlink, but ignore ENOTSUP. In that way we're consistent with chown(1) where it also ignores ENOTSUP for symlinks, and we don't fail when trying to be extra secure with command line params. * doc/coreutils.texi (chmod invocation): Reference the -H,-L,-P descriptions, and adjust the corresponding macros to say the default is -H or -P as appropriate. Add --dereference and -h,--no-dereference descriptions. * man/chmod.x: Adjust discussion of symlink handling. * src/chmod.c (main): Accept new options and set fts flags appropriately. (process_file): Process / dereference symlinks as necessary. * src/system.h (emit_symlink_recurse_options): A new function refactored from chown.c and chmod.c usage(). * tests/chmod/symlinks.sh: New test for the new options. * tests/local.mk: Reference the new test. * NEWS: Mention the new feature. |
||
---|---|---|
.. | ||
.gitignore | ||
coreutils.texi | ||
fdl.texi | ||
local.mk | ||
perm.texi | ||
sort-version.texi |