version 1.12, 2000/11/26 01:29:43 |
version 1.13, 2000/12/12 02:19:58 |
|
|
extern int pwd_gettries __P((struct passwd *)); |
extern int pwd_gettries __P((struct passwd *)); |
|
|
int |
int |
local_passwd(uname) |
local_passwd(uname, authenticated) |
char *uname; |
char *uname; |
|
int authenticated; |
{ |
{ |
struct passwd *pw; |
struct passwd *pw; |
int pfd, tfd; |
int pfd, tfd; |
|
|
return(1); |
return(1); |
} |
} |
|
|
uid = getuid(); |
uid = authenticated ? pw->pw_uid : getuid(); |
if (uid && uid != pw->pw_uid) { |
if (uid && uid != pw->pw_uid) { |
warnx("login/uid mismatch, username argument required."); |
warnx("login/uid mismatch, username argument required."); |
return(1); |
return(1); |
|
|
* classes are implemented, go and get the "offset" value for this |
* classes are implemented, go and get the "offset" value for this |
* class and reset the timer. |
* class and reset the timer. |
*/ |
*/ |
pw->pw_passwd = getnewpasswd(pw); |
pw->pw_passwd = getnewpasswd(pw, authenticated); |
pw->pw_change = 0; |
pw->pw_change = 0; |
pw_copy(pfd, tfd, pw); |
pw_copy(pfd, tfd, pw); |
|
|
|
|
} |
} |
|
|
char * |
char * |
getnewpasswd(pw) |
getnewpasswd(pw, authenticated) |
register struct passwd *pw; |
register struct passwd *pw; |
|
int authenticated; |
{ |
{ |
register char *p, *t; |
register char *p; |
int tries, pwd_tries; |
int tries, pwd_tries; |
char buf[_PASSWORD_LEN+1], salt[_PASSWORD_LEN], *crypt(), *getpass(); |
char buf[_PASSWORD_LEN+1], salt[_PASSWORD_LEN]; |
|
|
(void)printf("Changing local password for %s.\n", pw->pw_name); |
if (!authenticated) { |
|
(void)printf("Changing local password for %s.\n", pw->pw_name); |
if (uid && pw->pw_passwd[0] && |
if (uid && pw->pw_passwd[0] && |
strcmp(crypt(getpass("Old password:"), pw->pw_passwd), |
strcmp(crypt(getpass("Old password:"), pw->pw_passwd), |
pw->pw_passwd)) { |
pw->pw_passwd)) { |
errno = EACCES; |
errno = EACCES; |
pw_error(NULL, 1, 1); |
pw_error(NULL, 1, 1); |
|
} |
} |
} |
|
|
pwd_tries = pwd_gettries(pw); |
pwd_tries = pwd_gettries(pw); |
|
|
if ((tries++ < pwd_tries || pwd_tries == 0) |
if ((tries++ < pwd_tries || pwd_tries == 0) |
&& pwd_check(pw, p) == 0) |
&& pwd_check(pw, 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, 'l' )) { |
if(!pwd_gensalt(salt, _PASSWORD_LEN, pw, 'l')) { |
(void)printf("Couldn't generate salt.\n"); |
(void)printf("Couldn't generate salt.\n"); |
pw_error(NULL, 0, 0); |
pw_error(NULL, 0, 0); |
} |
} |