Date: Thu, 11 Jul 2002 12:50:12 -0700 From: "Crist J. Clark" <crist.clark@attbi.com> To: Doug Barton <dougb@FreeBSD.org> Cc: freebsd-bugs@FreeBSD.org Subject: Re: bin/39919: chpass no longer edits existing entries Message-ID: <20020711195012.GD40486@blossom.cjclark.org> In-Reply-To: <200207062016.g66KGZhN050936@freefall.freebsd.org> References: <200207062016.g66KGZhN050936@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
How does this patch look? Index: chpass.c =================================================================== RCS file: /export/freebsd/ncvs/src/usr.bin/chpass/chpass.c,v retrieving revision 1.16.2.2 diff -u -r1.16.2.2 chpass.c --- chpass.c 24 Mar 2002 09:00:03 -0000 1.16.2.2 +++ chpass.c 11 Jul 2002 19:45:28 -0000 @@ -40,7 +40,7 @@ #ifndef lint static const char sccsid[] = "From: @(#)chpass.c 8.4 (Berkeley) 4/2/94"; static const char rcsid[] = - "$FreeBSD: src/usr.bin/chpass/chpass.c,v 1.16.2.2 2002/03/24 09:00:03 cjc Exp $"; + "$FreeBSD: src/usr.bin/chpass/chpass.c,v 1.16.2.2 2002/03/24 05:35:51 cjc Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -83,7 +83,7 @@ char **argv; { enum { NEWSH, LOADENTRY, EDITENTRY, NEWPW, NEWEXP } op; - struct passwd *pw = NULL, lpw, old_pw; + struct passwd *pw = NULL, lpw, old_pw, *pold_pw; char *username = NULL; int ch, pfd, tfd; char *arg = NULL; @@ -190,6 +190,7 @@ /* Make a copy for later verification */ old_pw = *pw; old_pw.pw_gecos = strdup(old_pw.pw_gecos); + pold_pw = &old_pw; } if (op == NEWSH) { @@ -213,6 +214,10 @@ pw = &lpw; if (!pw_scan(arg, pw)) exit(1); + if ((pold_pw = getpwnam(pw->pw_name)) != NULL) { + old_pw = *pold_pw; + old_pw.pw_gecos = strdup(old_pw.pw_gecos); + } } username = pw->pw_name; @@ -268,7 +273,7 @@ } else { #endif /* YP */ pfd = pw_lock(); - pw_copy(pfd, tfd, pw, &old_pw); + pw_copy(pfd, tfd, pw, pold_pw); if (!pw_mkdb(username)) pw_error((char *)NULL, 0, 1); -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020711195012.GD40486>