# HG changeset patch # User Bruno Haible # Date 1224414435 -7200 # Node ID d162e4057aa8b74387b48b49f807bfe0c2db80be # Parent 5394a3a1039834b752b3456183e120f70e7759ba Add getusershell(), setusershell(), endusershell() declarations to . diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2008-10-18 Bruno Haible + + Add getusershell(), setusershell(), endusershell() declarations to + . + * lib/unistd.in.h (getusershell, setusershell, endusershell): New + declarations. + * lib/getusershell.c: Include unistd.h. + * m4/getusershell.m4 (gl_FUNC_GETUSERSHELL): Require + gl_UNISTD_H_DEFAULTS and AC_USE_SYSTEM_EXTENSIONS. Set + HAVE_GETUSERSHELL. + * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize GNULIB_GETUSERSHELL + and HAVE_GETUSERSHELL. + * modules/getusershell (Depends-on): Add unistd, extensions. + (configure.ac): Invoke gl_UNISTD_MODULE_INDICATOR. + (Include): Specify . + * modules/unistd (Makefile.am): Substitute GNULIB_GETUSERSHELL and + HAVE_GETUSERSHELL. + 2008-10-18 Bruno Haible Add a getloadavg() declaration to . diff --git a/lib/getusershell.c b/lib/getusershell.c --- a/lib/getusershell.c +++ b/lib/getusershell.c @@ -1,6 +1,6 @@ /* getusershell.c -- Return names of valid user shells. - Copyright (C) 1991, 1997, 2000, 2001, 2003, 2004, 2005, 2006 Free + Copyright (C) 1991, 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -20,6 +20,9 @@ #include +/* Specification. */ +#include + #ifndef SHELLS_FILE # ifndef __DJGPP__ /* File containing a list of nonrestricted shells, one per line. */ diff --git a/lib/unistd.in.h b/lib/unistd.in.h --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -353,6 +353,36 @@ #endif +#if @GNULIB_GETUSERSHELL@ +# if !@HAVE_GETUSERSHELL@ +/* Return the next valid login shell on the system, or NULL when the end of + the list has been reached. */ +extern char *getusershell (void); +/* Rewind to pointer that is advanced at each getusershell() call. */ +extern void setusershell (void); +/* Free the pointer that is advanced at each getusershell() call and + associated resources. */ +extern void endusershell (void); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getusershell +# define getusershell() \ + (GL_LINK_WARNING ("getusershell is unportable - " \ + "use gnulib module getusershell for portability"), \ + getusershell ()) +# undef setusershell +# define setusershell() \ + (GL_LINK_WARNING ("setusershell is unportable - " \ + "use gnulib module getusershell for portability"), \ + setusershell ()) +# undef endusershell +# define endusershell() \ + (GL_LINK_WARNING ("endusershell is unportable - " \ + "use gnulib module getusershell for portability"), \ + endusershell ()) +#endif + + #if @GNULIB_LCHOWN@ # if @REPLACE_LCHOWN@ /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE diff --git a/m4/getusershell.m4 b/m4/getusershell.m4 --- a/m4/getusershell.m4 +++ b/m4/getusershell.m4 @@ -1,10 +1,18 @@ -# getusershell.m4 serial 4 -dnl Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc. +# getusershell.m4 serial 5 +dnl Copyright (C) 2002, 2003, 2006, 2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_GETUSERSHELL], [ - AC_REPLACE_FUNCS(getusershell) + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + + dnl Persuade glibc to declare {get,set,end}usershell(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_REPLACE_FUNCS([getusershell]) + if test $ac_cv_func_getusershell = no; then + HAVE_GETUSERSHELL=0 + fi ]) diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -45,6 +45,7 @@ GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE]) GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R]) GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE]) + GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL]) GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN]) GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK]) GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) @@ -59,6 +60,7 @@ HAVE_GETDOMAINNAME=1; AC_SUBST([HAVE_GETDOMAINNAME]) HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE]) HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) + HAVE_GETUSERSHELL=1; AC_SUBST([HAVE_GETUSERSHELL]) HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON]) diff --git a/modules/getusershell b/modules/getusershell --- a/modules/getusershell +++ b/modules/getusershell @@ -6,15 +6,19 @@ m4/getusershell.m4 Depends-on: +unistd +extensions fopen-safer xalloc configure.ac: gl_FUNC_GETUSERSHELL +gl_UNISTD_MODULE_INDICATOR([getusershell]) Makefile.am: Include: + License: GPL diff --git a/modules/unistd b/modules/unistd --- a/modules/unistd +++ b/modules/unistd @@ -37,6 +37,7 @@ -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \ -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_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ @@ -50,6 +51,7 @@ -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \ -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ + -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \