Age | Commit message (Collapse) | Author |
|
* src/chown-core.c (FTSENT_IS_DIRECTORY): New macro.
(change_file_owner): Perform the ROOT_DEV_INO_CHECK only for a
directory. Non-directory entries lack fts_statp data when using
the FTS_NOSTAT option.
|
|
* 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.
|
|
* src/chmod.c (process_file): Do honor the --preserve-root option.
* src/chown-core.c (change_file_owner): Likewise, but here, also
handle the case in which a traversal would go "through" a symlink
to root. Reported by Matthew M. Boedicker
* tests/chown/preserve-root: Test for the above.
* tests/chown/Makefile.am (TESTS): Add preserve-root.
|
|
on some file system types) also with the --preserve-root option
of chown or chgrp.
* src/chown-core.c (change_file_owner): Compare fts_statp-based
dev/ino against root dev/ino only for directories.
(chown_files): Don't let the root_dev_ino setting influence whether
we use FTS_NOSTAT: fts always sets *fts_statp for a directory.
|
|
* src/chown-core.c (change_file_owner): Don't use fts_statp if
we're dereferencing symlinks.
Reverse conjuncts, so that we use dereference file_stats
(aka ent->fts_statp) only *after* we've confirmed that
chopt->affect_symlink_referent is true. Otherwise, we might
use ent->fts_statp uninitialized.
Don't turn on FTS_NOSTAT when dereferencing symlinks.
* tests/chown/deref: Update the expected diagnostic, now that
this test case (trying to use "chown --dereference ..." on a
dangling symlink) takes a different code path.
|
|
now that we're using fts_open with FTS_CWDFD.
* tests/chgrp/posix-H: Add --preserve-root to an invocation of
chgrp, to exercise the above fix.
|
|
* src/chmod.c: (process_file): Upon FTS_NS for a top-level file,
tell fts_read to stat the file again, in case it has become
accessible since the initial fts_open call.
* src/chown-core.c (change_file_owner): Likewise.
|
|
* src/chown-core.c: Likewise.
|
|
left-to-right in some cases.
* src/chmod.c (wd_errno): New var.
(chmod_file): New function, with most of the contents of the
old prcess_file function.
(process_files): Use it. This gives file names to fts one
at a time, so that they are processed left-to-right as POSIX
requires.
* src/chown-core.c (wd_errno, chown_files): Likewise.
(chown_file): New function.
* tests/install/basic-1: Redo test so as to not workaround
the chmod bug, thereby testing for it.
|
|
Don't include "lchown.h".
(restricted_chown): Accept a new parameter, CWD_FD, and use it in
calling openat, lchownat, chownat, rather than open, lchown, chown.
Update caller.
|
|
(restricted_chown): Return it, if the file cannot be accessed due
to EPERM, or if no uid or gid are required, or if the file is
neither a directory nor a regular file. Rewrite to avoid gotos.
(change_file_owner): Handle RC_do_ordinary_chown case.
Rewrite to avoid gotos.
|
|
Don't try O_WRONLY unless O_RDONLY failed wth EACCES.
|
|
Remove decls.
|
|
|
|
|
|
|
|
|
|
|
|
as it's not valid in standard C89.
|
|
--from=O:G and without the (-h) --no-dereference option.
(restricted_chown): New function.
(change_file_owner): Call it.
Reported by Ulrich Drepper.
|
|
|
|
without using "to OWNERSHIP" phrase.
|
|
(UINT_MAX_DECIMAL_DIGITS, uint_to_string): Remove.
(gid_to_name, uid_to_name): Use imaxtostr/umaxtostr
instead of uint_to_string).
(describe_change): Instead of an int flag, use a char *
auxiliary; this avoids the need for casts.
Assume free (NULL) works.
(change_file_owner): Return true/false, not 0/-1, since
we don't set errno. All callers changed.
Use bool when appropriate.
(chown_files): Likewise.
|
|
old_uid and old_gid to required_uid and required_gid respectively.
|
|
particular, a no-op chown is no longer reported as a change; this
reverts to previous behavior. Also, fix both commands so that -v
report failures even if the failure is not due to the chmod or
chown syscalls.
* src/chown-core.c (change_file_owner): Return -1 on error, not
1 sometimes and -1 on others. Our caller ORs together our results,
and (-1 | 1) == 0 on ones-complement hosts.
With -v report all errors verbosely, not just some.
Fix bug when chopt->root_dev_ino && !chopt->affect_symlink_referent:
file_stats wasn't set properly in that case.
|
|
needed. Chown a directory only after chowning its children; this
avoids problems if the new directory ownership doesn't permit
access to the children. Dereference symlinks before doing
ROOT_DEV_INO_CHECK, not after, so that we catch symlinks to /.
Do not optimize away the chown() system call when the file's owner
and group already have the desired value. POSIX does not permit
this optimization. Rely on chown and lchown to do the right
thing with symlinks and/or -1 arguments, now that we have wrappers
to do this. Use ENOTSUPP not ENOSYS, and ignore all ENOTSUPP
errors, not just command-line errors.
(chown_files): Pass FTS_STAT to xfts_open if we don't need file status.
|
|
|
|
symlink matched the desired owner/group. Reported by David Malone.
Also reported in 1999 as http://bugs.debian.org/39642.
(change_file_owner): When --dereference has
been specified, and when processing a symlink, stat it to get the
owner and group of the referent.
|
|
use the chown(2) function, if possible.
(change_file_owner): Don't hard-code the
open/fchown/close kludge here. Use `chown' instead.
The chown function works just fine on conforming systems.
Other systems now go through the new chown wrapper that
resorts to the old kludge.
|
|
|
|
Add `extern' keyword.
|
|
|
|
(chopt_init): Initialize new member.
(change_file_owner): Support rm's new --preserve-root option.
|
|
which fts_info indicates an error with the given entry.
|
|
(chown_files): Use xfts_open, rather than fts_open.
|
|
|
|
via explicit recursion.
Include "fts_.h"
(change_file_owner): Rewrite to use FTS* and FTSENT* and to operate
on a single file at a time.
(chown_files): New function.
|
|
|
|
permission bits (e.g., set-user-ID, set-group-ID) that are reset
by chown(2) on some systems. Suggestion and insistence :-) from
Michael Stone.
|
|
|
|
|
|
Include the word `fail' in some diagnostics to make it clearer
that they indicate a failure.
s/getting attributes/failed to get attributes/
|
|
|
|
(uid_to_name): Use it.
(gid_to_name): Use it.
Rename locals, user/group, to uid/gid.
|
|
Rename change_symlinks member to `dereference' and use the DEREF_*
enum values.
(describe_change): Merge the chgrp and chown switch statements.
Use xmalloc to form the `user:group' string.
(change_file_owner): Record (and later, use) is_symlink and is_directory
from the lstat stats, in order to control whether we operate on symlinks
and whether (with -R) we traverse symlinks to directories.
When dereferencing, use open/fchown (rather than chown) on symlinks.
|
|
|
|
|
|
[!_POSIX_VERSION]: Declare getgrnam and getgrgid.
(gid_to_name): New function.
(uid_to_name): Likewise.
(chopt_free): Likewise.
|
|
|