[net.sources.bugs] 5 bug fixes for the nu

glenn@nsc.UUCP (Glenn Skinner) (12/02/84)

I've just installed the new user program (nu) that Brian Reid distributed
recently.  While doing so, I found and fixed several bugs.  They're all
fairly minor.  What follows is a set of bug fixes for each of the five
bugs I found.

		-- Glenn Skinner
		National Semiconductor, Microcomputer Systems Division
		(408) 733-2600 x 335

----------------------------------------------------------------
Subject: nu distribution format problem

Description:
	Nu was distributed in shar format.  The distributed material
	contained characters that the shell interprets as metacharacters.
	These characters were not protected from expansion, since the
	delimiters for input redirection weren't quoted.
Repeat-By:
	Extract the archive and observe that `` pairs have disappeared
	from nu.8 and that all of nu.[1234].sh have been corrupted.
Fix:
	Before extracting the archive, edit it to replace all occurrences
	of
		cat > ... << BeginBombingInFiveMinutes
	with
		cat > ... << 'BeginBombingInFiveMinutes'

----------------------------------------------------------------
Subject: nu.8 describes a nonexistent option (-d)
Index:	etc/nu/nu.8

Description:
	Nu's man page describes a "-d" option that doesn't exist.
Repeat-By:
	Try running "nu -d".  You'll get an error exit.
Fix:
	Remove the relevant SYNOPSIS line and paragraph describing the
	"-d" option from nu.8.  (This one's too bad.  The option as
	described is one I'd very much like to have.)

----------------------------------------------------------------
Subject: nu's Makefile's install rule doesn't set modes correctly
Index:	etc/nu/Makefile

Description:
	When running "make install", the shell files nu[1234].sh aren't
	made executable.  This causes nu to fail when it tries to execute
	them.
Repeat-By:
	Install nu using the distributed Makefile, then run "nu -a".
	It will update the password file, then fail when it tries to
	execute nu1.sh to create the new user's home directory.
Fix:
	Replace the distributed Makefile with this one.  (The diffs are
	as long as the Makefile itself.)  This Makefile assumes you're
	running the 4.2bsd version of install.

SHELLFILES	= nu1.sh nu2.sh nu3.sh nu4.sh

nu:	nu.c
	cc -O -o nu nu.c -ldbm

install: nu
	-mkdir /etc/nulib
	install -s nu /etc
	for i in ${SHELLFILES}; do install -c -m 555 $$i /etc/nulib; done
	install -c -m 444 nu.cf.debug /etc/nulib
	install -c -m 444 nu.cf.real  /etc/nulib
	-ln -s /etc/nulib/nu.cf.real /etc/nu.cf
	install -c -m 444 nu.8 /usr/man/man8
	@echo Make sure you edit /etc/nulib/nu.cf.\* for your site

----------------------------------------------------------------
Subject: nu locks the password file, but doesn't unlock it on error exit
Index:	etc/nu/nu.c

Description:
	When it starts up, nu locks the password file, obeying the
	conventions used by vipw, passwd, etc.  If invoked incorrectly,
	it exits without removing the lock.
Repeat-By:
	Run the following commands:
		nu -x
		nu -x
	The second time around, nu will complain that the password file
	is locked and will then exit.
Fix:
	Apply the change indicated by the following context diff to
	nu.c.  Unfortunately, line numbers won't correspond to those
	in the original -- we add our own SCCS headers.

------- nu.c -------
*** /tmp/d20728	Sat Dec  1 13:33:30 1984
--- nu.c	Sat Dec  1 13:04:13 1984
***************
*** 1447,1451
  	    "usage:	nu -a			add new accounts\n");
      fprintf (stderr, "	nu -k user1 user2 ...	kill old accounts\n");
      fprintf (stderr, "	nu -m			modify existing accounts\n");
      exit (ERROR);
  }

--- 1447,1452 -----
  	    "usage:	nu -a			add new accounts\n");
      fprintf (stderr, "	nu -k user1 user2 ...	kill old accounts\n");
      fprintf (stderr, "	nu -m			modify existing accounts\n");
+     unlink (StrV ("Linkfile"));
      exit (ERROR);
  }

----------------------------------------------------------------
Subject: nu doesn't respect the WantMHsetup configuration variable
Index:	etc/nu/nu.c

Description:
	When adding a new user ("nu -a"), nu will ask whether you
	want to set up a MH mailbox regardless of the value of the
	WantMHsetup configuration variable.
