diff options
author | 2000-06-05 14:01:15 +0000 | |
---|---|---|
committer | 2000-06-05 14:01:15 +0000 | |
commit | f5ba15c9ac8665502175bc9baef72ad6ddcb7fcd (patch) | |
tree | e69c02d841e1b8a17a262f0691cbc81d5639219a /usr.bin/sudo/getspwuid.c | |
parent | Err, make it splclock(9), so it's more clear to the reader. (diff) | |
download | wireguard-openbsd-f5ba15c9ac8665502175bc9baef72ad6ddcb7fcd.tar.xz wireguard-openbsd-f5ba15c9ac8665502175bc9baef72ad6ddcb7fcd.zip |
Update to sudo 1.6.3p4
Diffstat (limited to 'usr.bin/sudo/getspwuid.c')
-rw-r--r-- | usr.bin/sudo/getspwuid.c | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/usr.bin/sudo/getspwuid.c b/usr.bin/sudo/getspwuid.c index f9056c6bf05..2d9248d837e 100644 --- a/usr.bin/sudo/getspwuid.c +++ b/usr.bin/sudo/getspwuid.c @@ -93,7 +93,8 @@ int crypt_type = INT_MAX; /* * Local functions not visible outside getspwuid.c */ -static char *sudo_getshell __P((struct passwd *)); +static char *sudo_getshell __P((struct passwd *)); +static struct passwd *sudo_pwdup __P((struct passwd *)); /* @@ -191,14 +192,11 @@ sudo_getepw(pw) * Dynamically allocate space for a struct password and the constituent parts * that we care about. Fills in pw_passwd from shadow file if necessary. */ -struct passwd * -sudo_getpwuid(uid) - uid_t uid; +static struct passwd * +sudo_pwdup(pw) + struct passwd *pw; { - struct passwd *pw, *local_pw; - - if ((pw = getpwuid(uid)) == NULL) - return(NULL); + struct passwd *local_pw; /* Allocate space for a local copy of pw. */ local_pw = (struct passwd *) emalloc(sizeof(struct passwd)); @@ -218,3 +216,35 @@ sudo_getpwuid(uid) return(local_pw); } + +/* + * Get a password entry by uid and allocate space for it. + * Fills in pw_passwd from shadow file if necessary. + */ +struct passwd * +sudo_getpwuid(uid) + uid_t uid; +{ + struct passwd *pw; + + if ((pw = getpwuid(uid)) == NULL) + return(NULL); + else + return(sudo_pwdup(pw)); +} + +/* + * Get a password entry by name and allocate space for it. + * Fills in pw_passwd from shadow file if necessary. + */ +struct passwd * +sudo_getpwnam(name) + const char *name; +{ + struct passwd *pw; + + if ((pw = getpwnam(name)) == NULL) + return(NULL); + else + return(sudo_pwdup(pw)); +} |