diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-09-23 13:11:49 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-09-23 13:11:49 +0000 |
commit | faf64b2b268014d7076a2aeb58a823f45ca9218c (patch) | |
tree | c99eb90ceea7adfebc157ca28a45cf9ae81b4a57 /libbb | |
parent | f70446b9182357f44f607f5923ac2eb49c4af12c (diff) | |
download | busybox-w32-faf64b2b268014d7076a2aeb58a823f45ca9218c.tar.gz busybox-w32-faf64b2b268014d7076a2aeb58a823f45ca9218c.tar.bz2 busybox-w32-faf64b2b268014d7076a2aeb58a823f45ca9218c.zip |
correct_password: undo whitespace damage.
vlock + correct_password: fix incorrect line breaks in messages.
git-svn-id: svn://busybox.net/trunk/busybox@16201 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/correct_password.c | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/libbb/correct_password.c b/libbb/correct_password.c index 527b3100b..fd7e0b56c 100644 --- a/libbb/correct_password.c +++ b/libbb/correct_password.c | |||
@@ -28,50 +28,38 @@ | |||
28 | * SUCH DAMAGE. | 28 | * SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdio.h> | ||
32 | #include <errno.h> | ||
33 | #include <unistd.h> | ||
34 | #include <string.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <syslog.h> | ||
37 | #include <ctype.h> | ||
38 | #include <crypt.h> | ||
39 | |||
40 | #include "libbb.h" | 31 | #include "libbb.h" |
41 | 32 | ||
42 | |||
43 | |||
44 | /* Ask the user for a password. | 33 | /* Ask the user for a password. |
45 | Return 1 if the user gives the correct password for entry PW, | 34 | Return 1 if the user gives the correct password for entry PW, |
46 | 0 if not. Return 1 without asking for a password if run by UID 0 | 35 | 0 if not. Return 1 without asking for a password if run by UID 0 |
47 | or if PW has an empty password. */ | 36 | or if PW has an empty password. */ |
48 | 37 | ||
49 | int correct_password ( const struct passwd *pw ) | 38 | int correct_password(const struct passwd *pw) |
50 | { | 39 | { |
51 | char *unencrypted, *encrypted, *correct; | 40 | char *unencrypted, *encrypted, *correct; |
52 | 41 | ||
53 | #ifdef CONFIG_FEATURE_SHADOWPASSWDS | 42 | #ifdef CONFIG_FEATURE_SHADOWPASSWDS |
54 | if (( strcmp ( pw-> pw_passwd, "x" ) == 0 ) || ( strcmp ( pw-> pw_passwd, "*" ) == 0 )) { | 43 | if (!strcmp(pw->pw_passwd, "x") || !strcmp(pw->pw_passwd, "*")) { |
55 | struct spwd *sp = getspnam ( pw-> pw_name ); | 44 | struct spwd *sp = getspnam(pw->pw_name); |
56 | 45 | ||
57 | if ( !sp ) | 46 | if (!sp) |
58 | bb_error_msg_and_die ( "\nno valid shadow password" ); | 47 | bb_error_msg_and_die("no valid shadow password"); |
59 | 48 | ||
60 | correct = sp-> sp_pwdp; | 49 | correct = sp->sp_pwdp; |
61 | } | 50 | } |
62 | else | 51 | else |
63 | #endif | 52 | #endif |
64 | correct = pw-> pw_passwd; | 53 | correct = pw->pw_passwd; |
65 | 54 | ||
66 | if ( correct == 0 || correct[0] == '\0' ) | 55 | if (!correct || correct[0] == '\0') |
67 | return 1; | 56 | return 1; |
68 | 57 | ||
69 | unencrypted = bb_askpass ( 0, "Password: " ); | 58 | unencrypted = bb_askpass(0, "Password: "); |
70 | if ( !unencrypted ) | 59 | if (!unencrypted) { |
71 | { | ||
72 | return 0; | 60 | return 0; |
73 | } | 61 | } |
74 | encrypted = crypt ( unencrypted, correct ); | 62 | encrypted = crypt(unencrypted, correct); |
75 | memset ( unencrypted, 0, strlen ( unencrypted )); | 63 | memset(unencrypted, 0, strlen(unencrypted)); |
76 | return ( strcmp ( encrypted, correct ) == 0 ) ? 1 : 0; | 64 | return (!strcmp(encrypted, correct)) ? 1 : 0; |
77 | } | 65 | } |