diff options
author | Jeremy Allison <jra@samba.org> | 2001-04-30 22:56:52 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-04-30 22:56:52 +0000 |
commit | 75da59c8add1a8dc30ef89765850c47e2205ab94 (patch) | |
tree | 9b093bc14766526daa42acfc75d98cceca8ca8ba | |
parent | e3ca9f33bb979cc341286e37f4f2f5d3e47c4124 (diff) | |
download | samba-75da59c8add1a8dc30ef89765850c47e2205ab94.tar.gz samba-75da59c8add1a8dc30ef89765850c47e2205ab94.tar.bz2 samba-75da59c8add1a8dc30ef89765850c47e2205ab94.zip |
Fixed password entry caching bug pointed out by Elrond.
Jeremy.
(This used to be commit dc31b47deda188cb88288a8f33dc09faed9b2c41)
-rw-r--r-- | source3/lib/system.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/source3/lib/system.c b/source3/lib/system.c index 0c627b2f65..810096ef36 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -583,6 +583,9 @@ int sys_setgroups(int setlen, gid_t *gidset) struct saved_pw { fstring pw_name; fstring pw_passwd; + fstring pw_gecos; + pstring pw_dir; + pstring pw_shell; struct passwd pass; }; @@ -594,6 +597,26 @@ static int num_lookups; /* Counter so we don't always use cache. */ #define PW_RET_CACHE_MAX_LOOKUPS 100 #endif +static void copy_pwent(struct saved_pw *dst, struct passwd *pass) +{ + memcpy((char *)&dst->pass, pass, sizeof(struct passwd)); + + fstrcpy(dst->pw_name, pass->pw_name); + dst->pass.pw_name = dst->pw_name; + + fstrcpy(dst->pw_passwd, pass->pw_passwd); + dst->pass.pw_passwd = dst->pw_passwd; + + fstrcpy(dst->pw_gecos, pass->pw_gecos); + dst->pass.pw_gecos = dst->pw_gecos; + + pstrcpy(dst->pw_dir, pass->pw_dir); + dst->pass.pw_dir = dst->pw_dir; + + pstrcpy(dst->pw_shell, pass->pw_shell); + dst->pass.pw_shell = dst->pw_shell; +} + static struct passwd *setup_pwret(struct passwd *pass) { if (pass == NULL) { @@ -604,25 +627,13 @@ static struct passwd *setup_pwret(struct passwd *pass) return NULL; } - /* this gets the uid, gid and null pointers */ - - memcpy((char *)&pw_mod.pass, pass, sizeof(struct passwd)); - fstrcpy(pw_mod.pw_name, pass->pw_name); - pw_mod.pass.pw_name = pw_mod.pw_name; - fstrcpy(pw_mod.pw_passwd, pass->pw_passwd); - pw_mod.pass.pw_passwd = pw_mod.pw_passwd; - + copy_pwent( &pw_mod, pass); if (pass != &pw_cache.pass) { /* If it's a cache miss we must also refill the cache. */ - memcpy((char *)&pw_cache.pass, pass, sizeof(struct passwd)); - fstrcpy(pw_cache.pw_name, pass->pw_name); - pw_cache.pass.pw_name = pw_cache.pw_name; - fstrcpy(pw_cache.pw_passwd, pass->pw_passwd); - pw_cache.pass.pw_passwd = pw_cache.pw_passwd; - + copy_pwent( &pw_cache, pass); num_lookups = 1; } else { |