bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] chown.c fix imported from coreutils (file writeable, not re


From: Paul Eggert
Subject: [Bug-gnulib] chown.c fix imported from coreutils (file writeable, not readable)
Date: Mon, 09 Aug 2004 21:50:12 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

I installed this:

2004-08-09  Paul Eggert  <address@hidden>

        * lib/chown.c (rpl_chown): Work even if the file is writeable but not
        readable.  This could be improved further but it'd take some work.

Index: lib/chown.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/chown.c,v
retrieving revision 1.10
diff -p -u -r1.10 chown.c
--- lib/chown.c 7 Aug 2004 00:09:38 -0000       1.10
+++ lib/chown.c 10 Aug 2004 04:47:56 -0000
@@ -68,10 +68,11 @@ rpl_chown (const char *file, uid_t uid, 
     /* 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);
-    if (fd == -1)
+    if (fd < 0
+       && (fd = open (file, O_WRONLY | O_NONBLOCK | O_NOCTTY)) < 0)
       return -1;
     if (fchown (fd, uid, gid))
       {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]