diff options
author | wpaul <wpaul@FreeBSD.org> | 1995-02-05 02:12:49 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1995-02-05 02:12:49 +0000 |
commit | 30b1b88a7de5e100059fef304e33f0473f5a8e30 (patch) | |
tree | 1d07521da98f5597ff4b902a5f43037de110a431 /lib/libc | |
parent | 850294c714fcfe37c906280372420d4c7b73c33c (diff) | |
download | FreeBSD-src-30b1b88a7de5e100059fef304e33f0473f5a8e30.zip FreeBSD-src-30b1b88a7de5e100059fef304e33f0473f5a8e30.tar.gz |
Collapsed _masterpw_breakout_yp() and _pw_breakout_yp() into a
single function.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/getpwent.c | 92 |
1 files changed, 20 insertions, 72 deletions
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index e8a86a8..c9bbd37 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -269,7 +269,7 @@ __hashpw(key) * at some point since __hashpw() can be called several times in * a single program. If we leave here after the second invokation * with garbage data in pw_fields, it can totally screw up NIS - * lookups (the pw_breakout functions only populate the pw_passwd + * lookups (the pw_breakout_yp function only populates the pw_passwd * structure if the pw_fields bits are clear). */ if ((_pw_db->get)(_pw_db, key, &data, 0)) { @@ -307,7 +307,7 @@ __hashpw(key) #ifdef YP static void -_pw_breakout_yp(struct passwd *pw, char *result) +_pw_breakout_yp(struct passwd *pw, char *result, int master) { char *s; @@ -335,70 +335,24 @@ _pw_breakout_yp(struct passwd *pw, char *result) pw->pw_fields |= _PWF_GID; } - s = strsep(&result, ":"); /* gecos */ - if(!(pw->pw_fields & _PWF_GECOS)) { - pw->pw_gecos = s; - pw->pw_fields |= _PWF_GECOS; - } - - s = strsep(&result, ":"); /* dir */ - if(!(pw->pw_fields & _PWF_DIR)) { - pw->pw_dir = s; - pw->pw_fields |= _PWF_DIR; - } - - s = strsep(&result, ":"); /* shell */ - if(!(pw->pw_fields & _PWF_SHELL)) { - pw->pw_shell = s; - pw->pw_fields |= _PWF_SHELL; - } -} - -static void -_masterpw_breakout_yp(struct passwd *pw, char *result) -{ - char *s; - - s = strsep(&result, ":"); /* name */ - if(!(pw->pw_fields & _PWF_NAME) || (pw->pw_name[0] == '+')) { - pw->pw_name = s; - pw->pw_fields |= _PWF_NAME; - } - - s = strsep(&result, ":"); /* password */ - if(!(pw->pw_fields & _PWF_PASSWD)) { - pw->pw_passwd = s; - pw->pw_fields |= _PWF_PASSWD; - } - - s = strsep(&result, ":"); /* uid */ - if(!(pw->pw_fields & _PWF_UID)) { - pw->pw_uid = atoi(s); - pw->pw_fields |= _PWF_UID; - } - - s = strsep(&result, ":"); /* gid */ - if(!(pw->pw_fields & _PWF_GID)) { - pw->pw_gid = atoi(s); - pw->pw_fields |= _PWF_GID; - } - - s = strsep(&result, ":"); /* class */ - if(!(pw->pw_fields & _PWF_CLASS)) { - pw->pw_class = s; - pw->pw_fields |= _PWF_CLASS; - } + if (master) { + s = strsep(&result, ":"); /* class */ + if(!(pw->pw_fields & _PWF_CLASS)) { + pw->pw_class = s; + pw->pw_fields |= _PWF_CLASS; + } - s = strsep(&result, ":"); /* change */ - if(!(pw->pw_fields & _PWF_CHANGE)) { - pw->pw_change = atol(s); - pw->pw_fields |= _PWF_CHANGE; - } + s = strsep(&result, ":"); /* change */ + if(!(pw->pw_fields & _PWF_CHANGE)) { + pw->pw_change = atol(s); + pw->pw_fields |= _PWF_CHANGE; + } - s = strsep(&result, ":"); /* expire */ - if(!(pw->pw_fields & _PWF_EXPIRE)) { - pw->pw_expire = atol(s); - pw->pw_fields |= _PWF_EXPIRE; + s = strsep(&result, ":"); /* expire */ + if(!(pw->pw_fields & _PWF_EXPIRE)) { + pw->pw_expire = atol(s); + pw->pw_fields |= _PWF_EXPIRE; + } } s = strsep(&result, ":"); /* gecos */ @@ -470,10 +424,7 @@ _getyppass(struct passwd *pw, const char *name, const char *map) if(resultlen >= sizeof resultbuf) return 0; strcpy(resultbuf, result); result = resultbuf; - if (gotmaster) - _masterpw_breakout_yp(pw, resultbuf); - else - _pw_breakout_yp(pw, resultbuf); + _pw_breakout_yp(pw, resultbuf, gotmaster); return 1; } @@ -531,10 +482,7 @@ unpack: strcpy(resultbuf, result); free(result); if(result = strchr(resultbuf, '\n')) *result = '\0'; - if (gotmaster) - _masterpw_breakout_yp(pw, resultbuf); - else - _pw_breakout_yp(pw, resultbuf); + _pw_breakout_yp(pw, resultbuf, gotmaster); } return 1; } |