Mercurial > hg > octave-lojdl > gnulib-hg
changeset 7225:3307ae6ea2e5
* lib/fcntl_.h: New file.
* lib/chdir-safer.c (O_DIRECTORY, O_NOFOLLOW): Remove, now that we have
the fcntl module.
* lib/dirchownmod.c: Likewise.
* lib/fts.c: Likewise.
* m4/fcntl_h.m4: New file.
* modules/fcntl: New file.
* modules/chdir-safer (Depends-on): Add fcntl.
* modules/fts: Likewise.
* modules/mkdir-p: Likewise.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 28 Aug 2006 22:59:17 +0000 |
parents | c42a57e8d187 |
children | d5530bceacf7 |
files | ChangeLog lib/ChangeLog lib/chdir-safer.c lib/dirchownmod.c lib/fcntl_.h lib/fts.c m4/ChangeLog m4/fcntl_h.m4 modules/chdir-safer modules/fcntl modules/fts modules/mkdir-p |
diffstat | 12 files changed, 202 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 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.
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,5 +1,11 @@ 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
--- a/lib/chdir-safer.c +++ b/lib/chdir-safer.c @@ -32,14 +32,6 @@ #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
--- a/lib/dirchownmod.c +++ b/lib/dirchownmod.c @@ -33,13 +33,6 @@ #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
new file mode 100644 --- /dev/null +++ b/lib/fcntl_.h @@ -0,0 +1,100 @@ +/* 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
--- a/lib/fts.c +++ b/lib/fts.c @@ -115,10 +115,6 @@ # 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
--- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,7 @@ +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.
new file mode 100644 --- /dev/null +++ b/m4/fcntl_h.m4 @@ -0,0 +1,50 @@ +# 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]) +])
--- a/modules/chdir-safer +++ b/modules/chdir-safer @@ -7,6 +7,7 @@ m4/chdir-safer.m4 Depends-on: +fcntl same-inode stdbool
new file mode 100644 --- /dev/null +++ b/modules/fcntl @@ -0,0 +1,34 @@ +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