changeset 14733:8d8a6d8151f4

group-member: Declare function in <unistd.h>. * lib/unistd.in.h (group_member): New declaration. * lib/group-member.h: Remove file. * lib/group-member.c: Include <unistd.h> instead of group-member.h. * tests/test-unistd-c++.cc: Check signature of group_member. * m4/group-member.m4 (gl_FUNC_GROUP_MEMBER): Require gl_UNISTD_H_DEFAULTS. Set HAVE_GROUP_MEMBER. * m4/unistd_h.m4 (gl_UNISTD_H): Check whether group_member is declared. (gl_UNISTD_H_DEFAULTS): Initialize GNULIB_GROUP_MEMBER, HAVE_GROUP_MEMBER. * modules/group-member (Files): Remove lib/group-member.h. (Depends-on): Add unistd. Specify conditions. (configure.ac): Invoke gl_UNISTD_MODULE_INDICATOR. (Include): Change to <unistd.h>. * modules/unistd (Makefile.am): Substitute GNULIB_GROUP_MEMBER, HAVE_GROUP_MEMBER. * NEWS: Mention the change. * lib/euidaccess.c: Don't include group-member.h.
author Bruno Haible <bruno@clisp.org>
date Thu, 12 May 2011 02:03:07 +0200
parents 50a39f529fed
children 0e1b87c3d416
files ChangeLog NEWS lib/euidaccess.c lib/group-member.c lib/group-member.h lib/unistd.in.h m4/group-member.m4 m4/unistd_h.m4 modules/group-member modules/unistd tests/test-unistd-c++.cc
diffstat 11 files changed, 66 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2011-05-11  Bruno Haible  <bruno@clisp.org>
+
+	group-member: Declare function in <unistd.h>.
+	* lib/unistd.in.h (group_member): New declaration.
+	* lib/group-member.h: Remove file.
+	* lib/group-member.c: Include <unistd.h> instead of group-member.h.
+	* tests/test-unistd-c++.cc: Check signature of group_member.
+	* m4/group-member.m4 (gl_FUNC_GROUP_MEMBER): Require
+	gl_UNISTD_H_DEFAULTS. Set HAVE_GROUP_MEMBER.
+	* m4/unistd_h.m4 (gl_UNISTD_H): Check whether group_member is declared.
+	(gl_UNISTD_H_DEFAULTS): Initialize GNULIB_GROUP_MEMBER,
+	HAVE_GROUP_MEMBER.
+	* modules/group-member (Files): Remove lib/group-member.h.
+	(Depends-on): Add unistd. Specify conditions.
+	(configure.ac): Invoke gl_UNISTD_MODULE_INDICATOR.
+	(Include): Change to <unistd.h>.
+	* modules/unistd (Makefile.am): Substitute GNULIB_GROUP_MEMBER,
+	HAVE_GROUP_MEMBER.
+	* NEWS: Mention the change.
+	* lib/euidaccess.c: Don't include group-member.h.
+
 2011-05-11  Bruno Haible  <bruno@clisp.org>
 
 	group-member: Document module.
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,9 @@
 
 Date        Modules         Changes
 
+2011-05-11  group-member    The include file is changed from "group-member.h"
+                            to <unistd.h>.
+
 2011-05-02  exit            The module is removed.  It was deprecated
                             on 2010-03-05.  Use 'stdlib' directly instead.
 
--- a/lib/euidaccess.c
+++ b/lib/euidaccess.c
@@ -63,10 +63,6 @@
 # undef stat
 # define stat stat64
 
-#else
-
-# include "group-member.h"
-
 #endif
 
 /* Return 0 if the user has permission of type MODE on FILE;
--- a/lib/group-member.c
+++ b/lib/group-member.c
@@ -18,15 +18,14 @@
 
 #include <config.h>
 
-#include "group-member.h"
+/* Specification.  */
+#include <unistd.h>
 
 #include <stdbool.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <stdlib.h>
 
-#include <unistd.h>
-
 #include "xalloc.h"
 
 struct group_info
deleted file mode 100644
--- a/lib/group-member.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Determine whether group id is in calling user's group list.
-
-   Copyright (C) 1994, 1997, 2003, 2009-2011 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef GROUP_MEMBER_H_
-# define GROUP_MEMBER_H_ 1
-
-# include <sys/types.h>
-
-int group_member (gid_t);
-
-#endif /* GROUP_MEMBER_H_ */
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -871,6 +871,22 @@
 #endif
 
 
+#if @GNULIB_GROUP_MEMBER@
+/* Determine whether group id is in calling user's group list.  */
+# if !@HAVE_GROUP_MEMBER@
+_GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
+# endif
+_GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
+_GL_CXXALIASWARN (group_member);
+#elif defined GNULIB_POSIXCHECK
+# undef group_member
+# if HAVE_RAW_DECL_GROUP_MEMBER
+_GL_WARN_ON_USE (group_member, "group_member is unportable - "
+                 "use gnulib module group-member for portability");
+# endif
+#endif
+
+
 #if @GNULIB_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.
