- if (!invalid && pwd->pw_uid == 0 && !rootterm(tty)) {
- if (utmp.ut_host[0])
- syslog(LOG_CRIT,
- "ROOT LOGIN REFUSED ON %s FROM %.*s",
- tty, HMAX, utmp.ut_host);
- else
- syslog(LOG_CRIT,
- "ROOT LOGIN REFUSED ON %s", tty);
- invalid = TRUE;
- }
- if (invalid) {
- printf("Login incorrect\n");
- if (++t >= 5) {
- if (utmp.ut_host[0])
- syslog(LOG_ERR,
- "REPEATED LOGIN FAILURES ON %s FROM %.*s, %.*s",
- tty, HMAX, utmp.ut_host,
- NMAX, utmp.ut_name);
- else
- syslog(LOG_ERR,
- "REPEATED LOGIN FAILURES ON %s, %.*s",
- tty, NMAX, utmp.ut_name);
- ioctl(0, TIOCHPCL, (struct sgttyb *) 0);
- close(0), close(1), close(2);
- sleep(10);
- exit(1);
- }
- }
- if (*pwd->pw_shell == '\0')
- pwd->pw_shell = "/bin/sh";
- if (chdir(pwd->pw_dir) < 0 && !invalid ) {
- if (chdir("/") < 0) {
- printf("No directory!\n");
- invalid = TRUE;
- } else {
- printf("No directory! %s\n",
- "Logging in with home=/");
- pwd->pw_dir = "/";
+ if (!passwd_req || (pwd && !*pwd->pw_passwd))
+ break;
+
+ setpriority(PRIO_PROCESS, 0, -4);
+ pp = getpass("Password:");
+ p = crypt(pp, salt);
+ setpriority(PRIO_PROCESS, 0, 0);
+
+ (void) bzero(pp, strlen(pp));
+ if (pwd && !strcmp(p, pwd->pw_passwd))
+ break;
+
+ printf("Login incorrect\n");
+ failures++;
+ /* we allow 10 tries, but after 3 we start backing off */
+ if (++cnt > 3) {
+ if (cnt >= 10) {
+ badlogin(username);
+ (void)ioctl(0, TIOCHPCL, (struct sgttyb *)NULL);
+ sleepexit(1);