Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: disabling dependence on dynamic NSS modules



If one has zsh statically-linked against GNU libc, one will
encounter troubles if /lib/libnss*.so are missing or have a
different ABI from the glibc zsh was compiled against.

Since these ABI changes are not uncommon, this is meant to
make a static zsh more robust.

Index: configure.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.ac,v
retrieving revision 1.48
diff -u -r1.48 configure.ac
--- configure.ac	8 Jan 2006 23:08:39 -0000	1.48
+++ configure.ac	19 Feb 2006 19:27:40 -0000
@@ -2099,6 +2099,23 @@
   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 ---------------
Index: Src/glob.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/glob.c,v
retrieving revision 1.49
diff -u -r1.49 glob.c
--- Src/glob.c	15 Dec 2005 10:38:56 -0000	1.49
+++ Src/glob.c	19 Feb 2006 19:27:42 -0000
@@ -1263,7 +1263,7 @@
 				 NULL, 0);
 			    data = 0;
 			} else {
-#ifdef HAVE_GETPWNAM
+#ifdef USE_GETPWNAM
 			    struct passwd *pw;
 			    sav = *tt;
 			    *tt = '\0';
@@ -1275,11 +1275,11 @@
 				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 @@
 				 NULL, 0);
 			    data = 0;
 			} else {
-#ifdef HAVE_GETGRNAM
+#ifdef USE_GETGRNAM
 			    struct group *gr;
 			    sav = *tt;
 			    *tt = '\0';
@@ -1315,11 +1315,11 @@
 				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
Index: Src/hashtable.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hashtable.c,v
retrieving revision 1.22
diff -u -r1.22 hashtable.c
--- Src/hashtable.c	15 Nov 2005 08:44:17 -0000	1.22
+++ Src/hashtable.c	19 Feb 2006 19:27:43 -0000
@@ -1340,7 +1340,7 @@
 	    }
 	}
 #else  /* no NIS or NIS_PLUS */
-#ifdef HAVE_GETPWENT
+#ifdef USE_GETPWENT
 	struct passwd *pw;
  
 	setpwent();
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.63
diff -u -r1.63 init.c
--- Src/init.c	7 Feb 2006 11:29:33 -0000	1.63
+++ Src/init.c	19 Feb 2006 19:27:44 -0000
@@ -628,7 +628,7 @@
 void
 setupvals(void)
 {
-#ifdef HAVE_GETPWUID
+#ifdef USE_GETPWUID
     struct passwd *pswd;
 #endif
     struct timezone dummy_tz;
@@ -796,14 +796,14 @@
     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("/");
Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.109
diff -u -r1.109 params.c
--- Src/params.c	7 Feb 2006 11:29:33 -0000	1.109
+++ Src/params.c	19 Feb 2006 19:27:46 -0000
@@ -3019,7 +3019,7 @@
     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)) {
Index: Src/system.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/system.h,v
retrieving revision 1.38
diff -u -r1.38 system.h
--- Src/system.h	8 Jan 2006 22:37:15 -0000	1.38
+++ Src/system.h	19 Feb 2006 19:27:46 -0000
@@ -710,3 +710,28 @@
 #    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
+
Index: Src/Modules/stat.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/stat.c,v
retrieving revision 1.11
diff -u -r1.11 stat.c
--- Src/Modules/stat.c	13 Jan 2006 09:15:59 -0000	1.11
+++ Src/Modules/stat.c	19 Feb 2006 19:27:46 -0000
@@ -166,13 +166,13 @@
 	    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++)



Messages sorted by: Reverse Date, Date, Thread, Author