--- a/m4/group-member.m4
+++ b/m4/group-member.m4
@@ -1,4 +1,4 @@
-# serial 12
+# serial 13
 
 # Copyright (C) 1999-2001, 2003-2007, 2009-2011 Free Software Foundation, Inc.
 
@@ -10,15 +10,20 @@
 
 AC_DEFUN([gl_FUNC_GROUP_MEMBER],
 [
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+
   dnl Persuade glibc <unistd.h> to declare group_member().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
   dnl Do this replacement check manually because I want the hyphen
   dnl (not the underscore) in the filename.
   AC_CHECK_FUNC([group_member], , [
+    HAVE_GROUP_MEMBER=0
+  ])
+  if test $HAVE_GROUP_MEMBER = 0; then
     AC_LIBOBJ([group-member])
     gl_PREREQ_GROUP_MEMBER
-  ])
+  fi
 ])
 
 # Prerequisites of lib/group-member.c.
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 55
+# unistd_h.m4 serial 56
 dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -36,8 +36,8 @@
     ]], [chown dup2 dup3 environ euidaccess faccessat fchdir fchownat
     fsync ftruncate getcwd getdomainname getdtablesize getgroups
     gethostname getlogin getlogin_r getpagesize getusershell setusershell
-    endusershell lchown link linkat lseek pipe pipe2 pread pwrite readlink
-    readlinkat rmdir sleep symlink symlinkat ttyname_r unlink unlinkat
+    endusershell group_member lchown link linkat lseek pipe pipe2 pread pwrite
+    readlink readlinkat rmdir sleep symlink symlinkat ttyname_r unlink unlinkat
     usleep])
 ])
 
@@ -72,6 +72,7 @@
   GNULIB_GETLOGIN_R=0;           AC_SUBST([GNULIB_GETLOGIN_R])
   GNULIB_GETPAGESIZE=0;          AC_SUBST([GNULIB_GETPAGESIZE])
   GNULIB_GETUSERSHELL=0;         AC_SUBST([GNULIB_GETUSERSHELL])
+  GNULIB_GROUP_MEMBER=0;         AC_SUBST([GNULIB_GROUP_MEMBER])
   GNULIB_LCHOWN=0;               AC_SUBST([GNULIB_LCHOWN])
   GNULIB_LINK=0;                 AC_SUBST([GNULIB_LINK])
   GNULIB_LINKAT=0;               AC_SUBST([GNULIB_LINKAT])
@@ -110,6 +111,7 @@
   HAVE_GETHOSTNAME=1;     AC_SUBST([HAVE_GETHOSTNAME])
   HAVE_GETLOGIN=1;        AC_SUBST([HAVE_GETLOGIN])
   HAVE_GETPAGESIZE=1;     AC_SUBST([HAVE_GETPAGESIZE])
+  HAVE_GROUP_MEMBER=1;    AC_SUBST([HAVE_GROUP_MEMBER])
   HAVE_LCHOWN=1;          AC_SUBST([HAVE_LCHOWN])
   HAVE_LINK=1;            AC_SUBST([HAVE_LINK])
   HAVE_LINKAT=1;          AC_SUBST([HAVE_LINKAT])
--- a/modules/group-member
+++ b/modules/group-member
@@ -2,23 +2,24 @@
 Determine whether the current process has the permissions of a given group ID.
 
 Files:
-lib/group-member.h
 lib/group-member.c
 m4/group-member.m4
 
 Depends-on:
+unistd
 extensions
-getgroups
-xalloc
-stdbool
+getgroups       [test $HAVE_GROUP_MEMBER = 0]
+xalloc          [test $HAVE_GROUP_MEMBER = 0]
+stdbool         [test $HAVE_GROUP_MEMBER = 0]
 
 configure.ac:
 gl_FUNC_GROUP_MEMBER
+gl_UNISTD_MODULE_INDICATOR([group-member])
 
 Makefile.am:
 
 Include:
-"group-member.h"
+<unistd.h>
 
 License:
 GPL
--- a/modules/unistd
+++ b/modules/unistd
@@ -48,6 +48,7 @@
 	      -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
 	      -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \
 	      -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \
+	      -e 's|@''GNULIB_GROUP_MEMBER''@|$(GNULIB_GROUP_MEMBER)|g' \
 	      -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \
 	      -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \
 	      -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \
@@ -86,6 +87,7 @@
 	      -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
 	      -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \
 	      -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
+	      -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \
 	      -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
 	      -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
 	      -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
--- a/tests/test-unistd-c++.cc
+++ b/tests/test-unistd-c++.cc
@@ -112,6 +112,10 @@
 SIGNATURE_CHECK (GNULIB_NAMESPACE::endusershell, void, (void));
 #endif
 
+#if GNULIB_TEST_GROUP_MEMBER
+SIGNATURE_CHECK (GNULIB_NAMESPACE::group_member, int, (gid_t));
+#endif
+
 #if GNULIB_TEST_LCHOWN
 SIGNATURE_CHECK (GNULIB_NAMESPACE::lchown, int, (char const *, uid_t, gid_t));
 #endif