From f3dab068fce37270e5e4e1a00e5a44e30f00baf7 Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Sun, 2 May 2021 16:00:07 -0400 Subject: Recommit everything, add chpass, improve history (except for a few files that git-filter-repo dislikes for some reason [_secure_path.c and login_cap.h]) --- chpass/chpass.c | 62 ++++++++++++++++++--------------------------------------- 1 file changed, 19 insertions(+), 43 deletions(-) (limited to 'chpass/chpass.c') diff --git a/chpass/chpass.c b/chpass/chpass.c index 643b0f3..3b3a41f 100644 --- a/chpass/chpass.c +++ b/chpass/chpass.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "chpass.h" @@ -237,51 +238,26 @@ main(int argc, char *argv[]) password = ""; } - if (old_pw != NULL) - pw->pw_fields |= (old_pw->pw_fields & _PWF_SOURCE); - switch (pw->pw_fields & _PWF_SOURCE) { -#ifdef YP - case _PWF_NIS: - ypclnt = ypclnt_new(yp_domain, "passwd.byname", yp_host); - if (ypclnt == NULL) { - warnx("ypclnt_new failed"); - exit(1); - } - if (ypclnt_connect(ypclnt) == -1 || - ypclnt_passwd(ypclnt, pw, password) == -1) { - warnx("%s", ypclnt->error); - ypclnt_free(ypclnt); - exit(1); - } - ypclnt_free(ypclnt); - errx(0, "NIS user information updated"); -#endif /* YP */ - case 0: - case _PWF_FILES: - if (pw_init(NULL, NULL)) - err(1, "pw_init()"); - if ((pfd = pw_lock()) == -1) { - pw_fini(); - err(1, "pw_lock()"); - } - if ((tfd = pw_tmp(-1)) == -1) { - pw_fini(); - err(1, "pw_tmp()"); - } - if (pw_copy(pfd, tfd, pw, old_pw) == -1) { - pw_fini(); - err(1, "pw_copy"); - } - if (pw_mkdb(pw->pw_name) == -1) { - pw_fini(); - err(1, "pw_mkdb()"); - } + if (pw_init(NULL, NULL)) + err(1, "pw_init()"); + if ((pfd = pw_lock()) == -1) { + pw_fini(); + err(1, "pw_lock()"); + } + if ((tfd = pw_tmp(-1)) == -1) { + pw_fini(); + err(1, "pw_tmp()"); + } + if (pw_copy(pfd, tfd, pw, old_pw) == -1) { + pw_fini(); + err(1, "pw_copy"); + } + if (pw_mkdb(pw->pw_name) == -1) { pw_fini(); - errx(0, "user information updated"); - break; - default: - errx(1, "unsupported passwd source"); + err(1, "pw_mkdb()"); } + pw_fini(); + errx(0, "user information updated"); } static void -- cgit v1.2.3-56-ge451