correct_password: undo whitespace damage.
authorDenis Vlasenko <vda.linux@googlemail.com>
Sat, 23 Sep 2006 13:11:49 +0000 (13:11 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Sat, 23 Sep 2006 13:11:49 +0000 (13:11 -0000)
vlock + correct_password: fix incorrect line breaks in messages.

libbb/correct_password.c
loginutils/su.c
loginutils/vlock.c

index 527b3100b5c0c2d878ea1465a48e356036b37beb..fd7e0b56c8d85e26796dc93635c0d2a7fafadd71 100644 (file)
  * SUCH DAMAGE.
  */
 
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <syslog.h>
-#include <ctype.h>
-#include <crypt.h>
-
 #include "libbb.h"
 
-
-
 /* Ask the user for a password.
    Return 1 if the user gives the correct password for entry PW,
    0 if not.  Return 1 without asking for a password if run by UID 0
    or if PW has an empty password.  */
 
-int correct_password ( const struct passwd *pw )
+int correct_password(const struct passwd *pw)
 {
        char *unencrypted, *encrypted, *correct;
 
 #ifdef CONFIG_FEATURE_SHADOWPASSWDS
-       if (( strcmp ( pw-> pw_passwd, "x" ) == 0 ) || ( strcmp ( pw-> pw_passwd, "*" ) == 0 )) {
-               struct spwd *sp = getspnam ( pw-> pw_name );
+       if (!strcmp(pw->pw_passwd, "x") || !strcmp(pw->pw_passwd, "*")) {
+               struct spwd *sp = getspnam(pw->pw_name);
 
-               if ( !sp )
-                       bb_error_msg_and_die ( "\nno valid shadow password" );
+               if (!sp)
+                       bb_error_msg_and_die("no valid shadow password");
 
-               correct = sp-> sp_pwdp;
+               correct = sp->sp_pwdp;
        }
        else
 #endif
-               correct = pw-> pw_passwd;
+               correct = pw->pw_passwd;
 
-       if ( correct == 0 || correct[0] == '\0' )
+       if (!correct || correct[0] == '\0')
                return 1;
 
-       unencrypted = bb_askpass ( 0, "Password: " );
-       if ( !unencrypted )
-       {
+       unencrypted = bb_askpass(0, "Password: ");
+       if (!unencrypted) {
                return 0;
        }
-       encrypted = crypt ( unencrypted, correct );
-       memset ( unencrypted, 0, strlen ( unencrypted ));
-       return ( strcmp ( encrypted, correct ) == 0 ) ? 1 : 0;
+       encrypted = crypt(unencrypted, correct);
+       memset(unencrypted, 0, strlen(unencrypted));
+       return (!strcmp(encrypted, correct)) ? 1 : 0;
 }
index ff6643e60d96bf44765be924e950f61db86e02cd..c51359ae175021da142ffc923f22c9c5f5be535d 100644 (file)
@@ -45,7 +45,7 @@ int su_main(int argc, char **argv)
        }
 
        pw = getpwnam(opt_username);
-       if (!pw) bb_error_msg_and_die("Unknown id: %s", opt_username);
+       if (!pw) bb_error_msg_and_die("unknown id: %s", opt_username);
 
        /* Make sure pw->pw_shell is non-NULL.  It may be NULL when NEW_USER
           is a username that is retrieved via NIS (YP), but that doesn't have
index b4426ad41a607be9fe23d676f0a026c8370d339c..564b6d527fd76175d7f6babf6f674a7715e94ea5 100644 (file)
@@ -108,13 +108,12 @@ int vlock_main(int argc, char **argv)
        tcsetattr(STDIN_FILENO, TCSANOW, &term);
 
        do {
-               printf("Virtual Console%s locked.\n%s's ", (o_lock_all) ? "s" : "", pw->pw_name);
-               fflush(stdout);
-               if (correct_password (pw)) {
+               printf("Virtual Console%s locked. Enter %s's password to unlock\n", (o_lock_all) ? "s" : "", pw->pw_name);
+               if (correct_password(pw)) {
                        break;
                }
                bb_do_delay(FAIL_DELAY);
-               puts("Password incorrect.");
+               puts("Password incorrect");
        } while (1);
        restore_terminal();
        return 0;