about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2006-02-19 19:36:31 +0000
committerClint Adams <clint@users.sourceforge.net>2006-02-19 19:36:31 +0000
commita9151388528c84d7993a366ae03b57f5a413ca78 (patch)
tree14e46a64fdf4d09ad98b431863d2442b3db60301
parent930c18ee44a562c915171fda9158dd613e7d97db (diff)
downloadzsh-a9151388528c84d7993a366ae03b57f5a413ca78.tar.gz
zsh-a9151388528c84d7993a366ae03b57f5a413ca78.tar.xz
zsh-a9151388528c84d7993a366ae03b57f5a413ca78.zip
22284: add --disable-dynamic-nss configure switch to disable use of getpw*(), getgr*(), initgroups() functions.
-rw-r--r--ChangeLog7
-rw-r--r--Src/Modules/stat.c4
-rw-r--r--Src/glob.c12
-rw-r--r--Src/hashtable.c2
-rw-r--r--Src/init.c6
-rw-r--r--Src/params.c2
-rw-r--r--Src/system.h25
-rw-r--r--configure.ac17
8 files changed, 62 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 237ea33d2..bf97827a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-02-19  Clint Adams  <clint@zsh.org>
+
+	* 22284: configure.ac, Src/glob.c, Src/hashtable.c, Src/init.c,
+	Src/params.c, Src/system.h, Src/Modules/stat.c: add
+	--disable-dynamic-nss configure switch to disable use of
+	getpw*(), getgr*(), initgroups() functions.
+
 2006-02-19  Wayne Davison  <wayned@users.sourceforge.net>
 
 	* unposted: Completion/Unix/Command/_rsync: added the missing
diff --git a/Src/Modules/stat.c b/Src/Modules/stat.c
index 0c56aea76..20a09e671 100644
--- a/Src/Modules/stat.c
+++ b/Src/Modules/stat.c
@@ -166,13 +166,13 @@ statgidprint(gid_t gid, char *outbuf, int flags)
 	    strcat(outbuf, " (");
     }
     if (flags & STF_STRING) {
-#ifdef HAVE_GETGRGID
+#ifdef USE_GETGRGID
 	struct group *gr;
 	gr = getgrgid(gid);
 	if (gr)
 	    strcat(outbuf, gr->gr_name);
 	else
-#endif /* !HAVE_GETGRGID */
+#endif /* !USE_GETGRGID */
 	{
 	    char *optr;
 	    for (optr = outbuf; *optr; optr++)
diff --git a/Src/glob.c b/Src/glob.c
index efdce9fb3..3c05605a5 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -1263,7 +1263,7 @@ zglob(LinkList list, LinkNode np, int nountok)
 				 NULL, 0);
 			    data = 0;
 			} else {
-#ifdef HAVE_GETPWNAM
+#ifdef USE_GETPWNAM
 			    struct passwd *pw;
 			    sav = *tt;
 			    *tt = '\0';
@@ -1275,11 +1275,11 @@ zglob(LinkList list, LinkNode np, int nountok)
 				data = 0;
 			    }
 			    *tt = sav;
-#else /* !HAVE_GETPWNAM */
+#else /* !USE_GETPWNAM */
 			    sav = *tt;
 			    zerr("unknown user", NULL, 0);
 			    data = 0;
-#endif /* !HAVE_GETPWNAM */
+#endif /* !USE_GETPWNAM */
 			    if (sav)
 				s = tt + 1;
 			    else
@@ -1303,7 +1303,7 @@ zglob(LinkList list, LinkNode np, int nountok)
 				 NULL, 0);
 			    data = 0;
 			} else {
-#ifdef HAVE_GETGRNAM
+#ifdef USE_GETGRNAM
 			    struct group *gr;
 			    sav = *tt;
 			    *tt = '\0';
@@ -1315,11 +1315,11 @@ zglob(LinkList list, LinkNode np, int nountok)
 				data = 0;
 			    }
 			    *tt = sav;
-#else /* !HAVE_GETGRNAM */
+#else /* !USE_GETGRNAM */
 			    sav = *tt;
 			    zerr("unknown group", NULL, 0);
 			    data = 0;
-#endif /* !HAVE_GETGRNAM */
+#endif /* !USE_GETGRNAM */
 			    if (sav)
 				s = tt + 1;
 			    else
