]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-aix-auth-speedup-20050508
authorSteve Roseman <sgr0@lehigh.edu>
Sun, 8 May 2005 06:51:24 +0000 (06:51 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sun, 8 May 2005 06:51:24 +0000 (06:51 +0000)
FIXES 18467

The security module "afs_dynamic_auth" can get VERY slow if trying to
authenticate against a user in a large NIS password file. This happens
because it "replaces" getpwnam with code which loops through the
"passwd" file.

this 1) makes external programs use the "real"
getpwnam, and 2) changes the internal routine afs_getpwnam_int to use
getpwnam instead of iterating.

(cherry picked from commit 160c01035ca3775d8bf21dd9a34bd0f51f309159)

src/tsm41/aix41_auth.c

index b9fa36e5a395def82360c156f026382d9220ca18..d9879a25bf6bab115cf862dbadd409c5af714b9b 100644 (file)
@@ -144,7 +144,7 @@ afs_getgrnam(char *name)
 struct passwd *
 afs_getpwnam(char *user)
 {
-    return (struct passwd *) afs_getpwnam_int(user, 0);
+  return (NULL);
 }
 
 struct passwd *
@@ -164,24 +164,23 @@ afs_getpwnam_int(char *user, int ignore)
     if (!user)
        return &pwd;
 
-    while ((p = getpwent()) != NULL) {
-       if (!strcmp(p->pw_name, user)) {
-           strncpy(&name, p->pw_name, sizeof(name));
-           strncpy(&passwd, p->pw_passwd, sizeof(passwd));
-           strncpy(&gecos, p->pw_gecos, sizeof(gecos));
-           strncpy(&dir, p->pw_dir, sizeof(dir));
-           strncpy(&shell, p->pw_shell, sizeof(shell));
-           pwd.pw_name = &name;
-           pwd.pw_passwd = &passwd;
-           pwd.pw_uid = p->pw_uid;
-           pwd.pw_gid = p->pw_gid;
-           pwd.pw_gecos = &gecos;
-           pwd.pw_dir = &dir;
-           pwd.pw_shell = &shell;
-           break;
-       }
+    p = getpwnam (user);
+    
+    if (p) {
+      strncpy(&name, p->pw_name, sizeof(name));
+      strncpy(&passwd, p->pw_passwd, sizeof(passwd));
+      strncpy(&gecos, p->pw_gecos, sizeof(gecos));
+      strncpy(&dir, p->pw_dir, sizeof(dir));
+      strncpy(&shell, p->pw_shell, sizeof(shell));
     }
-    endpwent();
+    pwd.pw_name = &name;
+    pwd.pw_passwd = &passwd;
+    pwd.pw_uid = p->pw_uid;
+    pwd.pw_gid = p->pw_gid;
+    pwd.pw_gecos = &gecos;
+    pwd.pw_dir = &dir;
+    pwd.pw_shell = &shell;
+
     if (ignore && (p == NULL))
        return NULL;
     return &pwd;