From a9151388528c84d7993a366ae03b57f5a413ca78 Mon Sep 17 00:00:00 2001 From: Clint Adams Date: Sun, 19 Feb 2006 19:36:31 +0000 Subject: 22284: add --disable-dynamic-nss configure switch to disable use of getpw*(), getgr*(), initgroups() functions. --- Src/Modules/stat.c | 4 ++-- Src/glob.c | 12 ++++++------ Src/hashtable.c | 2 +- Src/init.c | 6 +++--- Src/params.c | 2 +- Src/system.h | 25 +++++++++++++++++++++++++ 6 files changed, 38 insertions(+), 13 deletions(-) (limited to 'Src') 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 # 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 + -- cgit 1.4.1