From owner-freebsd-bugs Thu Jul 11 12:50:24 2002 Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 96C5F37B400; Thu, 11 Jul 2002 12:50:16 -0700 (PDT) Received: from rwcrmhc51.attbi.com (rwcrmhc51.attbi.com [204.127.198.38]) by mx1.FreeBSD.org (Postfix) with ESMTP id EB87443E52; Thu, 11 Jul 2002 12:50:12 -0700 (PDT) (envelope-from crist.clark@attbi.com) Received: from blossom.cjclark.org ([12.234.91.48]) by rwcrmhc51.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020711195012.PEKL24728.rwcrmhc51.attbi.com@blossom.cjclark.org>; Thu, 11 Jul 2002 19:50:12 +0000 Received: from blossom.cjclark.org (localhost. [127.0.0.1]) by blossom.cjclark.org (8.12.3/8.12.3) with ESMTP id g6BJoCJK040973; Thu, 11 Jul 2002 12:50:12 -0700 (PDT) (envelope-from crist.clark@attbi.com) Received: (from cjc@localhost) by blossom.cjclark.org (8.12.3/8.12.3/Submit) id g6BJoCaI040972; Thu, 11 Jul 2002 12:50:12 -0700 (PDT) X-Authentication-Warning: blossom.cjclark.org: cjc set sender to crist.clark@attbi.com using -f Date: Thu, 11 Jul 2002 12:50:12 -0700 From: "Crist J. Clark" To: Doug Barton Cc: freebsd-bugs@FreeBSD.org Subject: Re: bin/39919: chpass no longer edits existing entries Message-ID: <20020711195012.GD40486@blossom.cjclark.org> Reply-To: cjclark@alum.mit.edu References: <200207062016.g66KGZhN050936@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200207062016.g66KGZhN050936@freefall.freebsd.org> User-Agent: Mutt/1.4i X-URL: http://people.freebsd.org/~cjc/ Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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 @@ -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