Oops, the second patch was slightly incomplete regarding modules/group-member. Here's it's once again, hopefully complete this time:
2011-05-08 Bruno Haible <br...@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. --- lib/unistd.in.h.orig Sun May 8 20:06:55 2011 +++ lib/unistd.in.h Sun May 8 19:56:55 2011 @@ -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. --- lib/group-member.h.orig Sun May 8 20:06:55 2011 +++ lib/group-member.h Sun May 8 19:57:11 2011 @@ -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_ */ --- lib/group-member.c.orig Sun May 8 20:06:55 2011 +++ lib/group-member.c Sun May 8 19:57:26 2011 @@ -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 --- tests/test-unistd-c++.cc.orig Sun May 8 20:24:51 2011 +++ tests/test-unistd-c++.cc Sun May 8 20:24:29 2011 @@ -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 --- m4/group-member.m4.orig Sun May 8 20:06:55 2011 +++ m4/group-member.m4 Sun May 8 19:59:59 2011 @@ -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. --- m4/unistd_h.m4.orig Sun May 8 20:06:55 2011 +++ m4/unistd_h.m4 Sun May 8 19:56:01 2011 @@ -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]) --- modules/group-member.orig Sun May 8 20:34:33 2011 +++ modules/group-member Sun May 8 20:31:44 2011 @@ -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 --- modules/unistd.orig Sun May 8 20:06:55 2011 +++ modules/unistd Sun May 8 19:56:42 2011 @@ -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' \ --- NEWS.orig Sun May 8 20:06:55 2011 +++ NEWS Sun May 8 19:51:14 2011 @@ -12,6 +12,9 @@ Date Modules Changes +2011-05-08 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. --- lib/euidaccess.c.orig Sun May 8 20:06:55 2011 +++ lib/euidaccess.c Sun May 8 20:06:41 2011 @@ -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; -- In memoriam Farrokhroo Parsa <http://en.wikipedia.org/wiki/Farrokhroo_Parsa>