- quietlog = FALSE;
- if (access(qlog, 0) == 0)
- quietlog = TRUE;
- if ( !quietlog && (f = open(lastlog, 2)) >= 0 ) {
- struct lastlog ll;
-
- lseek(f, (long)pwd->pw_uid * sizeof (struct lastlog), 0);
- if (read(f, (char *) &ll, sizeof ll) == sizeof ll &&
- ll.ll_time != 0) {
- printf("Last login: %.*s on %.*s\n"
- , 24-5
- , (char *) ctime(&ll.ll_time)
- , sizeof(ll.ll_line)
- , ll.ll_line
- );
- }
- lseek(f, (long)pwd->pw_uid * sizeof (struct lastlog), 0);
- time(&ll.ll_time);
- SCPYN(ll.ll_line, rindex(ttyn, '/')+1);
- write(f, (char *) &ll, sizeof ll);
- close(f);
+
+ dolastlog(quietlog);
+
+ (void)chown(ttyn, pwd->pw_uid,
+ (gr = getgrnam(TTYGRPNAME)) ? gr->gr_gid : pwd->pw_gid);
+ (void)setgid(pwd->pw_gid);
+
+ initgroups(username, pwd->pw_gid);
+
+ if (*pwd->pw_shell == '\0')
+ pwd->pw_shell = _PATH_BSHELL;
+
+ /* destroy environment unless user has requested preservation */
+ if (!pflag)
+ environ = envinit;
+ (void)setenv("HOME", pwd->pw_dir, 1);
+ (void)setenv("SHELL", pwd->pw_shell, 1);
+ if (term[0] == '\0')
+ strncpy(term, stypeof(tty), sizeof(term));
+ (void)setenv("TERM", term, 0);
+ (void)setenv("LOGNAME", pwd->pw_name, 1);
+ (void)setenv("USER", pwd->pw_name, 1);
+ (void)setenv("PATH", _PATH_DEFPATH, 0);
+#ifdef KERBEROS
+ if (krbtkfile_env)
+ (void)setenv("KRBTKFILE", krbtkfile_env, 1);
+#endif
+
+ if (tty[sizeof("tty")-1] == 'd')
+ syslog(LOG_INFO, "DIALUP %s, %s", tty, pwd->pw_name);
+ /* if fflag is on, assume caller/authenticator has logged root login */
+ if (rootlogin && fflag == 0)
+ if (hostname)
+ syslog(LOG_NOTICE, "ROOT LOGIN (%s) ON %s FROM %s",
+ username, tty, hostname);
+ else
+ syslog(LOG_NOTICE, "ROOT LOGIN (%s) ON %s", username, tty);
+
+#ifdef KERBEROS
+ if (!quietlog && notickets == 1)
+ (void)printf("Warning: no Kerberos tickets issued.\n");
+#endif
+
+ if (!quietlog) {
+ struct stat st;
+
+ printf("%s%s",
+ "386BSD Release 0.1 by William and Lynne Jolitz.\n",
+"Copyright (c) 1989,1990,1991,1992 William F. Jolitz. All rights reserved.\n\
+Based in part on work by the 386BSD User Community and the\n\
+BSD Networking Software, Release 2 by UCB EECS Department.\n");
+
+ motd();
+ (void)sprintf(tbuf, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
+ if (stat(tbuf, &st) == 0 && st.st_size != 0)
+ (void)printf("You have %smail.\n",
+ (st.st_mtime > st.st_atime) ? "new " : "");