Repeat-By:
	Edit /etc/nulib/nu.cf.real to have the WantMHsetup line look like:
		WantMHsetup=0		; ask about setting up MH mailbox
	Then run "nu -a" and observe that you're asked about setting up a
	MH mailbox.
Fix:
	Apply the change indicated by the following context diff to
	nu.c.  Unfortunately, line numbers won't correspond to those
	in the original -- we add our own SCCS headers.

------- nu.c -------
*** /tmp/d20738	Sat Dec  1 13:42:18 1984
--- nu.c	Sat Dec  1 13:41:54 1984
***************
*** 852,860
  	GetLoginSH (new.cpw_shell);
  
  	if (noclobber == 0) {
! 	    printf ("Do you want an initialized ~/Mail for MH? (y or n) [y] ");
! 	    if (YesNo ('y'))
! 		whichmail = 'm';
  	    else
  		whichmail = 'u';
  	}

--- 852,864 -----
  	GetLoginSH (new.cpw_shell);
  
  	if (noclobber == 0) {
! 	    if (IntV ("WantMHsetup")) {
! 		printf ("Do you want an initialized ~/Mail for MH? (y or n) [y] ");
! 		if (YesNo ('y'))
! 		    whichmail = 'm';
! 		else
! 		    whichmail = 'u';
! 	    }
  	    else
  		whichmail = 'u';
  	}

----------------------------------------------------------------
This concludes the nu bug fixes.

glenn@nsc.UUCP (Glenn Skinner) (12/03/84)

How embarrassing!  After posting some bug fixes to nu, I found a bug in one
of my fixes.  The bug occurs in the fix to the password locking problem.  My
fix as posted works except in the case when nu is invoked with no arguments.
In this case, it tries to unlock the password file even thoug it hasn't been
locked yet (harmless, but annoying).

A fix for the fix follows.  Apply it _after_ applying the original fix.

		-- Glenn Skinner
		National Semiconductor, Microcomputer Systems Division
		(408) 733-2600 x 335

----------------------------------------------------------------

------- nu.c -------
*** /tmp/d07963	Mon Dec  3 10:04:53 1984
--- nu.c	Mon Dec  3 09:51:20 1984
***************
*** 1386,1392
      struct passwd  *pwd;
  
      if (argc == 1)
! 	goto uusage;
      incritsect = FALSE;
      signal (SIGINT, Catch);		/* catch ^C's */
      gethostname (This_host, 100);

--- 1386,1392 -----
      struct passwd  *pwd;
  
      if (argc == 1)
! 	goto usage;
      incritsect = FALSE;
      signal (SIGINT, Catch);		/* catch ^C's */
      gethostname (This_host, 100);
***************
*** 1442,1448
      }
      unlink (StrV ("Linkfile"));
      exit (OK);
uusage: 
      fprintf (stderr,
  	    "usage:	nu -a			add new accounts\n");
      fprintf (stderr, "	nu -k user1 user2 ...	kill old accounts\n");

--- 1442,1450 -----
      }
      unlink (StrV ("Linkfile"));
      exit (OK);
uusage:
+     unlink (StrV ("Linkfile"));
+ usage:
      fprintf (stderr,
  	    "usage:	nu -a			add new accounts\n");
      fprintf (stderr, "	nu -k user1 user2 ...	kill old accounts\n");
***************
*** 1447,1452
  	    "usage:	nu -a			add new accounts\n");
      fprintf (stderr, "	nu -k user1 user2 ...	kill old accounts\n");
      fprintf (stderr, "	nu -m			modify existing accounts\n");
-     unlink (StrV ("Linkfile"));
      exit (ERROR);
  }

--- 1449,1453 -----
  	    "usage:	nu -a			add new accounts\n");
      fprintf (stderr, "	nu -k user1 user2 ...	kill old accounts\n");
      fprintf (stderr, "	nu -m			modify existing accounts\n");
      exit (ERROR);
  }

reid@Glacier.ARPA (12/05/84)

You claimed in your previous message that "nu -d" does not exist or work. It
works just fine in the version of nu that I sent out, and I just tried it
again a minute or two ago to make sure it really did work. Some damage must
have happened to the archive file in transmission. For this reason I have
not installed any of your bug fixes in the ``master'' copy of nu, though
when I get a chance to do it by hand, I will.