[comp.bugs.4bsd] 'Bug' and fix/improvement to vipw

scs@itivax.iti.org (Steve Simmons) (09/25/89)

We recently had some odd performance on a BSD4.3 VAX.  We've fixed
the performance, but don't think we fixed the bug.  :-(.  Along the
way we improved some error messages in vipw, and include them here.

We wanted to change the 'root' home from / to /etc/root.  When doing
this with vipw, we got messages about having corrupted the passwd file.
It turns out that our passwd file was corrupted all along, and vipw
was not noticing!

Circumstances: one operator was changing /etc/passwd with another
editor, then not running mkpasswd.  She introduced a format error in
the file.  Running vipw to add, delete or disable users gave no complaint.
But modifying the root entry did.

Once we figured out what was going on, we fixed /etc/passwd, then ran
mkpasswd to force the updates.  This had the bizarre side-effect of
changing the root password!  If anyone can tell me what we did wrong,
I'd sure appreciate it.

Along the way, we improved the vipw error message so it tells you just
what entry is corrupted.  The patch (to tahoe vipw) follows.

*** vipw.c	Mon Sep 25 12:09:02 1989
--- vipw.c.orig	Mon Sep 25 12:07:29 1989
***************
*** 193,199 ****
  				else if (!strcmp(cp, sh))
  					break;
  		if (token(CHN)) {			/* too many fields */
! bad:			fprintf(stderr, "vipw: too many fields for user %s, %s unchanged.\n", buf, passwd);
  			return(0);
  		}
  	}
--- 193,199 ----
  				else if (!strcmp(cp, sh))
  					break;
  		if (token(CHN)) {			/* too many fields */
! bad:			fprintf(stderr, "vipw: corrupted entry; %s unchanged.\n", passwd);
  			return(0);
  		}
  	}