[comp.sources.bugs] patch 4 for shadow login package

jfh@rpp386.Dallas.TX.US (John F. Haugh II) (02/22/89)

OK - This collection of patches repairs problems with undefined options
causing syntax errors and so on.  I took a very pathological approach
and turned off almost all of the #Define's in config.h.  Some of them
should not be turned off ever.  But I went ahead and added defaults
inside of the modules if a required macro is undefined.  One other fix
involved the base-64 character routines being needed for base-64
conversions when password aging was turned off.  I moved the code
outside of the #Ifdef block.

It also fixes a major stupid I committed.  Patch3 converted the gets()
call in password.c to a fgets() call.  I royally screwed up the
arguments.  I sent that patch out and cancelled it soon thereafter.
Now that I have the fix for that bug, you should be seeing Patch3
show up again.

Also, I have heard of more work being done to increase the portability
of this thing.  Peter De Silva is working on making this run on 7th Edition
UNIX.  I will be archiving up a current version on this system.  The
filenames will be /usr/archive/login/login.shar.{1,2,3}.Z.  The phone
number is in the .signature, and the login is 'uucp' with no password.
An archive index is in /usr/archive/index incase you are interested ...

- John.
--
*** age.c
--- new/age.c
**************
*** 3,8
  #include <pwd.h>
  #include "config.h"
  
  #ifndef	PASSWD
  extern	char	*newenvp[];
  #endif
--- 3,12 -----
  #include <pwd.h>
  #include "config.h"
  
+ #ifndef	lint
+ static	char	_sccsid[] = "@(#)age.c	1.2	08:41:03	2/22/89";
+ #endif
+ 
  #ifndef	PASSWD
  extern	char	*newenvp[];
  #endif
**************
*** 9,14
  
  time_t	time ();
  
  #ifdef	AGING
  #ifdef	PASSWD
  char	*l64a (l)
--- 13,39 -----
  
  time_t	time ();
  
+ int	c64i (c)
+ char	c;
+ {
+ 	if (c == '.')
+ 		return (0);
+ 
+ 	if (c == '/')
+ 		return (1);
+ 
+ 	if (c >= '0' && c <= '9')
+ 		return (c - '0' + 2);
+ 
+ 	if (c >= 'A' && c <= 'Z')
+ 		return (c - 'A' + 12);
+ 
+ 	if (c >= 'a' && c <= 'z')
+ 		return (c - 'a' + 38);
+ 	else
+ 		return (-1);
+ }
+ 
  #ifdef	AGING
  #ifdef	PASSWD
  char	*l64a (l)
**************
*** 52,78
  		return ('a' - 38 + i);
  
  	return ('\0');
- }
- 
- int	c64i (c)
- char	c;
- {
- 	if (c == '.')
- 		return (0);
- 
- 	if (c == '/')
- 		return (1);
- 
- 	if (c >= '0' && c <= '9')
- 		return (c - '0' + 2);
- 
- 	if (c >= 'A' && c <= 'Z')
- 		return (c - 'A' + 12);
- 
- 	if (c >= 'a' && c <= 'z')
- 		return (c - 'a' + 38);
- 	else
- 		return (-1);
  }
  
  long	a64l (s)
--- 77,82 -----
  		return ('a' - 38 + i);
  
  	return ('\0');
  }
  
  long	a64l (s)
*** password.c
--- new/password.c
**************
*** 13,19
   */
  
  #ifndef	lint
! static	char	_sccsid[] = "@(#)password.c	1.2	19:00:10	2/21/89";
  #endif
  
  int	password (prompt, pass)
--- 13,19 -----
   */
  
  #ifndef	lint
! static	char	_sccsid[] = "@(#)password.c	1.3	08:41:05	2/22/89";
  #endif
  
  int	password (prompt, pass)
**************
*** 41,47
  	ioctl (fileno (fp), TCSETAF, &termio);
  
  	fputs (prompt, stdout);
! 	eof = fgets (buf, s, BUFSIZ) == (char *) 0 || feof (fp) || ferror (fp);
  	putchar ('\n');
  
  	ioctl (fileno (fp), TCSETAF, &save);
--- 41,47 -----
  	ioctl (fileno (fp), TCSETAF, &termio);
  
  	fputs (prompt, stdout);
! 	eof = fgets (buf, BUFSIZ, fp) == (char *) 0 || feof (fp) || ferror (fp);
  	putchar ('\n');
  
  	ioctl (fileno (fp), TCSETAF, &save);
*** pmain.c
--- new/pmain.c
**************
*** 9,16
  #include "lastlog.h"
  #include "shadow.h"
  
