make unknown login name parallel real login so looks the same
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 25 Jun 1990 07:19:33 +0000 (23:19 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 25 Jun 1990 07:19:33 +0000 (23:19 -0800)
SCCS-vsn: usr.bin/login/login.c 5.57

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

index c6f3343..0c02566 100644 (file)
@@ -12,7 +12,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)login.c    5.56 (Berkeley) %G%";
+static char sccsid[] = "@(#)login.c    5.57 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -243,23 +243,21 @@ main(argc, argv)
                        failures = 0;
                }
                (void)strcpy(tbuf, username);
                        failures = 0;
                }
                (void)strcpy(tbuf, username);
+
                if (pwd = getpwnam(username))
                        salt = pwd->pw_passwd;
                if (pwd = getpwnam(username))
                        salt = pwd->pw_passwd;
-               else {
-                       /* take up the right amount of time */
-                       (void)crypt(getpass("Password:"), "xx");
-                       goto faked;
-               }
+               else
+                       salt = "xx";
 
                /* if user not super-user, check for disabled logins */
 
                /* if user not super-user, check for disabled logins */
-               if (pwd->pw_uid)
+               if (!pwd || pwd->pw_uid)
                        checknologin();
 
                /*
                 * Disallow automatic login to root; if not invoked by
                 * root, disallow if the uid's differ.
                 */
                        checknologin();
 
                /*
                 * Disallow automatic login to root; if not invoked by
                 * root, disallow if the uid's differ.
                 */
-               if (fflag) {
+               if (pwd && fflag) {
                        passwd_req =
 #ifndef        KERBEROS
                             pwd->pw_uid == 0 ||
                        passwd_req =
 #ifndef        KERBEROS
                             pwd->pw_uid == 0 ||
@@ -271,14 +269,14 @@ main(argc, argv)
                 * If no pre-authentication and a password exists
                 * for this user, prompt for one and verify it.
                 */
                 * If no pre-authentication and a password exists
                 * for this user, prompt for one and verify it.
                 */
-               if (!passwd_req || !*pwd->pw_passwd)
+               if (pwd && (!passwd_req || !*pwd->pw_passwd))
                        break;
 
                /*
                 * If trying to log in as root, but with insecure terminal,
                 * refuse the login attempt.
                 */
                        break;
 
                /*
                 * If trying to log in as root, but with insecure terminal,
                 * refuse the login attempt.
                 */
-               if (pwd->pw_uid == 0 && !rootterm(tty)) {
+               if (pwd && pwd->pw_uid == 0 && !rootterm(tty)) {
                        (void)fprintf(stderr,
                            "%s login refused on this terminal.\n",
                            pwd->pw_name);
                        (void)fprintf(stderr,
                            "%s login refused on this terminal.\n",
                            pwd->pw_name);
@@ -294,13 +292,18 @@ main(argc, argv)
                }
 
                (void)setpriority(PRIO_PROCESS, 0, -4);
                }
 
                (void)setpriority(PRIO_PROCESS, 0, -4);
+
                p = getpass("Password:");
 
                p = getpass("Password:");
 
+               if (pwd) {
                bzero(p, strlen(p));
                bzero(p, strlen(p));
-               if (!rval)
+
+               (void)setpriority(PRIO_PROCESS, 0, 0);
+
+               if (pwd && !rval)
                        break;
 
                        break;
 
-faked:         (void)printf("Login incorrect\n");
+               (void)printf("Login incorrect\n");
                failures++;
                /* we allow 10 tries, but after 3 we start backing off */
                if (++cnt > 3) {
                failures++;
                /* we allow 10 tries, but after 3 we start backing off */
                if (++cnt > 3) {
@@ -316,9 +319,6 @@ faked:              (void)printf("Login incorrect\n");
        /* committed to login -- turn off timeout */
        (void)alarm((u_int)0);
 
        /* committed to login -- turn off timeout */
        (void)alarm((u_int)0);
 
-       /* reset priority */
-       (void)setpriority(PRIO_PROCESS, 0, 0);
-
        /* paranoia... */
        endpwent();
 
        /* paranoia... */
        endpwent();