group-member: Declare function in <unistd.h>.
authorBruno Haible <bruno@clisp.org>
Thu, 12 May 2011 00:03:07 +0000 (02:03 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 12 May 2011 00:05:12 +0000 (02:05 +0200)
* 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.

ChangeLog
NEWS
lib/euidaccess.c
lib/group-member.c
lib/group-member.h [deleted file]
lib/unistd.in.h
m4/group-member.m4
m4/unistd_h.m4
modules/group-member
modules/unistd
tests/test-unistd-c++.cc

index cc8f985..e8b8aa1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
 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.
        * doc/glibc-functions/group_member.texi: Mention the 'group-member'
        module.
diff --git a/NEWS b/NEWS
index 8674ed8..abe1238 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,9 @@ User visible incompatible changes
 
 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.
 
index 101f975..4178354 100644 (file)
 # undef stat
 # define stat stat64
 
-#else
-
-# include "group-member.h"
-
 #endif
 
 /* Return 0 if the user has permission of type MODE on FILE;
index 6d1cd66..cc787d1 100644 (file)
 
 #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
diff --git a/lib/group-member.h b/lib/group-member.h
deleted file mode 100644 (file)
index cb89ee3..0000000
+++ /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_ */
index d216e38..5596533 100644 (file)
@@ -871,6 +871,22 @@ _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
 #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.
index 5f7aa8a..a415a32 100644 (file)
@@ -1,4 +1,4 @@
-# serial 12
+# serial 13
 
 # Copyright (C) 1999-2001, 2003-2007, 2009-2011 Free Software Foundation, Inc.
 
@@ -10,15 +10,20 @@ dnl Written by Jim Meyering
 
 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.
index eeb3360..fb6fe07 100644 (file)
@@ -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 @@ AC_DEFUN([gl_UNISTD_H],
     ]], [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 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   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 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   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])
index 20075dd..9da67f7 100644 (file)
@@ -2,23 +2,24 @@ Description:
 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
index 0636a1b..c9a9b76 100644 (file)
@@ -48,6 +48,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
              -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 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
              -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' \
index c63cf3d..12e415b 100644 (file)
@@ -112,6 +112,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::setusershell, void, (void));
 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