use tzfile.h #defines; tests for expiration were reversed
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sat, 3 Jun 1989 00:02:24 +0000 (16:02 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sat, 3 Jun 1989 00:02:24 +0000 (16:02 -0800)
SCCS-vsn: usr.bin/login/login.c 5.42

usr/src/usr.bin/login/login.c

index c1ac218..fe01e57 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)login.c    5.41 (Berkeley) %G%";
+static char sccsid[] = "@(#)login.c    5.42 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -364,7 +364,6 @@ main(argc, argv)
                            months[ttp->tm_mon], ttp->tm_mday, ttp->tm_year);
                }
 
                            months[ttp->tm_mon], ttp->tm_mday, ttp->tm_year);
                }
 
-#define        TWOWEEKS        (14*24*60*60)
        if (pwd->pw_change || pwd->pw_expire)
                (void)gettimeofday(&tp, (struct timezone *)NULL);
        if (pwd->pw_change)
        if (pwd->pw_change || pwd->pw_expire)
                (void)gettimeofday(&tp, (struct timezone *)NULL);
        if (pwd->pw_change)
@@ -372,20 +371,24 @@ main(argc, argv)
                        (void)printf("Sorry -- your password has expired.\n");
                        sleepexit(1);
                }
                        (void)printf("Sorry -- your password has expired.\n");
                        sleepexit(1);
                }
-               else if (tp.tv_sec - pwd->pw_change < TWOWEEKS && !quietlog) {
+               else if (pwd->pw_change - tp.tv_sec <
+                   2 * DAYSPERWEEK * SECSPERDAY && !quietlog) {
                        ttp = localtime(&pwd->pw_change);
                        (void)printf("Warning: your password expires on %s %d, %d\n",
                        ttp = localtime(&pwd->pw_change);
                        (void)printf("Warning: your password expires on %s %d, %d\n",
-                           months[ttp->tm_mon], ttp->tm_mday, TM_YEAR_BASE + ttp->tm_year);
+                           months[ttp->tm_mon], ttp->tm_mday,
+                           TM_YEAR_BASE + ttp->tm_year);
                }
        if (pwd->pw_expire)
                if (tp.tv_sec >= pwd->pw_expire) {
                        (void)printf("Sorry -- your account has expired.\n");
                        sleepexit(1);
                }
                }
        if (pwd->pw_expire)
                if (tp.tv_sec >= pwd->pw_expire) {
                        (void)printf("Sorry -- your account has expired.\n");
                        sleepexit(1);
                }
-               else if (tp.tv_sec - pwd->pw_expire < TWOWEEKS && !quietlog) {
+               else if (pwd->pw_expire - tp.tv_sec <
+                   2 * DAYSPERWEEK * SECSPERDAY && !quietlog) {
                        ttp = localtime(&pwd->pw_expire);
                        (void)printf("Warning: your account expires on %s %d, %d\n",
                        ttp = localtime(&pwd->pw_expire);
                        (void)printf("Warning: your account expires on %s %d, %d\n",
-                           months[ttp->tm_mon], ttp->tm_mday, TM_YEAR_BASE + ttp->tm_year);
+                           months[ttp->tm_mon], ttp->tm_mday,
+                           TM_YEAR_BASE + ttp->tm_year);
                }
 
        /* nothing else left to fail -- really log in */
                }
 
        /* nothing else left to fail -- really log in */