* 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 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.
/* 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
#include <unistd.h>
#include "lchmod.h"
-#include "lchown.h"
#include "stat-macros.h"
#ifndef HAVE_FCHMOD
#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"
/* 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
#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>
+/* 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.
But if autoconf tests determined that chown modifies
+++ /dev/null
-/* 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
/* 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
#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"
#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
#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.
-#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,
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
])
-# 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,
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])
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])
])
Description:
-chown() function: change ownership of a file.
+chown() function: change ownership of a file, following symlinks.
Files:
lib/chown.c
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
-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' \
-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