summaryrefslogtreecommitdiff
path: root/src/chown-core.c
AgeCommit message (Collapse)Author
2006-10-20Enable an fts optimization (call lstat only for directories,Jim Meyering
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.
2006-10-13More chown/chgrp dereferencing-related fixes.Jim Meyering
* 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.
2006-10-13* src/chown-core.c (change_file_owner): Use fstatat, not stat,Jim Meyering
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.
2006-09-20Fix the 2006-09-18 bug differently.Jim Meyering
* 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.
2006-09-20* src/chmod.c: Revert last change. There is a better way.Jim Meyering
* src/chown-core.c: Likewise.
2006-09-18Fix bug where chmod, chown, and chgrp did not process operandsPaul Eggert
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.
2006-01-17Include "openat.h".Jim Meyering
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.
2006-01-03(RC_do_ordinary_chown): New enum value.Paul Eggert
(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.
2005-12-27(restricted_chown):Paul Eggert
Don't try O_WRONLY unless O_RDONLY failed wth EACCES.
2005-05-30(getgrnam, getgrgid) [!defined _POSIX_VERSION]:Paul Eggert
Remove decls.
2005-05-14Update FSF postal mail address.Jim Meyering
2005-05-14Update FSF postal mail address.Jim Meyering
2005-04-14Correct typo, fchmod -> fchown, in a comment.Jim Meyering
2005-04-10(chopt_free): Mark parameter as unused.Jim Meyering
2005-03-28(chopt_init): Use NULL, not `0'.Jim Meyering
2005-02-21(enum RCH_status): Remove trailing comma,Paul Eggert
as it's not valid in standard C89.
2004-12-11Avoid a race condition vulnerability in chown, when used withJim Meyering
--from=O:G and without the (-h) --no-dereference option. (restricted_chown): New function. (change_file_owner): Call it. Reported by Ulrich Drepper.
2004-09-22(chown_files): Declare as `extern'.Jim Meyering
2004-08-19(describe_change): Describe changes to -1:-1Paul Eggert
without using "to OWNERSHIP" phrase.
2004-07-28Include inttostr.h.Paul Eggert
(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.
2004-06-09(change_file_owner): Change names of parametersJim Meyering
old_uid and old_gid to required_uid and required_gid respectively.
2004-06-09Adjust chmod and chown to be similar if -c or -v are given. InJim Meyering
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.
2004-06-08(change_file_owner): Use ent->fts_statp only ifJim Meyering
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.
2004-05-17(chopt_init): Affect each symlink referent by default.Jim Meyering
2004-05-16chown --dereference did nothing when the owner/group of aJim Meyering
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.
2004-05-01When chown or chgrp is modifying the referent of a symlink,Jim Meyering
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.
2004-05-01(change_file_owner): Add a comment.Jim Meyering
2004-04-27(chopt_init, chopt_free, gid_to_name, uid_to_name, chown_files):Jim Meyering
Add `extern' keyword.
2004-03-27Don't include savedir.h -- no longer needed.Jim Meyering
2003-11-09Include "root-dev-ino.h".Jim Meyering
(chopt_init): Initialize new member. (change_file_owner): Support rm's new --preserve-root option.
2003-10-17(change_file_owner): Handle the cases inJim Meyering
which fts_info indicates an error with the given entry.
2003-10-17Include "xfts.h".Jim Meyering
(chown_files): Use xfts_open, rather than fts_open.
2003-10-17tweak commentJim Meyering
2003-10-15Rewrite to iterate through hierarchies using fts rather thanJim Meyering
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.
2003-10-05(change_file_owner): Remove set-but-not-used local.Jim Meyering
2003-07-12(change_file_owner): Do not restore any specialJim Meyering
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.
2003-07-10(change_file_owner): Don't leak file descriptors when dereferencing symlinks.Jim Meyering
2002-01-21Don't include "xalloc.h", as system.h already does that via sys2.h.Jim Meyering
2001-12-11(change_file_owner):Jim Meyering
Include the word `fail' in some diagnostics to make it clearer that they indicate a failure. s/getting attributes/failed to get attributes/
2001-08-31(change_dir_owner): Remove statp arg; no longer needed.Jim Meyering
2000-12-16(uint_to_string): New function.Jim Meyering
(uid_to_name): Use it. (gid_to_name): Use it. Rename locals, user/group, to uid/gid.
2000-12-15Declare lstat.Jim Meyering
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.
2000-12-10give a better diagnostic when only the group is being changedJim Meyering
2000-12-09(chopt_free): don't free anythingJim Meyering
2000-12-09Include <pwd.h>, <grp.h>, and "xalloc.h".Jim Meyering
[!_POSIX_VERSION]: Declare getgrnam and getgrgid. (gid_to_name): New function. (uid_to_name): Likewise. (chopt_free): Likewise.
2000-12-09*** empty log message ***Jim Meyering