2006-08-28 Paul Eggert <eggert@cs.ucla.edu>
+ * modules/fcntl: New file.
+ * modules/chdir-safer (Depends-on): Add fcntl.
+ * modules/fts: Likewise.
+ * modules/mkdir-p: Likewise.
+
* modules/stdint (Makefile.am): Do not substitute ABSOLUTE_INTTYPES_H.
This undoes the most recent change, since we're not addressing the
problem in a different way.
2006-08-28 Paul Eggert <eggert@cs.ucla.edu>
+ * fcntl_.h: New file.
+ * chdir-safer.c (O_DIRECTORY, O_NOFOLLOW): Remove, now that we have
+ the fcntl module.
+ * dirchownmod.c: Likewise.
+ * fts.c: Likewise.
+
* inttypes_.h [defined _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H]:
Include @ABSOLUTE_INTTYPES_H@ if available, but do nothing else.
* stdint_.h (_GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H): Define
#include <sys/stat.h>
#include "same-inode.h"
-#ifndef O_DIRECTORY
-# define O_DIRECTORY 0
-#endif
-
-#ifndef O_NOFOLLOW
-# define O_NOFOLLOW 0
-#endif
-
/* Like chdir, but fail if DIR is a symbolic link to a directory (or
similar funny business), or if DIR is not readable. This avoids a
minor race condition between when a directory is created or statted
#include "lchmod.h"
#include "stat-macros.h"
-#ifndef O_DIRECTORY
-# define O_DIRECTORY 0
-#endif
-#ifndef O_NOFOLLOW
-# define O_NOFOLLOW 0
-#endif
-
#ifndef HAVE_FCHMOD
# define HAVE_FCHMOD 0
# undef fchmod
--- /dev/null
+/* Like <fcntl.h>, but with non-working flags defined to 0.
+
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* written by Paul Eggert */
+
+#ifndef _GL_FCNTL_H
+#define _GL_FCNTL_H
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include @ABSOLUTE_FCNTL_H@
+
+#if !defined O_DIRECT && defined O_DIRECTIO
+/* Tru64 spells it `O_DIRECTIO'. */
+# define O_DIRECT O_DIRECTIO
+#endif
+
+#ifndef O_DIRECT
+# define O_DIRECT 0
+#endif
+
+#ifndef O_DIRECTORY
+# define O_DIRECTORY 0
+#endif
+
+#ifndef O_DSYNC
+# define O_DSYNC 0
+#endif
+
+#ifndef O_NDELAY
+# define O_NDELAY 0
+#endif
+
+#ifndef O_NOATIME
+# define O_NOATIME 0
+#endif
+
+#ifndef O_NONBLOCK
+# define O_NONBLOCK O_NDELAY
+#endif
+
+#ifndef O_NOCTTY
+# define O_NOCTTY 0
+#endif
+
+#ifdef O_NOFOLLOW_IS_INEFFECTIVE
+# undef O_NOFOLLOW
+#endif
+#ifndef O_NOFOLLOW
+# define O_NOFOLLOW 0
+#endif
+
+#ifndef O_NOLINKS
+# define O_NOLINKS 0
+#endif
+
+#ifndef O_RSYNC
+# define O_RSYNC 0
+#endif
+
+#ifndef O_SYNC
+# define O_SYNC 0
+#endif
+
+/* For systems that distinguish between text and binary I/O.
+ O_BINARY is usually declared in fcntl.h */
+#if !defined O_BINARY && defined _O_BINARY
+ /* For MSC-compatible compilers. */
+# define O_BINARY _O_BINARY
+# define O_TEXT _O_TEXT
+#endif
+
+#ifdef __BEOS__
+ /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */
+# undef O_BINARY
+# undef O_TEXT
+#endif
+
+#ifndef O_BINARY
+# define O_BINARY 0
+# define O_TEXT 0
+#endif
+
+#endif
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif
-#if !defined O_NOFOLLOW
-# define O_NOFOLLOW 0
-#endif
-
/* If this host provides the openat function, then we can avoid
attempting to open "." in some initialization code below. */
#ifdef HAVE_OPENAT
+2006-08-28 Paul Eggert <eggert@cs.ucla.edu>
+
+ * fcntl_h.m4: New file.
+
2006-08-28 Eric Blake <ebb9@byu.net>
* inttypes.m4 (gl_INTTYPES_H): Fix missing #endif.
--- /dev/null
+# Configure fcntl.h.
+dnl Copyright (C) 2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Written by Paul Eggert.
+
+AC_DEFUN([gl_FCNTL_H],
+[
+ AC_CACHE_CHECK([for working fcntl.h], gl_cv_header_working_fcntl_h,
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <sys/types.h>
+ #include <sys/stat.h>
+ #include <unistd.h>
+ #include <fcntl.h>
+ #ifndef O_NOFOLLOW
+ #define O_NOFOLLOW 0
+ #endif
+ static int const constants[] =
+ {
+ O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
+ O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
+ };
+ ]],
+ [[static char const sym[] = "conftest.sym";
+ if (O_NOFOLLOW)
+ {
+ if (symlink (".", sym) != 0)
+ return 1;
+ if (open (sym, O_RDONLY | O_NOFOLLOW) == 0)
+ return 1;
+ }
+ return !constants;]])],
+ [gl_cv_header_working_fcntl_h=yes],
+ [gl_cv_header_working_fcntl_h=no],
+ [gl_cv_header_working_fcntl_h=cross-compiling])])
+
+ if test $gl_cv_header_working_fcntl_h != yes; then
+ AC_DEFINE([O_NOFOLLOW_IS_INEFFECTIVE], 1,
+ [Define to 1 if O_NOFOLLOW is ineffective.])
+ fi
+
+ gl_ABSOLUTE_HEADER([fcntl.h])
+ ABSOLUTE_FCNTL_H=\"$gl_cv_absolute_fcntl_h\"
+ AC_SUBST([ABSOLUTE_FCNTL_H])
+ FCNTL_H='fcntl.h'
+ AC_SUBST([FCNTL_H])
+])
m4/chdir-safer.m4
Depends-on:
+fcntl
same-inode
stdbool
--- /dev/null
+Description:
+Like <fcntl.h>, but with non-working flags defined to 0.
+
+Files:
+lib/fcntl_.h
+m4/absolute-header.m4
+m4/fcntl_h.m4
+
+Depends-on:
+unistd
+
+configure.ac:
+gl_FCNTL_H
+
+Makefile.am:
+BUILT_SOURCES += $(FCNTL_H)
+EXTRA_DIST += fcntl_.h
+
+# We need the following in order to create <fcntl.h> when the system
+# doesn't have one that works with the given compiler.
+fcntl.h: fcntl_.h
+ sed -e 's|@''ABSOLUTE_FCNTL_H''@|$(ABSOLUTE_FCNTL_H)|g' \
+ < $(srcdir)/fcntl_.h > $@-t
+ mv $@-t $@
+MOSTLYCLEANFILES += fcntl.h fcntl.h-t
+
+Include:
+#include <fcntl.h>
+
+License:
+LGPL
+
+Maintainer:
+all
Depends-on:
cycle-check
dirfd
+fcntl
hash
lstat
openat
Depends-on:
error
+fcntl
gettext-h
lchmod
lchown