X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/552ea1a28edb2850e2ba206fa27cae61fe6bfc80..7579356b76362e1454ed7a22dff69fbe0cd9ea6b:/usr/src/usr.bin/login/login.c.1 diff --git a/usr/src/usr.bin/login/login.c.1 b/usr/src/usr.bin/login/login.c.1 index 0fea1705c6..920ea40754 100644 --- a/usr/src/usr.bin/login/login.c.1 +++ b/usr/src/usr.bin/login/login.c.1 @@ -22,7 +22,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)login.c.1 5.32 (Berkeley) %G%"; +static char sccsid[] = "@(#)login.c.1 5.34 (Berkeley) %G%"; #endif /* not lint */ /* @@ -51,15 +51,6 @@ static char sccsid[] = "@(#)login.c.1 5.32 (Berkeley) %G%"; #include #include -#ifdef KERBEROS -#include -#include -char inst[INST_SZ]; -char realm[REALM_SZ]; -int kerror = KSUCCESS, notickets = 1; -#define LIFE 96 /* ticket lifetime in 5-min units */ -#endif - #define TTYGRPNAME "tty" /* name of group to own ttys */ #define MOTDFILE "/etc/motd" @@ -87,12 +78,18 @@ struct ltchars ltc = { CSUSP, CDSUSP, CRPRNT, CFLUSH, CWERASE, CLNEXT }; +char *months[] = + { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", + "Sep", "Oct", "Nov", "Dec" }; + main(argc, argv) int argc; char **argv; { extern int errno, optind; extern char *optarg, **environ; + struct timeval tp; + struct tm *ttp; struct group *gr; register int ch; register char *p; @@ -100,7 +97,7 @@ main(argc, argv) int quietlog, passwd_req, ioctlval, timedout(); char *domain, *salt, *envinit[1], *ttyn, *pp; char tbuf[MAXPATHLEN + 2]; - char *ttyname(), *stypeof(), *crypt(), *getpass(); + char *ctime(), *ttyname(), *stypeof(), *crypt(), *getpass(); time_t time(); off_t lseek(); @@ -231,25 +228,6 @@ main(argc, argv) p = crypt(pp, salt); setpriority(PRIO_PROCESS, 0, 0); -#ifdef KERBEROS - - /* - * If we aren't Kerberos-authenticated, try the normal - * pw file for a password. If that's ok, log the user - * in without issueing any tickets. - */ - - if (!get_krbrlm(realm,1)) { - /* get TGT for local realm */ - kerror = get_in_tkt(pwd->pw_name, inst, realm, - "krbtgt", realm, LIFE, pp); - if (kerror == KSUCCESS) { - bzero(pp, strlen(pp)); - notickets = 0; /* user got ticket */ - break; - } - } -#endif (void) bzero(pp, strlen(pp)); if (pwd && !strcmp(p, pwd->pw_passwd)) break; @@ -308,10 +286,29 @@ main(argc, argv) printf("Logging in with home = \"/\".\n"); } -#ifdef KERBEROS - if (notickets) - printf("Warning: no Kerberos tickets issued\n"); -#endif +#define TWOWEEKS (14*24*60*60) + if (pwd->pw_change || pwd->pw_expire) + (void)gettimeofday(&tp, (struct timezone *)NULL); + if (pwd->pw_change) + if (tp.tv_sec >= pwd->pw_change) { + printf("Sorry -- your password has expired.\n"); + sleepexit(1); + } + else if (tp.tv_sec - pwd->pw_change < TWOWEEKS) { + ttp = localtime(&pwd->pw_change); + printf("Warning: your password expires on %s %d, 19%d\n", + months[ttp->tm_mon], ttp->tm_mday, ttp->tm_year); + } + if (pwd->pw_expire) + if (tp.tv_sec >= pwd->pw_expire) { + printf("Sorry -- your account has expired.\n"); + sleepexit(1); + } + else if (tp.tv_sec - pwd->pw_expire < TWOWEEKS) { + ttp = localtime(&pwd->pw_expire); + printf("Warning: your account expires on %s %d, 19%d\n", + months[ttp->tm_mon], ttp->tm_mday, ttp->tm_year); + } /* nothing else left to fail -- really log in */ { @@ -479,6 +476,7 @@ dolastlog(quiet) { struct lastlog ll; int fd; + char *ctime(); if ((fd = open(LASTLOG, O_RDWR, 0)) >= 0) { (void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), L_SET);