Hi Damian, On Fri, Aug 15, 2003 at 06:43:14AM +1000, Damian Bickhoff wrote: > Hi. I grabbed the dpatch Guido posted and put that in glibc's > debian/patches, made it chmod +x, then edited the 0list file in that > dir. I'm not sure if that's the full procedure, but I made sure that > the patch was included in the build process through the build messages. > It compiled fine, I copied it to the affected machine, and it seems to > work. Basically the testing so far is this: Could you try the attached dpatch instead of the earlier one please? This one was posted to libc-alpha by Thorsten Kuckuck. I can also make a libc6 deb available to you if that is easier. Regards, -- Guido
#! /bin/sh -e # All lines beginning with `# DP:' are a description of the patch. # DP: Description: Fix getspnam # DP: Author: Thorsten Kuckuck # DP: Date: 2003-09-02 if [ $# -ne 2 ]; then echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" exit 1 fi case "$1" in -patch) patch -d "$2" -f --no-backup-if-mismatch -p0 < $0;; -unpatch) patch -d "$2" -f --no-backup-if-mismatch -R -p0 < $0;; *) echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" exit 1 esac exit 0 --- nis/nss_compat/compat-spwd.c +++ nis/nss_compat/compat-spwd.c 2003/09/01 15:14:14 @@ -435,7 +435,7 @@ copy_spwd_changes (result, &pwd, p, plen); give_spwd_free (&pwd); /* We found the entry. */ - return NSS_STATUS_RETURN; + return NSS_STATUS_SUCCESS; } static enum nss_status @@ -539,13 +539,16 @@ if (result->sp_namp[0] == '+' && result->sp_namp[1] != '\0' && result->sp_namp[1] != '@') { + size_t len = strlen (result->sp_namp); + char buf[len]; enum nss_status status; /* Store the User in the blacklist for the "+" at the end of /etc/passwd */ - blacklist_store_name (&result->sp_namp[1], ent); + memcpy (buf, &result->sp_namp[1], len); status = getspnam_plususer (&result->sp_namp[1], result, ent, buffer, buflen, errnop); + blacklist_store_name (buf, ent); if (status == NSS_STATUS_SUCCESS) /* We found the entry. */ break; @@ -653,6 +656,9 @@ return NSS_STATUS_TRYAGAIN; } + /* Terminate the line for any case. */ + buffer[buflen - 1] = '\0'; + /* Skip leading blanks. */ while (isspace (*p)) ++p; @@ -686,21 +692,8 @@ if (result->sp_namp[0] == '-' && result->sp_namp[1] == '@' && result->sp_namp[2] != '\0') { - /* XXX Do not use fixed length buffers. */ - char buf2[1024]; - char *user, *host, *domain; - struct __netgrent netgrdata; - - bzero (&netgrdata, sizeof (struct __netgrent)); - __internal_setnetgrent (&result->sp_namp[2], &netgrdata); - while (__internal_getnetgrent_r (&host, &user, &domain, &netgrdata, - buf2, sizeof (buf2), errnop)) - { - if (user != NULL && user[0] != '-') - if (strcmp (user, name) == 0) - return NSS_STATUS_NOTFOUND; - } - __internal_endnetgrent (&netgrdata); + if (innetgr (&result->sp_namp[2], NULL, name, NULL)) + return NSS_STATUS_NOTFOUND; continue; } @@ -708,25 +701,18 @@ if (result->sp_namp[0] == '+' && result->sp_namp[1] == '@' && result->sp_namp[2] != '\0') { - char *buf = strdupa (&result->sp_namp[2]); - int status; + enum nss_status status; - ent->netgroup = TRUE; - ent->first = TRUE; - copy_spwd_changes (&ent->pwd, result, NULL, 0); + if (innetgr (&result->sp_namp[2], NULL, name, NULL)) + { + status = getspnam_plususer (name, result, ent, buffer, + buflen, errnop); - do - { - status = getspent_next_nss_netgr (name, result, ent, buf, - buffer, buflen, errnop); - if (status == NSS_STATUS_RETURN) - continue; + if (status == NSS_STATUS_RETURN) + continue; - if (status == NSS_STATUS_SUCCESS - && strcmp (result->sp_namp, name) == 0) - return NSS_STATUS_SUCCESS; - } - while (status == NSS_STATUS_SUCCESS); + return status; + } continue; } @@ -767,10 +753,12 @@ status = getspnam_plususer (name, result, ent, buffer, buflen, errnop); - if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */ - return NSS_STATUS_NOTFOUND; - else - return status; + if (status == NSS_STATUS_SUCCESS) /* We found the entry. */ + break; + else if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */ + return NSS_STATUS_NOTFOUND; + else + return status; } } return NSS_STATUS_SUCCESS; @@ -796,10 +784,8 @@ result = internal_setspent (&ent, 0); - if (result != NSS_STATUS_SUCCESS) - return result; - - result = internal_getspnam_r (name, pwd, &ent, buffer, buflen, errnop); + if (result == NSS_STATUS_SUCCESS) + result = internal_getspnam_r (name, pwd, &ent, buffer, buflen, errnop); internal_endspent (&ent);
Attachment:
pgpk3JcU2A9A1.pgp
Description: PGP signature