projects
/
gnulib.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b584e96
)
(rpl_chown): Work even if the file is writeable but not readable.
author
Paul Eggert
<eggert@cs.ucla.edu>
Tue, 10 Aug 2004 04:49:04 +0000
(
04:49
+0000)
committer
Paul Eggert
<eggert@cs.ucla.edu>
Tue, 10 Aug 2004 04:49:04 +0000
(
04:49
+0000)
lib/chown.c
patch
|
blob
|
history
diff --git
a/lib/chown.c
b/lib/chown.c
index
d761c73
..
2b6b29d
100644
(file)
--- a/
lib/chown.c
+++ b/
lib/chown.c
@@
-68,10
+68,11
@@
rpl_chown (const char *file, uid_t uid, gid_t gid)
/* Handle the case in which the system-supplied chown function
does *not* follow symlinks. Instead, it changes permissions
on the symlink itself. To work around that, we open the
/* Handle the case in which the system-supplied chown function
does *not* follow symlinks. Instead, it changes permissions
on the symlink itself. To work around that, we open the
- file (but this can fail due to lack of read permission) and
+ file (but this can fail due to lack of read
or write
permission) and
use fchown on the resulting descriptor. */
int fd = open (file, O_RDONLY | O_NONBLOCK | O_NOCTTY);
use fchown on the resulting descriptor. */
int fd = open (file, O_RDONLY | O_NONBLOCK | O_NOCTTY);
- if (fd == -1)
+ if (fd < 0
+ && (fd = open (file, O_WRONLY | O_NONBLOCK | O_NOCTTY)) < 0)
return -1;
if (fchown (fd, uid, gid))
{
return -1;
if (fchown (fd, uid, gid))
{