From 1e8e78ed07f64d7f6968661ee05be157e3144c4a Mon Sep 17 00:00:00 2001 From: ad Date: Sat, 18 Aug 2001 19:35:32 +0000 Subject: [PATCH] Update for pw_mkdb() change: restrict updates to one user's records and/or the secure database where appropriate. --- usr.bin/chpass/chpass.c | 6 +++--- usr.bin/passwd/local_passwd.c | 6 +++--- usr.sbin/rpc.yppasswdd/yppasswdd_mkpw.c | 6 +++--- usr.sbin/user/user.c | 15 +++++++++++---- usr.sbin/vipw/vipw.c | 6 +++--- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/usr.bin/chpass/chpass.c b/usr.bin/chpass/chpass.c index 6b613ef2bb35..891611864cdd 100644 --- a/usr.bin/chpass/chpass.c +++ b/usr.bin/chpass/chpass.c @@ -1,4 +1,4 @@ -/* $NetBSD: chpass.c,v 1.21 2001/02/13 00:11:45 cgd Exp $ */ +/* $NetBSD: chpass.c,v 1.22 2001/08/18 19:35:34 ad Exp $ */ /*- * Copyright (c) 1988, 1993, 1994 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)chpass.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: chpass.c,v 1.21 2001/02/13 00:11:45 cgd Exp $"); +__RCSID("$NetBSD: chpass.c,v 1.22 2001/08/18 19:35:34 ad Exp $"); #endif #endif /* not lint */ @@ -267,7 +267,7 @@ main(argc, argv) pw_copy(pfd, tfd, pw, (op == LOADENTRY) ? NULL : &old_pw); /* Now finish the passwd file update. */ - if (pw_mkdb() < 0) + if (pw_mkdb(username, 0) < 0) pw_error(NULL, 0, 1); exit(0); diff --git a/usr.bin/passwd/local_passwd.c b/usr.bin/passwd/local_passwd.c index fcf0f8db96e0..2393ca8818e9 100644 --- a/usr.bin/passwd/local_passwd.c +++ b/usr.bin/passwd/local_passwd.c @@ -1,4 +1,4 @@ -/* $NetBSD: local_passwd.c,v 1.22 2000/10/09 11:14:17 ad Exp $ */ +/* $NetBSD: local_passwd.c,v 1.23 2001/08/18 19:35:35 ad Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "from: @(#)local_passwd.c 8.3 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: local_passwd.c,v 1.22 2000/10/09 11:14:17 ad Exp $"); +__RCSID("$NetBSD: local_passwd.c,v 1.23 2001/08/18 19:35:35 ad Exp $"); #endif #endif /* not lint */ @@ -216,7 +216,7 @@ local_chpw(uname) pw_copy(pfd, tfd, pw, &old_pw); - if (pw_mkdb() < 0) + if (pw_mkdb(uname, pw_expiry == 0) < 0) pw_error((char *)NULL, 0, 1); return (0); } diff --git a/usr.sbin/rpc.yppasswdd/yppasswdd_mkpw.c b/usr.sbin/rpc.yppasswdd/yppasswdd_mkpw.c index 72661776ccff..311e5ffd5bdf 100644 --- a/usr.sbin/rpc.yppasswdd/yppasswdd_mkpw.c +++ b/usr.sbin/rpc.yppasswdd/yppasswdd_mkpw.c @@ -1,4 +1,4 @@ -/* $NetBSD: yppasswdd_mkpw.c,v 1.8 2000/12/08 22:23:14 tron Exp $ */ +/* $NetBSD: yppasswdd_mkpw.c,v 1.9 2001/08/18 19:35:32 ad Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: yppasswdd_mkpw.c,v 1.8 2000/12/08 22:23:14 tron Exp $"); +__RCSID("$NetBSD: yppasswdd_mkpw.c,v 1.9 2001/08/18 19:35:32 ad Exp $"); #endif /* not lint */ #include @@ -130,7 +130,7 @@ make_passwd(yppasswd *argp, struct svc_req *rqstp, SVCXPRT *transp) pw_copy(pfd, tfd, pw, NULL); - if (pw_mkdb() < 0) { + if (pw_mkdb(pw->pw_name, 0) < 0) { warnx("pw_mkdb failed"); pw_abort(); RETURN(1); diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c index 0f0b68afc496..a72f191b1a98 100644 --- a/usr.sbin/user/user.c +++ b/usr.sbin/user/user.c @@ -1,4 +1,4 @@ -/* $NetBSD: user.c,v 1.40 2001/08/17 08:29:00 joda Exp $ */ +/* $NetBSD: user.c,v 1.41 2001/08/18 19:35:33 ad Exp $ */ /* * Copyright (c) 1999 Alistair G. Crooks. All rights reserved. @@ -35,7 +35,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1999 \ The NetBSD Foundation, Inc. All rights reserved."); -__RCSID("$NetBSD: user.c,v 1.40 2001/08/17 08:29:00 joda Exp $"); +__RCSID("$NetBSD: user.c,v 1.41 2001/08/18 19:35:33 ad Exp $"); #endif #include @@ -992,7 +992,7 @@ adduser(char *login, user_t *up) errx(EXIT_FAILURE, "can't append `%s' to new groups", login); } (void) close(ptmpfd); - if (pw_mkdb() < 0) { + if (pw_mkdb(login, 0) < 0) { err(EXIT_FAILURE, "pw_mkdb failed"); } return 1; @@ -1012,6 +1012,7 @@ moduser(char *login, char *newlogin, user_t *up) char *buf, *colon, *line; int masterfd; int ptmpfd; + int error; if (!valid_login(newlogin)) { errx(EXIT_FAILURE, "`%s' is not a valid login name", login); @@ -1159,9 +1160,15 @@ moduser(char *login, char *newlogin, user_t *up) } } (void) close(ptmpfd); - if (pw_mkdb() < 0) { + if (up != NULL && strcmp(login, newlogin) == 0) { + error = pw_mkdb(login, 0); + } else { + error = pw_mkdb(NULL, 0); + } + if (error < 0) { err(EXIT_FAILURE, "pw_mkdb failed"); } + return 1; } diff --git a/usr.sbin/vipw/vipw.c b/usr.sbin/vipw/vipw.c index 35ab84b2fe78..6ce9e075d7e1 100644 --- a/usr.sbin/vipw/vipw.c +++ b/usr.sbin/vipw/vipw.c @@ -1,4 +1,4 @@ -/* $NetBSD: vipw.c,v 1.8 2001/02/19 23:22:49 cgd Exp $ */ +/* $NetBSD: vipw.c,v 1.9 2001/08/18 19:35:33 ad Exp $ */ /* * Copyright (c) 1987, 1993, 1994 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)vipw.c 8.3 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: vipw.c,v 1.8 2001/02/19 23:22:49 cgd Exp $"); +__RCSID("$NetBSD: vipw.c,v 1.9 2001/08/18 19:35:33 ad Exp $"); #endif #endif /* not lint */ @@ -123,7 +123,7 @@ main(int argc, char *argv[]) warnx("no changes made"); pw_error((char *)NULL, 0, 0); } - if (pw_mkdb() == 0) + if (pw_mkdb(NULL, 0) == 0) break; pw_prompt(); }