date and time created 90/06/25 13:56:22 by bostic
[unix-history] / usr / src / usr.bin / login / login.c.1
index 0fea170..920ea40 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #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 */
 
 /*
 #endif /* not lint */
 
 /*
@@ -51,15 +51,6 @@ static char sccsid[] = "@(#)login.c.1        5.32 (Berkeley) %G%";
 #include <stdio.h>
 #include <strings.h>
 
 #include <stdio.h>
 #include <strings.h>
 
-#ifdef KERBEROS
-#include <kerberos/krb.h>
-#include <sys/termios.h>
-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"
 #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
 };
 
        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;
 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;
        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];
        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();
 
        time_t time();
        off_t lseek();
 
@@ -231,25 +228,6 @@ main(argc, argv)
                p = crypt(pp, salt);
                setpriority(PRIO_PROCESS, 0, 0);
 
                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;
                (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");
        }
 
                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 */
        {
 
        /* nothing else left to fail -- really log in */
        {
@@ -479,6 +476,7 @@ dolastlog(quiet)
 {
        struct lastlog ll;
        int fd;
 {
        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);
 
        if ((fd = open(LASTLOG, O_RDWR, 0)) >= 0) {
                (void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), L_SET);