diff --git a/Src/hashtable.c b/Src/hashtable.c
index 881b45bea..d24fb31cb 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -1340,7 +1340,7 @@ fillnameddirtable(UNUSED(HashTable ht))
 	    }
 	}
 #else  /* no NIS or NIS_PLUS */
-#ifdef HAVE_GETPWENT
+#ifdef USE_GETPWENT
 	struct passwd *pw;
  
 	setpwent();
diff --git a/Src/init.c b/Src/init.c
index ac04a90e2..2bb5e0dbd 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -628,7 +628,7 @@ init_term(void)
 void
 setupvals(void)
 {
-#ifdef HAVE_GETPWUID
+#ifdef USE_GETPWUID
     struct passwd *pswd;
 #endif
     struct timezone dummy_tz;
@@ -796,14 +796,14 @@ setupvals(void)
     cached_uid = getuid();
 
     /* Get password entry and set info for `USERNAME' */
-#ifdef HAVE_GETPWUID
+#ifdef USE_GETPWUID
     if ((pswd = getpwuid(cached_uid))) {
 	if (emulation == EMULATE_ZSH)
 	    home = metafy(pswd->pw_dir, -1, META_DUP);
 	cached_username = ztrdup(pswd->pw_name);
     }
     else
-#endif /* HAVE_GETPWUID */
+#endif /* USE_GETPWUID */
     {
 	if (emulation == EMULATE_ZSH)
 	    home = ztrdup("/");
diff --git a/Src/params.c b/Src/params.c
index a633fb579..efdb42aca 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3019,7 +3019,7 @@ usernamesetfn(UNUSED(Param pm), char *x)
     struct passwd *pswd;
 
     if (x && (pswd = getpwnam(x)) && (pswd->pw_uid != cached_uid)) {
-# ifdef HAVE_INITGROUPS
+# ifdef USE_INITGROUPS
 	initgroups(x, pswd->pw_gid);
 # endif
 	if(!setgid(pswd->pw_gid) && !setuid(pswd->pw_uid)) {
diff --git a/Src/system.h b/Src/system.h
index 33804e71a..377cd173e 100644
--- a/Src/system.h
+++ b/Src/system.h
@@ -710,3 +710,28 @@ extern short ospeed;
 #    include <iconv.h>
 #  endif
 #endif
+
+#if defined(HAVE_INITGROUPS) && !defined(DISABLE_DYNAMIC_NSS)
+# define USE_INITGROUPS
+#endif
+
+#if defined(HAVE_GETGRGID) && !defined(DISABLE_DYNAMIC_NSS)
+# define USE_GETGRGID
+#endif
+
+#if defined(HAVE_GETGRNAM) && !defined(DISABLE_DYNAMIC_NSS)
+# define USE_GETGRNAM
+#endif
+
+#if defined(HAVE_GETPWENT) && !defined(DISABLE_DYNAMIC_NSS)
+# define USE_GETPWENT
+#endif
+
+#if defined(HAVE_GETPWNAM) && !defined(DISABLE_DYNAMIC_NSS)
+# define USE_GETPWNAM
+#endif
+
+#if defined(HAVE_GETPWUID) && !defined(DISABLE_DYNAMIC_NSS)
+# define USE_GETPWUID
+#endif
+
diff --git a/configure.ac b/configure.ac
index 344e76f1a..be17361a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2099,6 +2099,23 @@ if test $zsh_cv_c_zle_unicode_support = yes; then
   AC_DEFINE(MULTIBYTE_SUPPORT)
 fi
 
+dnl
+dnl static user lookup
+dnl
+AC_ARG_ENABLE(dynamic-nss,
+	      AC_HELP_STRING([--disable-dynamic-nss], [do not call
+			      functions that will require dynamic NSS
+			      modules]),
+[zsh_cv_c_dynamic_nss=$enableval],
+[])
+
+AH_TEMPLATE([DISABLE_DYNAMIC_NSS],
+[Define to 1 if you want to avoid calling functions that will require
+ dynamic NSS modules.])
+if test $zsh_cv_c_dynamic_nss = no; then
+  AC_DEFINE(DISABLE_DYNAMIC_NSS)
+fi
+
 dnl ---------------
 dnl dynamic loading
 dnl ---------------