]> granicus.if.org Git - sudo/commitdiff
Add flag to sudo_pwdup that indicates whether or not to lookup the
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 25 Sep 2004 21:01:46 +0000 (21:01 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 25 Sep 2004 21:01:46 +0000 (21:01 +0000)
shadow password.  Will be used to a struct passwd that has the
shadow password already filled in.

getspwuid.c

index cb635ab50eeb3bce5f30a4cdfeb1eeddce7a1101..55afb3123e2d175c88d51d8a11ed0932c740b274 100644 (file)
@@ -176,8 +176,9 @@ sudo_getepw(pw)
  * that we care about.  Fills in pw_passwd from shadow file if necessary.
  */
 struct passwd *
-sudo_pwdup(pw)
+sudo_pwdup(pw, checkshadow)
     const struct passwd *pw;
+    int checkshadow;
 {
     char *cp;
     const char *pw_passwd, *pw_shell;
@@ -185,7 +186,7 @@ sudo_pwdup(pw)
     struct passwd *newpw;
 
     /* Get shadow password if available. */
-    pw_passwd = sudo_getepw(pw);
+    pw_passwd = checkshadow ? sudo_getepw(pw) : pw->pw_passwd;
 
     /* If shell field is empty, expand to _PATH_BSHELL. */
     pw_shell = (pw->pw_shell == NULL || pw->pw_shell[0] == '\0')
@@ -279,7 +280,7 @@ sudo_getpwuid(uid)
     if ((pw = getpwuid(uid)) == NULL)
        return(NULL);
     else
-       return(sudo_pwdup(pw));
+       return(sudo_pwdup(pw, 1));
 }
 
 /*
@@ -295,5 +296,5 @@ sudo_getpwnam(name)
     if ((pw = getpwnam(name)) == NULL)
        return(NULL);
     else
-       return(sudo_pwdup(pw));
+       return(sudo_pwdup(pw, 1));
 }