diff options
author | Stan Shebs <stanshebs@google.com> | 2016-11-03 16:31:52 -0700 |
---|---|---|
committer | Stan Shebs <stanshebs@google.com> | 2016-11-03 16:31:52 -0700 |
commit | b6099fb5b289b63204333465cfd704f45a824033 (patch) | |
tree | f5543e11c406c6b729a1fdee6bcc7ae968845cd2 | |
parent | 929275c19315abec2eb854c976751f2745572a8e (diff) | |
download | glibc-b6099fb5b289b63204333465cfd704f45a824033.zip glibc-b6099fb5b289b63204333465cfd704f45a824033.tar.gz glibc-b6099fb5b289b63204333465cfd704f45a824033.tar.bz2 |
Handle a not-found case in borg passwd lookup
-rw-r--r-- | README.google | 4 | ||||
-rw-r--r-- | 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 { |