diff options
author | Jim Meyering <jim@meyering.net> | 2004-05-01 14:33:41 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2004-05-01 14:33:41 +0000 |
commit | 83db4e147a59e082edfc4f8a511b6b1304a90821 (patch) | |
tree | 470f6cf374483d29e7fb9fb1db3509dda454b6e0 /src | |
parent | afef52af2f1a38b348a73a4914f236c82574ebbf (diff) | |
download | coreutils-83db4e147a59e082edfc4f8a511b6b1304a90821.tar.xz |
When chown or chgrp is modifying the referent of a symlink,
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/chown-core.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/chown-core.c b/src/chown-core.c index 821adfe76..82fb4de0f 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -224,22 +224,9 @@ change_file_owner (FTS *fts, FTSENT *ent, if (chopt->affect_symlink_referent) { /* Applying chown to a symlink and expecting it to affect - the referent is not portable. So instead, open the - file and use fchown on the resulting descriptor. */ - /* FIXME: but on some systems (e.g. Linux-2.1.81 and newer), - using chown is much better, since it *does* follow - symlinks, and the open/fchown approach fails when - the file is not readable. This looks like a fine case - for another chown wrapper. In any case, this code can - clobber errno, so fix it or remove it. - Related: with a proper autoconf test -- is this possible, - without root permissions or a guarantee of more than - one group? -- the lchown wrapper may just end up - calling chown on some systems. */ - int fd = open (file, O_RDONLY | O_NONBLOCK | O_NOCTTY); - fail = (fd == -1 ? 1 : fchown (fd, new_uid, new_gid)); - if (fd != -1) - close (fd); + the referent is not portable, but here we may be using a + wrapper that tries to correct for unconforming chown. */ + fail = chown (file, new_uid, new_gid); } else { |