[comp.sources.bugs] Patch #1 to shadow login package

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

This is a re-posting of patch #1 for the System V shadow login
clone.  Patch #2 was recently posted in this newsgroup and a
number of you mentioned that you did not see #1.  Sorry for the
confusion.

Feed this to your favorite version of patch from within the login
source directory.
--
*** orig/Makefile
--- Makefile
**************
*** 1,3
  SHELL = /bin/sh
  
  # Flags for SCO Xenix/386
--- 1,8 -----
+ #
+ #	@(#)Makefile	1.2 - System V shadow password system
+ #
+ #	@(#)Makefile	1.2	13:59:26	2/5/89
+ #
  SHELL = /bin/sh
  
  # Flags for SCO Xenix/386
**************
*** 15,21
  	pwent.o utmp.o sub.o mail.o motd.o log.o shadow.o dialup.o dialchk.o
  
  LSRCS = lmain.c login.c env.c password.c entry.c valid.c setup.c shell.c age.c \
! 	pwent.c utmp.c sub.c mail.c motd.c log.c shadow.c dialup.o dialchk.o
  
  SOBJS = smain.o env.o password.o entry.o valid.o susetup.o sushell.o \
  	pwent.o susub.o mail.o motd.o sulog.o shadow.o age.o
--- 20,26 -----
  	pwent.o utmp.o sub.o mail.o motd.o log.o shadow.o dialup.o dialchk.o
  
  LSRCS = lmain.c login.c env.c password.c entry.c valid.c setup.c shell.c age.c \
! 	pwent.c utmp.c sub.c mail.c motd.c log.c shadow.c dialup.c dialchk.c
  
  SOBJS = smain.o env.o password.o entry.o valid.o susetup.o sushell.o \
  	pwent.o susub.o mail.o motd.o sulog.o shadow.o age.o
**************
*** 42,48
  	shadow.c shell.c valid.c
  
  FILES1 = log.c mail.c shadow.h sulog.c Makefile entry.c obscure.c \
! 	setup.c sub.c config.h shadow.info pmain.c sulogin.c dialup.h
  
  FILES2 = lastlog.h login.c motd.c password.c shell.c utmp.c age.c env.c \
  	pwent.c shadow.c valid.c lmain.c smain.c pwconv.c dialup.c dialchk.c \
--- 47,53 -----
  	shadow.c shell.c valid.c
  
  FILES1 = log.c mail.c shadow.h sulog.c Makefile entry.c obscure.c \
! 	setup.c sub.c config.h pmain.c sulogin.c dialup.h
  
  FILES2 = lastlog.h login.c motd.c password.c shell.c utmp.c age.c env.c \
  	pwent.c shadow.c valid.c lmain.c smain.c pwconv.c dialup.c dialchk.c \
**************
*** 113,118
  	rm pwage.c
  
  lmain.o: config.h lastlog.h
  
  setup.o: config.h
  
--- 118,125 -----
  	rm pwage.c
  
  lmain.o: config.h lastlog.h
+ 
+ smain.o: config.h lastlog.h
  
  setup.o: config.h
  
*** orig/log.c
--- log.c
**************
*** 6,11
  #include <string.h>
  #include "config.h"
  
  extern	struct	utmp	utent;
  extern	struct	passwd	pwent;
  extern	struct	lastlog	lastlog;
--- 6,19 -----
  #include <string.h>
  #include "config.h"
  
+ #ifndef	lint
+ static	char	_sccsid[] = "@(#)log.c	1.2	13:59:29	2/5/89";
+ #endif
+ 
+ #ifdef	LASTLOG
+ 
+ #include "lastlog.h"
+ 
  extern	struct	utmp	utent;
  extern	struct	passwd	pwent;
  extern	struct	lastlog	lastlog;
**************
*** 13,22
  
  long	lseek ();
  time_t	time ();
