fcntl-h: default O_SEARCH, O_EXEC back to O_RDONLY
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 8 Nov 2012 09:23:20 +0000 (01:23 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 8 Nov 2012 09:24:09 +0000 (01:24 -0800)
O_PATH doesn't work with Linux kernel 3.6.5, as fchmod (fd, ...)
fails with errno == EBADF when fd is opened with O_PATH.
Reported by Jim Meyering in
<http://lists.gnu.org/archive/html/bug-gnulib/2012-11/msg00026.html>.
* doc/posix-headers/fcntl.texi (fcntl.h): Document this.
* lib/fcntl.in.h (O_EXEC, O_SEARCH) [O_PATH]: Default back to O_RDONLY.

ChangeLog
doc/posix-headers/fcntl.texi
lib/fcntl.in.h

index bd05f3c..9817769 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-11-08  Paul Eggert  <eggert@cs.ucla.edu>
+
+       fcntl-h: default O_SEARCH, O_EXEC back to O_RDONLY
+       O_PATH doesn't work with Linux kernel 3.6.5, as fchmod (fd, ...)
+       fails with errno == EBADF when fd is opened with O_PATH.
+       Reported by Jim Meyering in
+       <http://lists.gnu.org/archive/html/bug-gnulib/2012-11/msg00026.html>.
+       * doc/posix-headers/fcntl.texi (fcntl.h): Document this.
+       * lib/fcntl.in.h (O_EXEC, O_SEARCH) [O_PATH]: Default back to O_RDONLY.
+
 2012-11-07  Paul Eggert  <eggert@cs.ucla.edu>
 
        test-utimens: speed up by taking shorter naps
index 4a75a54..7366513 100644 (file)
@@ -28,9 +28,10 @@ non-zero value; otherwise, the gnulib replacement is 0.
 
 @item
 @samp{O_EXEC} and @samp{O_SEARCH} are not defined on some platforms.
-On platforms such as GNU/Linux 2.6.39 and later that have @samp{O_PATH},
-Gnulib defines these macros to @samp{O_PATH}.
-On other platforms, it defines them to @samp{O_RDONLY}, which is typically 0.
+Gnulib defines these macros to @samp{O_RDONLY}, which is typically 0.
+The @samp{O_PATH} macro of GNU/Linux is not a suitable substitute, as
+fchmod fails with @samp{errno==EBADF} when invoked on a file
+descriptor that was opened with @samp{O_PATH}.
 
 @item
 @samp{O_ACCMODE} is not defined on some platforms:
index fb402ee..604c31b 100644 (file)
@@ -213,11 +213,7 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
 #endif
 
 #ifndef O_EXEC
-# ifdef O_PATH
-#  define O_EXEC O_PATH
-# else
-#  define O_EXEC O_RDONLY /* This is often close enough in older systems.  */
-# endif
+# define O_EXEC O_RDONLY /* This is often close enough in older systems.  */
 #endif
 
 #ifndef O_IGNORE_CTTY
@@ -274,11 +270,7 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
 #endif
 
 #ifndef O_SEARCH
-# ifdef O_PATH
-#  define O_SEARCH O_PATH
-# else
-#  define O_SEARCH O_RDONLY /* This is often close enough in older systems.  */
-# endif
+# define O_SEARCH O_RDONLY /* This is often close enough in older systems.  */
 #endif
 
 #ifndef O_SYNC