! #ifndef	lint
! static	char	_sccsid[] = "@(#)pmain.c	1.2	13:59:32	2/5/89";
  #endif
  
  char	name[BUFSIZ];
--- 9,16 -----
  #include "lastlog.h"
  #include "shadow.h"
  
! #ifndef	PASSLENGTH
! #define	PASSLENGTH	5
  #endif
  
  #ifndef	lint
**************
*** 13,18
  static	char	_sccsid[] = "@(#)pmain.c	1.2	13:59:32	2/5/89";
  #endif
  
  char	name[BUFSIZ];
  char	orig[BUFSIZ];
  char	pass[BUFSIZ];
--- 13,22 -----
  #define	PASSLENGTH	5
  #endif
  
+ #ifndef	lint
+ static	char	_sccsid[] = "@(#)pmain.c	1.3	08:41:07	2/22/89";
+ #endif
+ 
  char	name[BUFSIZ];
  char	orig[BUFSIZ];
  char	pass[BUFSIZ];
**************
*** 326,332
  		(void) fprintf (npwd, "%s:", pwent.pw_passwd);
  
  	(void) fprintf (npwd, "%d:%d:%s:%s:%s",
! 		pwent.pw_uid, pwent.pw_gid, pwent.pw_gecos, pwent.pw_dir
  		pwent.pw_shell ? pwent.pw_shell:"");
  
  	while (fgets (buf, BUFSIZ, pwd) != (char *) 0)
--- 330,336 -----
  		(void) fprintf (npwd, "%s:", pwent.pw_passwd);
  
  	(void) fprintf (npwd, "%d:%d:%s:%s:%s",
! 		pwent.pw_uid, pwent.pw_gid, pwent.pw_gecos, pwent.pw_dir,
  		pwent.pw_shell ? pwent.pw_shell:"");
  
  	while (fgets (buf, BUFSIZ, pwd) != (char *) 0)
*** setup.c
--- new/setup.c
**************
*** 5,11
  #include "config.h"
  
  #ifndef	lint
! static	char	_sccsid[] = "@(#)setup.c	1.2	13:59:35	2/5/89";
  #endif
  
  extern	char	home[];
--- 5,11 -----
  #include "config.h"
  
  #ifndef	lint
! static	char	_sccsid[] = "@(#)setup.c	1.3	08:41:10	2/22/89";
  #endif
  
  extern	char	home[];
**************
*** 12,17
  extern	char	prog[];
  extern	char	name[];
  extern	char	mail[];
  
  #ifndef	SU
  extern	struct	utmp	utent;
--- 12,33 -----
  extern	char	prog[];
  extern	char	name[];
  extern	char	mail[];
+ 
+ #ifndef	PATH
+ #define	PATH	":/bin:/usr/bin"
+ #endif
+ 
+ #ifndef	SUPATH
+ #define	SUPATH	":/bin:/usr/bin:/etc"
+ #endif
+ 
+ #ifndef	MAILDIR
+ #define	MAILDIR	"/usr/spool/mail"
+ #endif
+ 
+ #ifndef	TTYPERM
+ #define	TTYPERM	0622
+ #endif
  
  #ifndef	SU
  extern	struct	utmp	utent;
*** smain.c
--- new/smain.c
**************
*** 7,13
  #include "lastlog.h"
  
  #ifndef	lint
! static	char	_sccsid[] = "@(#)smain.c	1.3	18:58:30	2/18/89";
  #endif
  
  #ifndef	MAXENV
--- 7,13 -----
  #include "lastlog.h"
  
  #ifndef	lint
! static	char	_sccsid[] = "@(#)smain.c	1.4	08:41:11	2/22/89";
  #endif
  
  #ifndef	MAXENV
**************
*** 12,17
  
  #ifndef	MAXENV
  #define	MAXENV	64
  #endif
  
  char	name[BUFSIZ];
--- 12,25 -----
  
  #ifndef	MAXENV
  #define	MAXENV	64
+ #endif
+ 
+ #ifndef	PATH
+ #define	PATH	":/bin:/usr/bin"
+ #endif
+ 
+ #ifndef	SUPATH
+ #define	SUPATH	":/bin:/usr/bin:/etc"
  #endif
  
  char	name[BUFSIZ];
-- 
John F. Haugh II                        +--Quote of the Week:------------------
VoiceNet: (214) 250-3311   Data: -6272  | "If I do not want others to quote me,
InterNet: jfh@rpp386.Dallas.TX.US       |  I do not speak."  -- Phil Wayne
UucpNet : <backbone>!killer!rpp386!jfh  +--------------------------------------