From ajk@physics.purdue.edu  Fri Oct 16 22:12:18 1998
Received: from poynting.physics.purdue.edu (poynting.physics.purdue.edu [128.210.146.58])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA29590
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 16 Oct 1998 22:12:18 -0700 (PDT)
          (envelope-from ajk@physics.purdue.edu)
Received: (from ajk@localhost)
	by poynting.physics.purdue.edu (8.8.8/8.8.8) id AAA25288;
	Sat, 17 Oct 1998 00:11:57 -0500 (EST)
Message-Id: <199810170511.AAA25288@poynting.physics.purdue.edu>
Date: Sat, 17 Oct 1998 00:11:57 -0500 (EST)
From: ajk@purdue.edu
Reply-To: ajk@purdue.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: vipw and chpass echo bogus error messages
X-Send-Pr-Version: 3.2

>Number:         8353
>Category:       bin
>Synopsis:       vipw and chpass echo bogus error messages
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 16 22:20:01 PDT 1998
>Closed-Date:    Tue Oct 20 04:34:22 PDT 1998
>Last-Modified:  Tue Oct 20 04:35:17 PDT 1998
>Originator:     Andrew J. Korty
>Release:        FreeBSD 3.0-BETA i386
>Organization:
Purdue University Physics Department
>Environment:

FreeBSD volta.physics.purdue.edu 3.0-BETA FreeBSD 3.0-BETA #3:
Tue Oct 13 15:04:20 EST 1998
csg@volta.physics.purdue.edu:/usr/src/sys/compile/VOLTA  i386

>Description:

A call to vfork() was replaced by a call to fork() in pw_util.c
recently.  Later, warn() is called in the parent process, expecting
it to have remained intact from the execlp() called in the child.

>How-To-Repeat:

env EDITOR=/nonexistent vipw

>Fix:
	
One possible solution:

*** src/usr.sbin/pw_util.c.orig	1998/10/13 14:52:33	1.10
--- src/usr.sbin/pw_util.c	1998/10/17 04:37:49
***************
*** 44,49 ****
--- 44,50 ----
   * and passwd(1).
   */
  
+ #include <sys/errno.h>
  #include <sys/param.h>
  #include <sys/time.h>
  #include <sys/resource.h>
***************
*** 185,200 ****
  			(void)setgid(getgid());
  			(void)setuid(getuid());
  		}
  		execlp(editor, p, tempname, NULL);
! 		_exit(1);
  	}
  	for (;;) {
  		editpid = waitpid(editpid, (int *)&pstat, WUNTRACED);
  		if (editpid == -1)
  			pw_error(editor, 1, 1);
  		else if (WIFSTOPPED(pstat))
  			raise(WSTOPSIG(pstat));
! 		else if (WIFEXITED(pstat) && WEXITSTATUS(pstat) == 0)
  			break;
  		else
  			pw_error(editor, 1, 1);
--- 186,203 ----
  			(void)setgid(getgid());
  			(void)setuid(getuid());
  		}
+ 		errno = 0;
  		execlp(editor, p, tempname, NULL);
! 		_exit(errno);
  	}
  	for (;;) {
  		editpid = waitpid(editpid, (int *)&pstat, WUNTRACED);
+ 		errno = WEXITSTATUS(pstat);
  		if (editpid == -1)
  			pw_error(editor, 1, 1);
  		else if (WIFSTOPPED(pstat))
  			raise(WSTOPSIG(pstat));
! 		else if (WIFEXITED(pstat) && errno == 0)
  			break;
  		else
  			pw_error(editor, 1, 1);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: des 
State-Changed-When: Tue Oct 20 04:34:22 PDT 1998 
State-Changed-Why:  
Slightly different patch applied, thanks. 


Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: des 
Responsible-Changed-When: Tue Oct 20 04:34:22 PDT 1998 
Responsible-Changed-Why:  
I broke it, I fixed it. 
>Unformatted:
