Add getusershell(), setusershell(), endusershell() declarations to <unistd.h>.
authorBruno Haible <bruno@clisp.org>
Sun, 19 Oct 2008 11:07:15 +0000 (13:07 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 19 Oct 2008 11:07:15 +0000 (13:07 +0200)
ChangeLog
lib/getusershell.c
lib/unistd.in.h
m4/getusershell.m4
m4/unistd_h.m4
modules/getusershell
modules/unistd

index 76667beaa64c63e891e1825dae96c16230ca9a3a..cf1f711b1dbd790daddff3b1f178d7579213b289 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2008-10-18  Bruno Haible  <bruno@clisp.org>
+
+       Add getusershell(), setusershell(), endusershell() declarations to
+       <unistd.h>.
+       * 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.
+
 2008-10-18  Bruno Haible  <bruno@clisp.org>
 
        Add a getloadavg() declaration to <stdlib.h>.
index fa1b1202dc9891fddfb32b2ab803bb5cbc81a771..bea62a07af3758173309f1c5037bbe6caee02ebd 100644 (file)
@@ -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. */
index a73a201ad175f091a0664effbadac5f66e3afe48..37009589667410078dc107e4e566aa141f35ef92 100644 (file)
@@ -353,6 +353,36 @@ extern int getpagesize (void);
 #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
index de602d337030e215a9ffda198577d4799ccf9dbb..17182dc96b07eabfa62de4fc525dee41522d67a8 100644 (file)
@@ -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
 ])
index b4a60559e697eacc415ba2fe2aaaab4cf171cda3..7a3798be9fb2a332dfeb3eedcd15ac596fb95bbe 100644 (file)
@@ -45,6 +45,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   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 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   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])
index 8b645061521a921f303e5d5e369dd8a066281256..9ae7dcae1ef0a5797ca91fd191cec0f96d167053 100644 (file)
@@ -6,15 +6,19 @@ lib/getusershell.c
 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
index 182219053ead740a45b69171d3c0164fcfecdb6b..2f1c0aab939ac34a91872272f636f491c1787f76 100644 (file)
@@ -37,6 +37,7 @@ unistd.h: unistd.in.h
              -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 @@ unistd.h: unistd.in.h
              -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' \