]> andersk Git - nss_nonlocal.git/blobdiff - nonlocal-passwd.c
Check that a nonlocal lookup by name returns the right name.
[nss_nonlocal.git] / nonlocal-passwd.c
index a5570df6040f7217b69ea4a849f97bbe1ca08b4a..29e922be62c42d2828b65ad71dc89fd78727920c 100644 (file)
@@ -79,7 +79,7 @@ check_nonlocal_uid(const char *user, uid_t uid, int *errnop)
     struct passwd pwbuf;
     int old_errno = errno;
 
-    int buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
+    size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
     char *buf = malloc(buflen);
     if (buf == NULL) {
        *errnop = ENOMEM;
@@ -140,7 +140,7 @@ check_nonlocal_user(const char *user, int *errnop)
     struct passwd pwbuf;
     int old_errno = errno;
 
-    int buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
+    size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
     char *buf = malloc(buflen);
     if (buf == NULL) {
        *errnop = ENOMEM;
@@ -329,6 +329,11 @@ _nss_nonlocal_getpwnam_r(const char *name, struct passwd *pwd,
     if (status != NSS_STATUS_SUCCESS)
        return status;
 
+    if (strcmp(name, pwd->pw_name) != 0) {
+       syslog(LOG_ERR, "nss_nonlocal: discarding user %s from lookup for user %s\n", pwd->pw_name, name);
+       return NSS_STATUS_NOTFOUND;
+    }
+
     status = check_nonlocal_uid(name, pwd->pw_uid, errnop);
     if (status != NSS_STATUS_SUCCESS)
        return status;
This page took 0.048054 seconds and 4 git commands to generate.