From b6099fb5b289b63204333465cfd704f45a824033 Mon Sep 17 00:00:00 2001 From: Stan Shebs Date: Thu, 3 Nov 2016 16:31:52 -0700 Subject: Handle a not-found case in borg passwd lookup --- README.google | 4 ++++ nss/nss_borg/borg-pwd.c | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.google b/README.google index 2b24beb..7b548cd 100644 --- a/README.google +++ b/README.google @@ -611,3 +611,7 @@ posix/tst-getaddrinfo6.c elf/elf.h For b/31273149, revert the value of DT_PPC64_NUM from 4 to 3. (stanshebs, google-local) + +nss/nss_borg/borg-pwd.c + Add /etc/passwd.borg.base as fallback passwd file. (b/30413914, b/32608777) + (mrothwell/stanshebs, google-local) diff --git a/nss/nss_borg/borg-pwd.c b/nss/nss_borg/borg-pwd.c index f8927e2..9b5145f 100644 --- a/nss/nss_borg/borg-pwd.c +++ b/nss/nss_borg/borg-pwd.c @@ -86,13 +86,16 @@ static enum nss_status _nss_borg_getpwent_r_locked(struct passwd *result, int *errnop) { enum nss_status ret; - + // Save a copy of the buffer address, in case first call errors + // and sets it to 0. + struct passwd *sparecopy = result; if ( f != NULL && (fgetpwent_r(f, result, buffer, buflen, &result) == 0)) { DEBUG("Returning borg user %d:%s\n", result->pw_uid, result->pw_name); ret = NSS_STATUS_SUCCESS; } else if ( - fb != NULL && (fgetpwent_r(fb, result, buffer, buflen, &result) == 0)) { + // Yes, this is one of those cases where an assign makes sense. + fb != NULL && (result = sparecopy) && (fgetpwent_r(fb, result, buffer, buflen, &result) == 0)) { DEBUG("Returning base user %d:%s\n", result->pw_uid, result->pw_name); ret = NSS_STATUS_SUCCESS; } else { -- cgit v1.1