version 1.16, 2001/01/10 20:11:30 |
version 1.17, 2001/06/18 21:09:24 |
|
|
#include <err.h> |
#include <err.h> |
#include <errno.h> |
#include <errno.h> |
#include <ctype.h> |
#include <ctype.h> |
|
#include <login_cap.h> |
#include <rpc/rpc.h> |
#include <rpc/rpc.h> |
#include <rpcsvc/yp_prot.h> |
#include <rpcsvc/yp_prot.h> |
#include <rpcsvc/ypclnt.h> |
#include <rpcsvc/ypclnt.h> |
|
|
#define _PASSWORD_LEN PASS_MAX |
#define _PASSWORD_LEN PASS_MAX |
#endif |
#endif |
|
|
extern int pwd_gensalt __P(( char *, int, struct passwd *, char)); |
extern int pwd_gensalt __P((char *, int, struct passwd *, login_cap_t *, char)); |
extern int pwd_check __P((struct passwd *, char *)); |
extern int pwd_check __P((struct passwd *, login_cap_t *, char *)); |
extern int pwd_gettries __P((struct passwd *)); |
extern int pwd_gettries __P((struct passwd *, login_cap_t *)); |
|
|
char *ypgetnewpasswd __P((struct passwd *, char **)); |
char *ypgetnewpasswd __P((struct passwd *, login_cap_t *, char **)); |
struct passwd *ypgetpwnam __P((char *)); |
struct passwd *ypgetpwnam __P((char *)); |
|
|
char *domain; |
char *domain; |
|
|
struct passwd *pw; |
struct passwd *pw; |
struct timeval tv; |
struct timeval tv; |
CLIENT *client; |
CLIENT *client; |
|
login_cap_t *lc; |
|
|
/* |
/* |
* Get local domain |
* Get local domain |
|
|
warnx("unknown user %s.", username); |
warnx("unknown user %s.", username); |
return(1); |
return(1); |
} |
} |
|
if ((lc = login_getclass(pw->pw_class)) == NULL) { |
|
warnx("unable to get login class for user %s.", username); |
|
return(1); |
|
} |
|
|
uid = getuid(); |
uid = getuid(); |
if (uid && uid != pw->pw_uid) { |
if (uid && uid != pw->pw_uid) { |
|
|
} |
} |
|
|
/* prompt for new password */ |
/* prompt for new password */ |
yppasswd.newpw.pw_passwd = ypgetnewpasswd(pw, &yppasswd.oldpass); |
yppasswd.newpw.pw_passwd = ypgetnewpasswd(pw, lc, &yppasswd.oldpass); |
|
|
/* tell rpc.yppasswdd */ |
/* tell rpc.yppasswdd */ |
yppasswd.newpw.pw_name = pw->pw_name; |
yppasswd.newpw.pw_name = pw->pw_name; |
|
|
} |
} |
|
|
char * |
char * |
ypgetnewpasswd(pw, old_pass) |
ypgetnewpasswd(pw, lc, old_pass) |
struct passwd *pw; |
struct passwd *pw; |
|
login_cap_t *lc; |
char **old_pass; |
char **old_pass; |
{ |
{ |
static char buf[_PASSWORD_LEN+1]; |
static char buf[_PASSWORD_LEN+1]; |
|
|
pw_error(NULL, 1, 1); |
pw_error(NULL, 1, 1); |
} |
} |
|
|
pwd_tries = pwd_gettries(pw); |
pwd_tries = pwd_gettries(pw, lc); |
|
|
for (buf[0] = '\0', tries = 0;;) { |
for (buf[0] = '\0', tries = 0;;) { |
p = getpass("New password:"); |
p = getpass("New password:"); |
|
|
continue; |
continue; |
} |
} |
if ((tries++ < pwd_tries || pwd_tries == 0) |
if ((tries++ < pwd_tries || pwd_tries == 0) |
&& pwd_check(pw, p) == 0) |
&& pwd_check(pw, lc, p) == 0) |
continue; |
continue; |
strncpy(buf, p, sizeof buf-1); |
strncpy(buf, p, sizeof buf-1); |
buf[sizeof buf-1] = '\0'; |
buf[sizeof buf-1] = '\0'; |
|
|
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, '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); |
} |
} |