glibc declares get/set/endusershell() in <unistd.h>. Here is a proposed patch for gnulib to do the same.
2008-10-18 Bruno Haible <[EMAIL PROTECTED]> * 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 <unistd.h>. * modules/unistd (Makefile.am): Substitute GNULIB_GETUSERSHELL and HAVE_GETUSERSHELL. --- lib/unistd.in.h.orig 2008-10-19 00:44:09.000000000 +0200 +++ lib/unistd.in.h 2008-10-19 00:30:32.000000000 +0200 @@ -315,6 +315,36 @@ #endif +#if @GNULIB_GETUSERSHELL@ +# if [EMAIL PROTECTED]@ +/* 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 --- lib/getusershell.c.orig 2008-10-19 00:44:09.000000000 +0200 +++ lib/getusershell.c 2008-10-19 00:43:11.000000000 +0200 @@ -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 <config.h> +/* Specification. */ +#include <unistd.h> + #ifndef SHELLS_FILE # ifndef __DJGPP__ /* File containing a list of nonrestricted shells, one per line. */ --- m4/getusershell.m4.orig 2008-10-19 00:44:09.000000000 +0200 +++ m4/getusershell.m4 2008-10-19 00:42:40.000000000 +0200 @@ -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 <unistd.h> 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 ]) --- m4/unistd_h.m4.orig 2008-10-19 00:44:09.000000000 +0200 +++ m4/unistd_h.m4 2008-10-19 00:32:25.000000000 +0200 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 14 +# unistd_h.m4 serial 15 dnl Copyright (C) 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, @@ -43,6 +43,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]) @@ -55,6 +56,7 @@ HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) 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]) --- modules/getusershell.orig 2008-10-19 00:44:09.000000000 +0200 +++ modules/getusershell 2008-10-19 00:42:36.000000000 +0200 @@ -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: +<unistd.h> License: GPL --- modules/unistd.orig 2008-10-19 00:44:09.000000000 +0200 +++ modules/unistd 2008-10-19 00:31:28.000000000 +0200 @@ -35,6 +35,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' \ @@ -46,6 +47,7 @@ -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|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' \