- lseek(f, (long)pwd->pw_uid * sizeof (struct lastlog), 0);
- time(&ll.ll_time);
- SCPYN(ll.ll_line, tty);
- SCPYN(ll.ll_host, utmp.ut_host);
- write(f, (char *) &ll, sizeof ll);
- close(f);
+ 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);
+ }
+
+ if (pwd->pw_change || pwd->pw_expire)
+ (void)gettimeofday(&tp, (struct timezone *)NULL);
+ if (pwd->pw_change)
+ if (tp.tv_sec >= pwd->pw_change) {
+ (void)printf("Sorry -- your password has expired.\n");
+ sleepexit(1);
+ }
+ else if (pwd->pw_change - tp.tv_sec <
+ 2 * DAYSPERWEEK * SECSPERDAY && !quietlog)
+ (void)printf("Warning: your password expires on %s",
+ ctime(&pwd->pw_expire));
+ if (pwd->pw_expire)
+ if (tp.tv_sec >= pwd->pw_expire) {
+ (void)printf("Sorry -- your account has expired.\n");
+ sleepexit(1);
+ }
+ else if (pwd->pw_expire - tp.tv_sec <
+ 2 * DAYSPERWEEK * SECSPERDAY && !quietlog)
+ (void)printf("Warning: your account expires on %s",
+ ctime(&pwd->pw_expire));
+
+ /* nothing else left to fail -- really log in */
+ {
+ struct utmp utmp;
+
+ bzero((void *)&utmp, sizeof(utmp));
+ (void)time(&utmp.ut_time);
+ strncpy(utmp.ut_name, username, sizeof(utmp.ut_name));
+ if (hostname)
+ strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
+ strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line));
+ login(&utmp);