- 
- #ifdef	LASTLOG
- 
- #include "lastlog.h"
  
  void	log ()
  {
--- 21,26 -----
  
  long	lseek ();
  time_t	time ();
  
  void	log ()
  {
*** orig/obscure.c
--- obscure.c
**************
*** 1,6
  #include <ctype.h>
  #include "config.h"
  
  /*
   * Obscure - see if password is obscure enough.
   *
--- 1,10 -----
  #include <ctype.h>
  #include "config.h"
  
+ #ifndef	lint
+ static	char	_sccsid[] = "@(#)obscure.c	1.2	13:59:30	2/5/89";
+ #endif
+ 
  /*
   * Obscure - see if password is obscure enough.
   *
**************
*** 11,16
  
  extern	char	pass[];			/* the new password */
  extern	char	orig[];			/* the original password */
  char	mono[32];			/* a monocase version of pass */
  
  int	obscure ()
--- 15,21 -----
  
  extern	char	pass[];			/* the new password */
  extern	char	orig[];			/* the original password */
+ #ifdef	OBSCURE
  char	mono[32];			/* a monocase version of pass */
  #endif
  int	obscure ()
**************
*** 12,18
  extern	char	pass[];			/* the new password */
  extern	char	orig[];			/* the original password */
  char	mono[32];			/* a monocase version of pass */
! 
  int	obscure ()
  {
  	int	i;
--- 17,23 -----
  extern	char	orig[];			/* the original password */
  #ifdef	OBSCURE
  char	mono[32];			/* a monocase version of pass */
! #endif
  int	obscure ()
  {
  #ifdef	OBSCURE
**************
*** 15,20
  
  int	obscure ()
  {
  	int	i;
  
  	if (orig[0] == '\0')
--- 20,26 -----
  #endif
  int	obscure ()
  {
+ #ifdef	OBSCURE
  	int	i;
  #endif
  	if (orig[0] == '\0')
**************
*** 16,22
  int	obscure ()
  {
  	int	i;
! 
  	if (orig[0] == '\0')
  		return (1);
  
--- 22,28 -----
  {
  #ifdef	OBSCURE
  	int	i;
! #endif
  	if (orig[0] == '\0')
  		return (1);
  
**************
*** 20,26
  	if (orig[0] == '\0')
  		return (1);
  
! 	if (strlen (pass) < 6) {	/* too short */
  		printf ("Too short.  ");
  		return (0);
  	}
--- 26,32 -----
  	if (orig[0] == '\0')
  		return (1);
  
! 	if (strlen (pass) < PASSLENGTH) { /* too short */
  		printf ("Too short.  ");
  		return (0);
  	}
*** orig/pmain.c
--- pmain.c
**************
*** 9,14
  #include "lastlog.h"
  #include "shadow.h"
  
  char	name[BUFSIZ];
  char	orig[BUFSIZ];
  char	pass[BUFSIZ];
--- 9,18 -----
  #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];
  char	orig[BUFSIZ];
  char	pass[BUFSIZ];
**************
*** 77,82
  	printf ("Changing password for %s\n", name);
  
  	amroot = getuid () == 0;	/* currently am super user */
  	if (! amroot)
  		force = 0;
  
--- 81,87 -----
  	printf ("Changing password for %s\n", name);
  
  	amroot = getuid () == 0;	/* currently am super user */
+ #ifdef	OBSCURE
  	if (! amroot)
  		force = 0;
  #endif
**************
*** 79,85
  	amroot = getuid () == 0;	/* currently am super user */
  	if (! amroot)
  		force = 0;
! 
  	if (! amroot && strcmp (name, pw->pw_name) != 0)
  		goto failure;
  
--- 84,90 -----
  #ifdef	OBSCURE
  	if (! amroot)
  		force = 0;
! #endif
  	if (! amroot && strcmp (name, pw->pw_name) != 0)
  		goto failure;
  
**************
*** 139,146
  	if (! password ("New Password:", pass))
  		exit (1);
  
! 	if (!force && ! obscure ()) {
! #ifdef	OBSCURE
  		puts ("Password not changed.");
  		exit (1);
  #else
--- 144,151 -----
  	if (! password ("New Password:", pass))
  		exit (1);
  
! #ifndef	OBSCURE
! 	if (! obscure ()) {
  		puts ("Password not changed.");
  		exit (1);
  	}
**************
*** 143,148
  #ifdef	OBSCURE
  		puts ("Password not changed.");
  		exit (1);
  #else
  		if (retries-- > 0) {
  			puts ("Please try again.");
--- 148,154 -----
  	if (! obscure ()) {
  		puts ("Password not changed.");
  		exit (1);
+ 	}
  #else
  	if (! force && ! obscure ()) {
  		if (retries-- > 0) {
**************
*** 144,149
  		puts ("Password not changed.");
  		exit (1);
  #else
  		if (retries-- > 0) {
  			puts ("Please try again.");
  			goto retry;
--- 150,156 -----
  		exit (1);
  	}
  #else
+ 	if (! force && ! obscure ()) {
  		if (retries-- > 0) {
  			puts ("Please try again.");
  			goto retry;
**************
*** 149,155
  			goto retry;
  		} else
  			goto toomany;
- #endif
  	}
  	if (! password ("Re-enter new password:", pass2))
  		exit (1);
--- 156,161 -----
  			goto retry;
  		} else
  			goto toomany;
  	}
  #endif
  	if (! password ("Re-enter new password:", pass2))
**************
*** 151,156
  			goto toomany;
  #endif
  	}
  	if (! password ("Re-enter new password:", pass2))
  		exit (1);
  
--- 157,163 -----
  		} else
  			goto toomany;
  	}
+ #endif
  	if (! password ("Re-enter new password:", pass2))
  		exit (1);
  
*** orig/setup.c
--- setup.c
**************
*** 4,9
  #include <string.h>
  #include "config.h"
  
  extern	char	home[];
  extern	char	prog[];
  extern	char	name[];
--- 4,13 -----
  #include <string.h>
  #include "config.h"
  
+ #ifndef	lint
+ static	char	_sccsid[] = "@(#)setup.c	1.2	13:59:35	2/5/89";
+ #endif
+ 
  extern	char	home[];
  extern	char	prog[];
  extern	char	name[];
**************
*** 24,30
  struct	passwd	*info;
  {
  	extern	int	errno;
- 	char	logname[30];
  #ifndef	SU
  	char	tty[30];
  #endif
--- 28,33 -----
  struct	passwd	*info;
  {
  	extern	int	errno;
  #ifndef	SU
  	char	logname[30];
  	char	tty[30];
**************
*** 26,31
  	extern	int	errno;
  	char	logname[30];
  #ifndef	SU
  	char	tty[30];
  #endif
  	char	*cp;
--- 29,35 -----
  {
  	extern	int	errno;
  #ifndef	SU
+ 	char	logname[30];
  	char	tty[30];
  #endif
  	char	*cp;
**************
*** 54,61
  
  			continue;
  		}
! 		if (strncmp (cp, "ulimit=", 6) == 0) {
! 			l = strtol (cp + 6, (char **) 0, 10);
  			(void) ulimit (2, l);
  
  			continue;
--- 58,65 -----
  
  			continue;
  		}
! 		if (strncmp (cp, "ulimit=", 7) == 0) {
! 			l = strtol (cp + 7, (char **) 0, 10);
  			(void) ulimit (2, l);
  
  			continue;
**************
*** 60,67
  
  			continue;
  		}
! 		if (strncmp (cp, "umask=", 5) == 0) {
! 			i = strtol (cp + 5, (char **) 0, 8) & 0777;
  			(void) umask (i);
  
  			continue;
--- 64,71 -----
  
  			continue;
  		}
! 		if (strncmp (cp, "umask=", 6) == 0) {
! 			i = strtol (cp + 6, (char **) 0, 8) & 0777;
  			(void) umask (i);
  
  			continue;
*** orig/smain.c
--- smain.c
**************
*** 6,11
  #include "config.h"
  #include "lastlog.h"
  
  #ifndef	MAXENV
  #define	MAXENV	64
  #endif
--- 6,15 -----
  #include "config.h"
  #include "lastlog.h"
  
+ #ifndef	lint
+ static	char	_sccsid[] = "@(#)smain.c	1.2	13:59:37	2/5/89";
+ #endif
+ 
  #ifndef	MAXENV
  #define	MAXENV	64
  #endif
-- 
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  +--------------------------------------