version 1.21, 2006/03/31 00:29:13 |
version 1.22, 2009/02/15 21:43:40 |
|
|
} |
} |
|
|
static struct passwd * |
static struct passwd * |
interpret(struct passwd *pwent, char *line) |
interpret(struct passwd *pwent, char *line, const int secure) |
{ |
{ |
char *p = line; |
char *p = line; |
|
|
|
|
pwent->pw_class = ""; |
pwent->pw_class = ""; |
|
|
/* line without colon separators is no good, so ignore it */ |
/* line without colon separators is no good, so ignore it */ |
if(!strchr(p,':')) |
if (!strchr(p,':')) |
return(NULL); |
return(NULL); |
|
|
pwent->pw_name = p; |
pwent->pw_name = p; |
|
|
p = pwskip(p); |
p = pwskip(p); |
pwent->pw_gid = (gid_t)strtoul(p, NULL, 10); |
pwent->pw_gid = (gid_t)strtoul(p, NULL, 10); |
p = pwskip(p); |
p = pwskip(p); |
|
if (secure == 1) { |
|
pwent->pw_class = p; |
|
p = pwskip(p); |
|
pwent->pw_change = (time_t)strtoul(p, NULL, 10); |
|
p = pwskip(p); |
|
pwent->pw_expire = (time_t)strtoul(p, NULL, 10); |
|
p = pwskip(p); |
|
} |
pwent->pw_gecos = p; |
pwent->pw_gecos = p; |
p = pwskip(p); |
p = pwskip(p); |
pwent->pw_dir = p; |
pwent->pw_dir = p; |
|
|
ypgetpwnam(char *nam) |
ypgetpwnam(char *nam) |
{ |
{ |
static struct passwd pwent; |
static struct passwd pwent; |
int reason, vallen; |
int reason, vallen, secure = 0; |
char *val; |
char *val; |
|
|
/* |
/* |
|
|
exit(1); |
exit(1); |
} |
} |
|
|
reason = yp_match(domain, "passwd.byname", nam, strlen(nam), |
if (!yp_match(domain, "master.passwd.byname", nam, strlen(nam), |
&val, &vallen); |
&val, &vallen)) |
switch(reason) { |
secure = 1; |
case 0: |
else if (yp_match(domain, "passwd.byname", nam, strlen(nam), |
break; |
&val, &vallen)) |
default: |
|
return (NULL); |
return (NULL); |
} |
|
val[vallen] = '\0'; |
val[vallen] = '\0'; |
if (__yplin) |
if (__yplin) |
free(__yplin); |
free(__yplin); |
|
|
strlcpy(__yplin, val, vallen + 1); |
strlcpy(__yplin, val, vallen + 1); |
free(val); |
free(val); |
|
|
return(interpret(&pwent, __yplin)); |
return(interpret(&pwent, __yplin, secure)); |
} |
} |
|
|
struct passwd * |
struct passwd * |
ypgetpwuid(uid_t uid) |
ypgetpwuid(uid_t uid) |
{ |
{ |
static struct passwd pwent; |
static struct passwd pwent; |
int reason, vallen; |
int reason, vallen, secure = 0; |
char namebuf[16], *val; |
char namebuf[16], *val; |
|
|
if (!domain && (reason = yp_get_default_domain(&domain))) { |
if (!domain && (reason = yp_get_default_domain(&domain))) { |
|
|
} |
} |
|
|
snprintf(namebuf, sizeof namebuf, "%u", (u_int)uid); |
snprintf(namebuf, sizeof namebuf, "%u", (u_int)uid); |
reason = yp_match(domain, "passwd.byuid", namebuf, strlen(namebuf), |
if (!yp_match(domain, "master.passwd.byuid", namebuf, strlen(namebuf), |
&val, &vallen); |
&val, &vallen)) |
switch(reason) { |
secure = 1; |
case 0: |
else if (yp_match(domain, "passwd.byuid", namebuf, strlen(namebuf), |
break; |
&val, &vallen)) |
default: |
|
return (NULL); |
return (NULL); |
} |
|
val[vallen] = '\0'; |
val[vallen] = '\0'; |
if (__yplin) |
if (__yplin) |
free(__yplin); |
free(__yplin); |
|
|
strlcpy(__yplin, val, vallen + 1); |
strlcpy(__yplin, val, vallen + 1); |
free(val); |
free(val); |
|
|
return(interpret(&pwent, __yplin)); |
return(interpret(&pwent, __yplin, secure)); |
} |
} |
|
|
#endif /* YP */ |
#endif /* YP */ |