-# $OpenBSD: Makefile,v 1.7 2014/04/22 10:21:56 reyk Exp $
+# $OpenBSD: Makefile,v 1.8 2015/10/22 12:32:33 tedu Exp $
PROG= login_chpass
.if (${YP:L} == "yes")
CFLAGS+=-DYP
-SRCS+= yp_passwd.c pwd_check.c pwd_gensalt.c
+SRCS+= yp_passwd.c pwd_check.c
DPADD+= ${LIBRPCSVC} ${LIBUTIL}
LDADD+= -lrpcsvc -lutil
.endif
-/* $OpenBSD: login_chpass.c,v 1.17 2015/10/05 17:31:17 millert Exp $ */
+/* $OpenBSD: login_chpass.c,v 1.18 2015/10/22 12:32:33 tedu Exp $ */
/*-
* Copyright (c) 1995,1996 Berkeley Software Design, Inc. All rights reserved.
}
}
if (pw == NULL) {
- char *p, salt[_PASSWORD_LEN + 1];
- login_cap_t *lc;
-
- /* no such user, get appropriate salt to thwart timing attack */
+ char *p;
+ /* no such user, but fake to thwart timing attack */
if ((p = getpass("Old password:")) != NULL) {
- if ((lc = login_getclass(NULL)) == NULL ||
- pwd_gensalt(salt, sizeof(salt), lc, 'y') == 0)
- strlcpy(salt, "xx", sizeof(salt));
- crypt(p, salt);
+ crypt_checkpass(p, NULL);
explicit_bzero(p, strlen(p));
}
warnx("YP passwd database unchanged.");
-# $OpenBSD: Makefile,v 1.3 2001/06/19 16:38:21 millert Exp $
+# $OpenBSD: Makefile,v 1.4 2015/10/22 12:32:33 tedu Exp $
# BSDI $From: Makefile,v 1.2 1997/08/08 18:58:22 prb Exp $
PROG= login_lchpass
-SRCS= login_lchpass.c local_passwd.c pwd_check.c pwd_gensalt.c
+SRCS= login_lchpass.c local_passwd.c pwd_check.c
MAN= login_lchpass.8
.PATH: ${.CURDIR}/../../usr.bin/passwd
-/* $OpenBSD: login_lchpass.c,v 1.15 2015/10/05 17:31:17 millert Exp $ */
+/* $OpenBSD: login_lchpass.c,v 1.16 2015/10/22 12:32:33 tedu Exp $ */
/*-
* Copyright (c) 1995,1996 Berkeley Software Design, Inc. All rights reserved.
login_cap_t *lc;
struct iovec iov[2];
struct passwd *pwd;
- char *username = NULL, *salt, *p, saltbuf[_PASSWORD_LEN + 1];
+ char *username = NULL, *hash = NULL, *p;
struct rlimit rl;
int c;
}
if (pwd)
- salt = pwd->pw_passwd;
- else {
- /* no such user, get appropriate salt */
- if ((lc = login_getclass(NULL)) == NULL ||
- pwd_gensalt(saltbuf, sizeof(saltbuf), lc, 'l') == 0)
- salt = "xx";
- else
- salt = saltbuf;
- }
+ hash = pwd->pw_passwd;
(void)setpriority(PRIO_PROCESS, 0, -4);
if ((p = getpass("Old Password:")) == NULL)
exit(1);
- salt = crypt(p, salt);
- explicit_bzero(p, strlen(p));
- if (!pwd || strcmp(salt, pwd->pw_passwd) != 0)
+ if (crypt_checkpass(p, hash) != 0) {
+ explicit_bzero(p, strlen(p));
exit(1);
+ }
+ explicit_bzero(p, strlen(p));
/*
* We rely on local_passwd() to block signals during the