+
+ quietlog = access(HUSHLOGIN, F_OK) == 0;
+ dolastlog(quietlog);
+
+ if (!hflag) { /* XXX */
+ static struct winsize win = { 0, 0, 0, 0 };
+
+ (void)ioctl(0, TIOCSWINSZ, &win);
+ }
+
+ (void)chown(ttyn, pwd->pw_uid,
+ (gr = getgrnam(TTYGRPNAME)) ? gr->gr_gid : pwd->pw_gid);
+ (void)chmod(ttyn, 0620);
+ (void)setgid(pwd->pw_gid);
+
+ initgroups(username, pwd->pw_gid);
+
+ quota(Q_DOWARN, pwd->pw_uid, (dev_t)-1, 0);
+ (void)setuid(pwd->pw_uid);
+
+ if (*pwd->pw_shell == '\0')
+ pwd->pw_shell = BSHELL;
+ /* turn on new line discipline for the csh */
+ else if (!strcmp(pwd->pw_shell, "/bin/csh")) {
+ ioctlval = NTTYDISC;
+ (void)ioctl(0, TIOCSETD, &ioctlval);
+ }
+
+ /* 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(), sizeof(term));
+ (void)setenv("TERM", term, 0);
+ (void)setenv("USER", pwd->pw_name, 1);
+ (void)setenv("PATH", "/usr/ucb:/bin:/usr/bin:", 0);
+
+ if (tty[sizeof("tty")-1] == 'd')
+ syslog(LOG_INFO, "DIALUP %s, %s", tty, pwd->pw_name);
+ if (pwd->pw_uid == 0)
+ if (hostname)
+ syslog(LOG_NOTICE, "ROOT LOGIN %s FROM %s",
+ tty, hostname);
+ else
+ syslog(LOG_NOTICE, "ROOT LOGIN %s", tty);
+
+ if (!quietlog) {
+ struct stat st;
+
+ motd();
+ (void)sprintf(tbuf, "%s/%s", MAILDIR, pwd->pw_name);
+ if (stat(tbuf, &st) == 0 && st.st_size != 0)
+ printf("You have %smail.\n",
+ (st.st_mtime > st.st_atime) ? "new " : "");
+ }
+
+ (void)signal(SIGALRM, SIG_DFL);
+ (void)signal(SIGQUIT, SIG_DFL);
+ (void)signal(SIGINT, SIG_DFL);
+ (void)signal(SIGTSTP, SIG_IGN);
+
+ tbuf[0] = '-';
+ strcpy(tbuf + 1, (p = rindex(pwd->pw_shell, '/')) ?
+ p + 1 : pwd->pw_shell);
+ execlp(pwd->pw_shell, tbuf, 0);
+ fprintf(stderr, "login: no shell: ");