zsh-workers
 help / color / mirror / code / Atom feed
From: Clint Adams <clint@zsh.org>
To: zsh-workers@sunsite.dk
Subject: PATCH: disabling dependence on dynamic NSS modules
Date: Sun, 19 Feb 2006 14:31:00 -0500	[thread overview]
Message-ID: <20060219193100.GA2725@scowler.net> (raw)

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++)


             reply	other threads:[~2006-02-19 19:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-19 19:31 Clint Adams [this message]
2006-02-20  4:27 ` Dan Nelson
2006-02-20  4:37   ` Clint Adams
2006-02-20  4:45   ` Andrey Borzenkov
2006-02-20  5:28     ` Dan Nelson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060219193100.GA2725@scowler.net \
    --to=clint@zsh.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).