Mercurial > hg > octave-nkf > gnulib-hg
changeset 8982:04a20e8bea33
Revamp lchown so that it lives in unistd.h where it belongs.
* lib/lchown.h: Remove.
* lib/dirchownmod.c: Don't include lib/lchown.h.
* lib/fchownat.c: Likewise.
* lib/openat.c: Likewise.
* lib/lchown.c (REPLACE_CHOWN): Define to 0 if the system chown
does not follow symlinks.
(EOPNOTSUPP): Define if not defined.
* lib/unistd_.h (chown): Do not replace if REPLADE_CHOWN
is defined to 0.
(lchown): New decl.
* m4/lchown.m4 (gl_FUNC_LCHOWN): Require gl_UNISTD_H_DEFAULTS.
Do not check for lchown decl.
Set REPLACE_LCHOWN.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Set GNULIB_LCHOWN,
REPLACE_LCHOWN.
* modules/chown: Make it clear it follows symlinks.
* modules/lchown: Make it clear it doesn't follow symlinks.
(Files): Remove lib/lchown.h
(Depends-on): Add unistd.
(configure.ac): Add gl_UNISTD_MODULE_INDICATOR([lchown]).
(Include): Include <unistd.h>, not "lchown.h".
* modules/unistd (unistd.h): Substitude GNULIB_LCHOWN and
REPLACE_LCHOWN.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sat, 16 Jun 2007 06:10:44 +0000 |
parents | 085312d74529 |
children | 5c190f3b839a |
files | ChangeLog lib/dirchownmod.c lib/fchownat.c lib/lchown.c lib/lchown.h lib/openat.c lib/unistd_.h m4/lchown.m4 m4/unistd_h.m4 modules/chown modules/lchown modules/unistd |
diffstat | 12 files changed, 92 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2007-06-15 Paul Eggert <eggert@cs.ucla.edu> + + Revamp lchown so that it lives in unistd.h where it belongs. + * lib/lchown.h: Remove. + * lib/dirchownmod.c: Don't include lib/lchown.h. + * lib/fchownat.c: Likewise. + * lib/openat.c: Likewise. + * lib/lchown.c (REPLACE_CHOWN): Define to 0 if the system chown + does not follow symlinks. + (EOPNOTSUPP): Define if not defined. + * lib/unistd_.h (chown): Do not replace if REPLADE_CHOWN + is defined to 0. + (lchown): New decl. + * m4/lchown.m4 (gl_FUNC_LCHOWN): Require gl_UNISTD_H_DEFAULTS. + Do not check for lchown decl. + Set REPLACE_LCHOWN. + * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Set GNULIB_LCHOWN, + REPLACE_LCHOWN. + * modules/chown: Make it clear it follows symlinks. + * modules/lchown: Make it clear it doesn't follow symlinks. + (Files): Remove lib/lchown.h + (Depends-on): Add unistd. + (configure.ac): Add gl_UNISTD_MODULE_INDICATOR([lchown]). + (Include): Include <unistd.h>, not "lchown.h". + * modules/unistd (unistd.h): Substitude GNULIB_LCHOWN and + REPLACE_LCHOWN. + 2007-06-15 Jim Meyering <jim@meyering.net> Change license (GPL to LGPL) of fsusage and dependents.
--- a/lib/dirchownmod.c +++ b/lib/dirchownmod.c @@ -1,6 +1,6 @@ /* Change the ownership and mode bits of a directory. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2007 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 @@ -28,7 +28,6 @@ #include <unistd.h> #include "lchmod.h" -#include "lchown.h" #include "stat-macros.h" #ifndef HAVE_FCHMOD
--- a/lib/fchownat.c +++ b/lib/fchownat.c @@ -29,7 +29,6 @@ #include <unistd.h> #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ -#include "lchown.h" #include "save-cwd.h" #include "openat-priv.h"
--- a/lib/lchown.c +++ b/lib/lchown.c @@ -1,6 +1,6 @@ /* Provide a stub lchown function for systems that lack it. - Copyright (C) 1998, 1999, 2002, 2004, 2006 Free Software + Copyright (C) 1998, 1999, 2002, 2004, 2006, 2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -21,9 +21,25 @@ #include <config.h> -#include "lchown.h" +/* If the system chown does not follow symlinks, we don't want it + replaced by gnulib's chown, which does follow symlinks. */ +#if CHOWN_MODIFIES_SYMLINK +# define REPLACE_CHOWN 0 +#endif +#include <unistd.h> + +#include <errno.h> +#include <sys/stat.h> -#include <sys/stat.h> +/* Some systems don't have EOPNOTSUPP. */ +#ifndef EOPNOTSUPP +# ifdef ENOTSUP +# define EOPNOTSUPP ENOTSUP +# else +/* Some systems don't have ENOTSUP either. */ +# define EOPNOTSUPP EINVAL +# endif +#endif /* Work just like chown, except when FILE is a symbolic link. In that case, set errno to EOPNOTSUPP and return -1.
deleted file mode 100644 --- a/lib/lchown.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Declare a replacement for lchown on hosts that lack it. - - 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 Jim Meyering. */ - -#include <errno.h> -#include <sys/types.h> -#include <unistd.h> - -#if HAVE_DECL_LCHOWN -# if ! HAVE_LCHOWN -# undef lchown -# define lchown rpl_chown -# endif -#else -int lchown (char const *, uid_t, gid_t); -#endif - -/* Some systems don't have EOPNOTSUPP. */ -#ifndef EOPNOTSUPP -# ifdef ENOTSUP -# define EOPNOTSUPP ENOTSUP -# else -/* Some systems don't have ENOTSUP either. */ -# define EOPNOTSUPP EINVAL -# endif -#endif
--- a/lib/openat.c +++ b/lib/openat.c @@ -1,5 +1,5 @@ /* provide a replacement openat function - Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006, 2007 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 @@ -26,7 +26,6 @@ #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ #include "fcntl--.h" -#include "lchown.h" #include "lstat.h" #include "openat-priv.h" #include "save-cwd.h"
--- a/lib/unistd_.h +++ b/lib/unistd_.h @@ -49,13 +49,18 @@ #if @GNULIB_CHOWN@ # if @REPLACE_CHOWN@ +# ifndef REPLACE_CHOWN +# define REPLACE_CHOWN 1 +# endif +# if REPLACE_CHOWN /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE - to GID (if GID is not -1). + to GID (if GID is not -1). Follow symbolic links. Return 0 if successful, otherwise -1 and errno set. See the POSIX:2001 specification <http://www.opengroup.org/susv3xsh/chown.html>. */ -# define chown rpl_chown +# define chown rpl_chown extern int chown (const char *file, uid_t uid, gid_t gid); +# endif # endif #elif defined GNULIB_POSIXCHECK # undef chown @@ -179,6 +184,25 @@ #endif +#if @GNULIB_LCHOWN@ +# if @REPLACE_LCHOWN@ +/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE + to GID (if GID is not -1). Do not follow symbolic links. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2001 specification + <http://www.opengroup.org/susv3xsh/lchown.html>. */ +# define lchown rpl_lchown +extern int lchown (char const *file, uid_t owner, gid_t group); +# endif +#elif defined GNULIB_POSIXCHECK +# undef lchown +# define lchown(f,u,g) \ + (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \ + "systems - use gnulib module lchown for portability"), \ + lchown (f, u, g)) +#endif + + #if @GNULIB_LSEEK@ # if @REPLACE_LSEEK@ /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
--- a/m4/lchown.m4 +++ b/m4/lchown.m4 @@ -1,7 +1,8 @@ -#serial 11 +#serial 12 +# Determine whether we need the lchown wrapper. -dnl Copyright (C) 1998, 2001, 2003, 2004, 2005, 2006 Free Software -dnl Foundation, Inc. +dnl Copyright (C) 1998, 2001, 2003, 2004, 2005, 2006, 2007 Free +dnl Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,8 +13,10 @@ AC_DEFUN([gl_FUNC_LCHOWN], [ - AC_REQUIRE([AC_TYPE_UID_T]) + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_CHOWN]) - AC_CHECK_DECLS_ONCE([lchown]) AC_REPLACE_FUNCS(lchown) + if test $ac_cv_func_lchown = no; then + REPLACE_LCHOWN=1 + fi ])
--- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 7 +# unistd_h.m4 serial 8 dnl Copyright (C) 2006-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -39,6 +39,7 @@ GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE]) GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD]) GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R]) + GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN]) GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK]) GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP]) @@ -51,5 +52,6 @@ REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR]) REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) + REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) ])
--- a/modules/chown +++ b/modules/chown @@ -1,5 +1,5 @@ Description: -chown() function: change ownership of a file. +chown() function: change ownership of a file, following symlinks. Files: lib/chown.c
--- a/modules/lchown +++ b/modules/lchown @@ -1,22 +1,23 @@ Description: -lchown() function: change ownership of a file. +lchown() function: change ownership of a file, without following symlinks. Files: -lib/lchown.h lib/lchown.c m4/lchown.m4 Depends-on: chown sys_stat +unistd configure.ac: gl_FUNC_LCHOWN +gl_UNISTD_MODULE_INDICATOR([lchown]) Makefile.am: Include: -"lchown.h" +<unistd.h> License: GPL
--- a/modules/unistd +++ b/modules/unistd @@ -29,6 +29,7 @@ -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \ -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \ + -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \ @@ -40,6 +41,7 @@ -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ + -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ < $(srcdir)/unistd_.h; \ } > $@-t