]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Handle a not-found case in borg passwd lookup
authorStan Shebs <stanshebs@google.com>
Thu, 3 Nov 2016 23:31:52 +0000 (16:31 -0700)
committerStan Shebs <stanshebs@google.com>
Thu, 3 Nov 2016 23:31:52 +0000 (16:31 -0700)
README.google
nss/nss_borg/borg-pwd.c

index 2b24beb850be9ca5db40d37e02ca301c9c62d55b..7b548cd60cc788353d92719e6d50b64e1ee4c9a3 100644 (file)
@@ -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)
index f8927e2beca0bbc0c2482e5648f79db1027f2a29..9b5145f0a8a0eb897e91c0a634b034fe158a2cd8 100644 (file)
@@ -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 {