version 1.22, 2002/06/04 00:09:08 |
version 1.23, 2002/06/28 22:28:17 |
|
|
extern int pwd_gettries(struct passwd *, login_cap_t *); |
extern int pwd_gettries(struct passwd *, login_cap_t *); |
extern void kbintr(int); |
extern void kbintr(int); |
|
|
char *ypgetnewpasswd(struct passwd *, login_cap_t *, char **); |
char *ypgetnewpasswd(struct passwd *, login_cap_t *, char **); |
struct passwd *ypgetpwnam(char *); |
struct passwd *ypgetpwnam(char *); |
|
|
char *domain; |
char *domain; |
|
|
static int |
static int |
pw_error(name, err, eval) |
pw_error(char *name, int err, int eval) |
char *name; |
|
int err, eval; |
|
{ |
{ |
if (err) { |
if (err) { |
if (name) |
if (name) |
|
|
} |
} |
|
|
int |
int |
yp_passwd(username) |
yp_passwd(char *username) |
char *username; |
|
{ |
{ |
char *master; |
|
int r, rpcport, status; |
|
uid_t uid; |
|
struct yppasswd yppasswd; |
struct yppasswd yppasswd; |
|
int r, rpcport, status; |
struct passwd *pw; |
struct passwd *pw; |
struct timeval tv; |
struct timeval tv; |
CLIENT *client; |
|
login_cap_t *lc; |
login_cap_t *lc; |
|
CLIENT *client; |
|
char *master; |
|
uid_t uid; |
|
|
/* |
/* |
* Get local domain |
* Get local domain |
|
|
|
|
/* tell rpc.yppasswdd */ |
/* tell rpc.yppasswdd */ |
yppasswd.newpw.pw_name = pw->pw_name; |
yppasswd.newpw.pw_name = pw->pw_name; |
yppasswd.newpw.pw_uid = pw->pw_uid; |
yppasswd.newpw.pw_uid = pw->pw_uid; |
yppasswd.newpw.pw_gid = pw->pw_gid; |
yppasswd.newpw.pw_gid = pw->pw_gid; |
yppasswd.newpw.pw_gecos = pw->pw_gecos; |
yppasswd.newpw.pw_gecos = pw->pw_gecos; |
yppasswd.newpw.pw_dir = pw->pw_dir; |
yppasswd.newpw.pw_dir = pw->pw_dir; |
|
|
} |
} |
|
|
char * |
char * |
ypgetnewpasswd(pw, lc, old_pass) |
ypgetnewpasswd(struct passwd *pw, login_cap_t *lc, char **old_pass) |
struct passwd *pw; |
|
login_cap_t *lc; |
|
char **old_pass; |
|
{ |
{ |
static char buf[_PASSWORD_LEN+1]; |
static char buf[_PASSWORD_LEN+1]; |
char *p; |
|
int tries, pwd_tries; |
|
char salt[_PASSWORD_LEN]; |
char salt[_PASSWORD_LEN]; |
sig_t saveint, savequit; |
sig_t saveint, savequit; |
|
int tries, pwd_tries; |
|
char *p; |
|
|
saveint = signal(SIGINT, kbintr); |
saveint = signal(SIGINT, kbintr); |
savequit = signal(SIGQUIT, kbintr); |
savequit = signal(SIGQUIT, kbintr); |
|
|
if ((tries++ < pwd_tries || pwd_tries == 0) |
if ((tries++ < pwd_tries || pwd_tries == 0) |
&& pwd_check(pw, lc, p) == 0) |
&& pwd_check(pw, lc, p) == 0) |
continue; |
continue; |
strncpy(buf, p, sizeof buf-1); |
strlcpy(buf, p, sizeof buf); |
buf[sizeof buf-1] = '\0'; |
|
if (!strcmp(buf, getpass("Retype new password:"))) |
if (!strcmp(buf, getpass("Retype new password:"))) |
break; |
break; |
(void)printf("Mismatch; try again, EOF to quit.\n"); |
(void)printf("Mismatch; try again, EOF to quit.\n"); |
} |
} |
if(!pwd_gensalt(salt, _PASSWORD_LEN, pw, lc, 'y')) { |
if (!pwd_gensalt(salt, _PASSWORD_LEN, pw, lc, 'y')) { |
(void)printf("Couldn't generate salt.\n"); |
(void)printf("Couldn't generate salt.\n"); |
pw_error(NULL, 0, 0); |
pw_error(NULL, 0, 0); |
} |
} |
|
|
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; |
|
|
static char *__yplin; |
static char *__yplin; |
|
|
struct passwd * |
struct passwd * |
ypgetpwnam(nam) |
ypgetpwnam(char *nam) |
char *nam; |
|
{ |
{ |
static struct passwd pwent; |
static struct passwd pwent; |
char *val; |
|
int reason, vallen; |
int reason, vallen; |
|
char *val; |
|
|
reason = yp_match(domain, "passwd.byname", nam, strlen(nam), |
reason = yp_match(domain, "passwd.byname", nam, strlen(nam), |
&val, &vallen); |
&val, &vallen); |
switch(reason) { |
switch (reason) { |
case 0: |
case 0: |
break; |
break; |
default: |
default: |
|
|
__yplin = (char *)malloc(vallen + 1); |
__yplin = (char *)malloc(vallen + 1); |
if (__yplin == NULL) |
if (__yplin == NULL) |
pw_error(NULL, 1, 1); |
pw_error(NULL, 1, 1); |
strncpy(__yplin, val, vallen); |
strlcpy(__yplin, val, vallen + 1); |
__yplin[vallen] = '\0'; |
|
free(val); |
free(val); |
|
|
return (interpret(&pwent, __yplin)); |
return (interpret(&pwent, __yplin)); |