Newsgroups: comp.sources.misc From: tony@ajfcal.cuc.ab.ca (Tony Field) Subject: v26i052: login - login replacement for Interactive or AT&T SysV/386, Patch01 Message-ID: <1991Nov24.052047.5755@sparky.imd.sterling.com> X-Md4-Signature: 155eaac10c6f0b25dfff463f8a6449b8 Date: Sun, 24 Nov 1991 05:20:47 GMT Approved: kent@sparky.imd.sterling.com Submitted-by: tony@ajfcal.cuc.ab.ca (Tony Field) Posting-number: Volume 26, Issue 52 Archive-name: login/patch01 Environment: ISC, SysV/386 Patch-To: login: Volume 25, Issue 45-46 Login.c (v2.0) would not properly process shadow file expiry times that were missing or zero in value. This patch corrects the problem. cd to the login source directory and unshar this file. Then apply the patch with: patch -p -N < z tony..... #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'z' <<'END_OF_FILE' X*** login.old.c Wed Nov 13 10:50:00 1991 X--- login.c Wed Nov 13 18:50:05 1991 X*************** X*** 7,14 **** X * tony field tony@ajfcal.cuc.ab.ca * X ****************************************************************************/ X /* X! * $Id: login.c,v 2.0 1991/11/10 23:01:36 ajf Exp $ X * $Log: login.c,v $ X * Revision 2.0 1991/11/10 23:01:36 ajf X * 1. added slip, /etc/nologin, general cleanup and bugfix. X * 2. added /etc/netlogin support (for use with rlogind). X--- 7,17 ---- X * tony field tony@ajfcal.cuc.ab.ca * X ****************************************************************************/ X /* X! * $Id: login.c,v 2.1 1991/11/14 01:48:07 ajf Exp ajf $ X * $Log: login.c,v $ X+ * Revision 2.1 1991/11/14 01:48:07 ajf X+ * 1. fix problem with 0 or blank expiry in /etc/shadow X+ * X * Revision 2.0 1991/11/10 23:01:36 ajf X * 1. added slip, /etc/nologin, general cleanup and bugfix. X * 2. added /etc/netlogin support (for use with rlogind). X*************** X*** 135,141 **** X int dialup_pwd(char *ttyfname, char *pwdfname, char *tty_name, struct passwd *pwd); X void setenv(char *this, char *val); X void check_putenv(char *val); X! char *get_shadow(char *fname, char *user, int allow); X char *search_ttytype(char *tty); X int get_defaults(char *fname, char *tz, char *hz, char **console, long *ulim, int *passreq, int *altshell, char **path, char **supath, long *timeout, int *cmask, int *idleweeks); X void trim(char *s); X--- 138,144 ---- X int dialup_pwd(char *ttyfname, char *pwdfname, char *tty_name, struct passwd *pwd); X void setenv(char *this, char *val); X void check_putenv(char *val); X! char *get_shadow(char *fname, char *user); X char *search_ttytype(char *tty); X int get_defaults(char *fname, char *tz, char *hz, char **console, long *ulim, int *passreq, int *altshell, char **path, char **supath, long *timeout, int *cmask, int *idleweeks); X void trim(char *s); X*************** X*** 374,380 **** X } X X /* valid user. shadow file may or may not exist */ X! if ((strcmp (pwd->pw_passwd, "x") == 0) && (shadow = get_shadow (SHADOW, user_name, 0))) X { salt = shadow; X my_pass = shadow; X } X--- 377,384 ---- X } X X /* valid user. shadow file may or may not exist */ X! if ((strcmp (pwd->pw_passwd, "x") == 0) X! && (shadow = get_shadow (SHADOW, user_name))) X { salt = shadow; X my_pass = shadow; X } X*************** X*** 512,518 **** X X if (strcmp (tty_name, "/dev/tty??") != 0) X { chown (tty_name, pwd->pw_uid, pwd->pw_gid); X! chmod (tty_name, 0620); X } X X if (setgid (pwd->pw_gid)) X--- 516,522 ---- X X if (strcmp (tty_name, "/dev/tty??") != 0) X { chown (tty_name, pwd->pw_uid, pwd->pw_gid); X! chmod (tty_name, 0622); /* some people believe 0620 */ X } X X if (setgid (pwd->pw_gid)) X*************** X*** 532,538 **** X if (system (BINPASSWD)) X slow_exit (1); X } X! else if (shadow_lstchg >= 0) X { if ((time(NULL) / (24L*60*60) - shadow_lstchg) > shadow_max) X { fprintf (stdout, "Your password has expired. Choose a new one.\n"); X if (system (BINPASSWD)) X--- 536,542 ---- X if (system (BINPASSWD)) X slow_exit (1); X } X! else if (shadow_lstchg >= 0 && shadow_max) X { if ((time(NULL) / (24L*60*60) - shadow_lstchg) > shadow_max) X { fprintf (stdout, "Your password has expired. Choose a new one.\n"); X if (system (BINPASSWD)) X*************** X*** 661,667 **** X trim (dtty); X if (strcmp (dtty, tty_name) == 0) X { fclose (fp); X! if (dialpass = get_shadow (DIALUPPWD, shell, 1)) X { if (*dialpass == '\0') /* no password needed */ X return (0); X salt = dialpass; X--- 665,671 ---- X trim (dtty); X if (strcmp (dtty, tty_name) == 0) X { fclose (fp); X! if (dialpass = get_shadow (DIALUPPWD, shell)) X { if (*dialpass == '\0') /* no password needed */ X return (0); X salt = dialpass; X*************** X*** 1008,1022 **** X /**************************************************************************** X * get the encrypted password from /etc/shadow or /etc/d_passwd * X * allow "null" user for /etc/d_passwd general shell password. * X! * Return encrypted password if found, else null. * X ****************************************************************************/ X X /* could have used getspnam(user) except for /etc/d_passwd */ X X! char *get_shadow (fname, user, allow) X char *fname; /* /etc/shadow or /etc/d_passwd */ X char *user; /* user's login name */ X- int allow; /* 0 =must have pwr entry, 1 =success even if no entry */ X { FILE *shadow; X char line[SHORTLINE+1]; X char *pwd, *colon; X--- 1012,1026 ---- X /**************************************************************************** X * get the encrypted password from /etc/shadow or /etc/d_passwd * X * allow "null" user for /etc/d_passwd general shell password. * X! * Return encrypted password if found, \0 if user/passwd not found, or * X! * NULL if shadow file missing. * X ****************************************************************************/ X X /* could have used getspnam(user) except for /etc/d_passwd */ X X! char *get_shadow (fname, user) X char *fname; /* /etc/shadow or /etc/d_passwd */ X char *user; /* user's login name */ X { FILE *shadow; X char line[SHORTLINE+1]; X char *pwd, *colon; X*************** X*** 1023,1028 **** X--- 1027,1033 ---- X static char pass[50]; X X *pass = '\0'; X+ shadow_lstchg = shadow_min = shadow_max = 0; X if (shadow = fopen (fname, "r")) X { while (fgets (line, SHORTLINE, shadow)) X { line[SHORTLINE] = '\0'; X*************** X*** 1032,1040 **** X { *colon++ = '\0'; X if (*line) X { if (strcmp (user, line) == 0) X! { fclose (shadow); X! strcpy (pass, pwd); X! if (allow == 0 && colon) X { shadow_lstchg = atol (colon); X colon = strchr (colon, ':') + 1; X shadow_min = atol (colon); X--- 1037,1044 ---- X { *colon++ = '\0'; X if (*line) X { if (strcmp (user, line) == 0) X! { strcpy (pass, pwd); X! if (colon) X { shadow_lstchg = atol (colon); X colon = strchr (colon, ':') + 1; X shadow_min = atol (colon); X*************** X*** 1041,1059 **** X colon = strchr (colon, ':') + 1; X shadow_max = atol (colon); X } X! return (pass); X } X } X- else if (allow) X- strcpy (pass, pwd); X } X } X } X } X! fclose (shadow); X! if (allow && *pass) X! return (pass); X! return (NULL); X } X X /**************************************************************************** X--- 1045,1060 ---- X colon = strchr (colon, ':') + 1; X shadow_max = atol (colon); X } X! break; X } X } X } X } X } X+ fclose (shadow); X+ return (pass); /* \0 or valid user passwd */ X } X! return (NULL); /* no file */ X } X X /**************************************************************************** X*************** X*** 1219,1225 **** X int rc; X { X #ifdef TCPIP X- fflush (stdout); X fflush (stdout); X sleep (1); /* maybe this should be longer? */ X #endif X--- 1220,1225 ---- END_OF_FILE if test 7204 -ne `wc -c <'z'`; then echo shar: \"'z'\" unpacked with wrong size! fi # end of 'z' fi echo shar: End of shell archive. exit 0 exit 0 # Just in case...