mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-09-27 22:40:20 +02:00
22284: add --disable-dynamic-nss configure switch to disable use of getpw*(), getgr*(), initgroups() functions.
This commit is contained in:
parent
930c18ee44
commit
a915138852
@ -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
|
||||
|
@ -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++)
|
||||
|
12
Src/glob.c
12
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
|
||||
|
@ -1340,7 +1340,7 @@ fillnameddirtable(UNUSED(HashTable ht))
|
||||
}
|
||||
}
|
||||
#else /* no NIS or NIS_PLUS */
|
||||
#ifdef HAVE_GETPWENT
|
||||
#ifdef USE_GETPWENT
|
||||
struct passwd *pw;
|
||||
|
||||
setpwent();
|
||||
|
@ -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("/");
|
||||
|
@ -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)) {
|
||||
|
25
Src/system.h
25
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
|
||||
|
||||
|
17
configure.ac
17
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 ---------------
|
||||
|
Loading…
Reference in New Issue
Block a user