mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-20 00:33:57 +00:00
Fix a core dump condition I discovered the other day (right
after I installed the last SNAP :). Because of the way the 'use NIS or local?' logic is set up here, it was possible to force the use of the NIS password changer even though the specified user didn't exist in NIS (i.e. # passwd foo, where foo is a local-only user). In this case, we fall intp yp_passwd() without the corresponding yp_password structure being filled in, which leads to an NULL pointer dereference. Also fixed the logic like I just did with chpass so that if the user is both in NIS and the local password database, the program makes a more sensible guess as to which one to use (if NIS is turned on in /etc/master.passwd, then use NIS, else default to local).
This commit is contained in:
parent
d7f248ea9f
commit
1fbf1a4630
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=19127
|
@ -43,7 +43,7 @@ static const char copyright[] =
|
|||
#ifndef lint
|
||||
static const char sccsid[] = "From: @(#)passwd.c 8.3 (Berkeley) 4/2/94";
|
||||
static const char rcsid[] =
|
||||
"$Id: passwd.c,v 1.7 1995/12/16 09:45:15 markm Exp $";
|
||||
"$Id: passwd.c,v 1.8 1996/02/23 16:08:26 wpaul Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
|
@ -181,7 +181,7 @@ main(argc, argv)
|
|||
if (__use_yp || (iflag == NULL && rflag == NULL && uflag == NULL)) {
|
||||
#endif
|
||||
res = use_yp(uname, 0, 0);
|
||||
if (res == USER_YP_ONLY || __use_yp) {
|
||||
if (res == USER_YP_ONLY) {
|
||||
if (!use_local_passwd) {
|
||||
exit(yp_passwd(uname));
|
||||
} else {
|
||||
|
@ -198,7 +198,7 @@ main(argc, argv)
|
|||
if (__use_yp)
|
||||
errx(1, "unknown NIS user: %s.", uname);
|
||||
} else if (res == USER_YP_AND_LOCAL) {
|
||||
if (!use_local_passwd)
|
||||
if (!use_local_passwd && (yp_in_pw_file || __use_yp))
|
||||
exit(yp_passwd(uname));
|
||||
}
|
||||
#ifdef KERBEROS
|
||||
|
|
Loading…
Reference in a new issue