version 1.26, 2002/06/28 22:28:17 |
version 1.27, 2003/03/30 20:50:05 |
|
|
#include <util.h> |
#include <util.h> |
#include <login_cap.h> |
#include <login_cap.h> |
|
|
|
#define UNCHANGED_MSG "Password unchanged.\n" |
|
|
static uid_t uid; |
static uid_t uid; |
extern int pwd_gensalt(char *, int, struct passwd *, login_cap_t *, char); |
extern int pwd_gensalt(char *, int, struct passwd *, login_cap_t *, char); |
extern int pwd_check(struct passwd *, login_cap_t *, char *); |
extern int pwd_check(struct passwd *, login_cap_t *, char *); |
|
|
|
|
if (!authenticated) { |
if (!authenticated) { |
(void)printf("Changing local password for %s.\n", pw->pw_name); |
(void)printf("Changing local password for %s.\n", pw->pw_name); |
if (uid && pw->pw_passwd[0] && |
if (uid != 0 && pw->pw_passwd[0] != '\0') { |
strcmp(crypt(getpass("Old password:"), pw->pw_passwd), |
p = getpass("Old password:"); |
pw->pw_passwd)) { |
if (*p == '\0') { |
errno = EACCES; |
(void)printf(UNCHANGED_MSG); |
pw_error(NULL, 1, 1); |
pw_abort(); |
|
exit(0); |
|
} |
|
if (strcmp(crypt(p, pw->pw_passwd), pw->pw_passwd)) { |
|
errno = EACCES; |
|
pw_error(NULL, 1, 1); |
|
} |
} |
} |
} |
} |
|
|
|
|
|
|
for (buf[0] = '\0', tries = 0;;) { |
for (buf[0] = '\0', tries = 0;;) { |
p = getpass("New password:"); |
p = getpass("New password:"); |
if (!*p) { |
if (*p == '\0') { |
(void)printf("Password unchanged.\n"); |
(void)printf(UNCHANGED_MSG); |
pw_error(NULL, 0, 0); |
pw_abort(); |
|
exit(0); |
} |
} |
if (strcmp(p, "s/key") == 0) { |
if (strcmp(p, "s/key") == 0) { |
printf("That password collides with a system feature. Choose another.\n"); |
printf("That password collides with a system feature. Choose another.\n"); |
|
|
void |
void |
kbintr(int signo) |
kbintr(int signo) |
{ |
{ |
char msg[] = "\nPassword unchanged.\n"; |
write(STDOUT_FILENO, UNCHANGED_MSG, sizeof(UNCHANGED_MSG) - 1); |
struct iovec iv[5]; |
_exit(0); |
extern char *__progname; |
|
|
|
iv[0].iov_base = msg; |
|
iv[0].iov_len = sizeof(msg) - 1; |
|
iv[1].iov_base = __progname; |
|
iv[1].iov_len = strlen(__progname); |
|
iv[2].iov_base = ": "; |
|
iv[2].iov_len = 2; |
|
iv[3].iov_base = _PATH_MASTERPASSWD; |
|
iv[3].iov_len = sizeof(_PATH_MASTERPASSWD) - 1; |
|
iv[4].iov_base = " unchanged\n"; |
|
iv[4].iov_len = 11; |
|
writev(STDERR_FILENO, iv, 5); |
|
|
|
_exit(1); |
|
} |
} |