bug in 2.9bsd passwd (and others) -- bad exit status

dave at uwvax.ARPA dave at uwvax.ARPA
Thu Jun 21 02:03:18 AEST 1984


Index: 	/usr/src/cmd/passwd.c 2.9bsd

Description:
	Passwd returns a non-zero exit status even when it has set
	the password correctly.  This causes any programs which
	look at the status to see if the password was set to fail.
Repeat-By:
	< use csh >
	% passwd anyuser
	< set the password correctly >
	% echo $status
	< the value will be non-zero >
Fix:
	This is not necessarily the best fix, but is short and works!

*** passwd.c.orig	Fri Jun  8 12:56:45 1984
--- passwd.c	Tue Jun 19 09:42:57 1984
***************
*** 37,42
  	int pwlen;
  	FILE *tf;
  	char *uname;
  
  	insist = 0;
  	if(argc < 2) {

--- 37,43 -----
  	int pwlen;
  	FILE *tf;
  	char *uname;
+ 	int exitstat = 1;
  
  	insist = 0;
  	if(argc < 2) {
***************
*** 180,185
  		goto out;
  	}
  	while((u=read(fi,buf,sizeof(buf))) > 0) write(fo,buf,u);
  
  out:
  	unlink(temp);

--- 181,187 -----
  		goto out;
  	}
  	while((u=read(fi,buf,sizeof(buf))) > 0) write(fo,buf,u);
+ 	exitstat = 0;		/* no errors! */
  
  out:
  	unlink(temp);
***************
*** 185,189
  	unlink(temp);
  
  bex:
! 	exit(1);
  }

--- 187,191 -----
  	unlink(temp);
  
  bex:
! 	exit(exitstat);
  }
-- 
Dave Cohrs @ wisconsin
...!{allegra,heurikon,ihnp4,seismo,sfwin,ucbvax,uwm-evax}!uwvax!dave
dave at wisc-rsch.arpa



More information about the Comp.unix.wizards mailing list