From: Bruno Haible Date: Thu, 12 May 2011 00:03:07 +0000 (+0200) Subject: group-member: Declare function in . X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fae7fdcf95f035f5cd410d4a6da7aec5a3b225ee;p=pspp group-member: Declare function in . * lib/unistd.in.h (group_member): New declaration. * lib/group-member.h: Remove file. * lib/group-member.c: Include 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 . * modules/unistd (Makefile.am): Substitute GNULIB_GROUP_MEMBER, HAVE_GROUP_MEMBER. * NEWS: Mention the change. * lib/euidaccess.c: Don't include group-member.h. --- diff --git a/ChangeLog b/ChangeLog index cc8f985721..e8b8aa177c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2011-05-11 Bruno Haible + + group-member: Declare function in . + * lib/unistd.in.h (group_member): New declaration. + * lib/group-member.h: Remove file. + * lib/group-member.c: Include 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 . + * 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 group-member: Document module. diff --git a/NEWS b/NEWS index 8674ed8827..abe12386d5 100644 --- 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 . + 2011-05-02 exit The module is removed. It was deprecated on 2010-03-05. Use 'stdlib' directly instead. diff --git a/lib/euidaccess.c b/lib/euidaccess.c index 101f975d29..4178354742 100644 --- 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; diff --git a/lib/group-member.c b/lib/group-member.c index 6d1cd6665e..cc787d1405 100644 --- a/lib/group-member.c +++ b/lib/group-member.c @@ -18,15 +18,14 @@ #include -#include "group-member.h" +/* Specification. */ +#include #include #include #include #include -#include - #include "xalloc.h" struct group_info diff --git a/lib/group-member.h b/lib/group-member.h deleted file mode 100644 index cb89ee3cb2..0000000000 --- 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 . */ - -#ifndef GROUP_MEMBER_H_ -# define GROUP_MEMBER_H_ 1 - -# include - -int group_member (gid_t); - -#endif /* GROUP_MEMBER_H_ */ diff --git a/lib/unistd.in.h b/lib/unistd.in.h index d216e38515..55965333c4 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -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. diff --git a/m4/group-member.m4 b/m4/group-member.m4 index 5f7aa8a959..a415a32b02 100644 --- 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 @@ dnl Written by Jim Meyering AC_DEFUN([gl_FUNC_GROUP_MEMBER], [ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + dnl Persuade glibc 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. diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index eeb3360b05..fb6fe07726 100644 --- 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 @@ 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]) diff --git a/modules/group-member b/modules/group-member index 20075dd6d4..9da67f745e 100644 --- a/modules/group-member +++ b/modules/group-member @@ -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" + License: GPL diff --git a/modules/unistd b/modules/unistd index 0636a1bf1b..c9a9b76b78 100644 --- a/modules/unistd +++ b/modules/unistd @@ -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' \ diff --git a/tests/test-unistd-c++.cc b/tests/test-unistd-c++.cc index c63cf3defa..12e415b002 100644 --- a/tests/test-unistd-c++.cc +++ b/tests/test-unistd-c++.cc @@ -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