diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-05-09 21:27:15 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-05-09 21:27:15 +0000 |
commit | 57bf668d118804060cee998408bdfbfb5512e670 (patch) | |
tree | 73c8241c94c6be8edc40e5761be496f9c17b0b26 | |
parent | 68de7207231fbb3c92487e30b381268737ee2228 (diff) | |
download | busybox-w32-57bf668d118804060cee998408bdfbfb5512e670.tar.gz busybox-w32-57bf668d118804060cee998408bdfbfb5512e670.tar.bz2 busybox-w32-57bf668d118804060cee998408bdfbfb5512e670.zip |
cryptpw: size reduction
function old new delta
cryptpw_main 198 140 -58
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-58) Total: -58 bytes
-rw-r--r-- | loginutils/cryptpw.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/loginutils/cryptpw.c b/loginutils/cryptpw.c index d4bcad3e0..54babdc80 100644 --- a/loginutils/cryptpw.c +++ b/loginutils/cryptpw.c | |||
@@ -3,7 +3,6 @@ | |||
3 | * cryptpw.c | 3 | * cryptpw.c |
4 | * | 4 | * |
5 | * Cooked from passwd.c by Thomas Lundquist <thomasez@zelow.no> | 5 | * Cooked from passwd.c by Thomas Lundquist <thomasez@zelow.no> |
6 | * | ||
7 | */ | 6 | */ |
8 | 7 | ||
9 | #include "busybox.h" | 8 | #include "busybox.h" |
@@ -11,27 +10,19 @@ | |||
11 | int cryptpw_main(int argc, char **argv); | 10 | int cryptpw_main(int argc, char **argv); |
12 | int cryptpw_main(int argc, char **argv) | 11 | int cryptpw_main(int argc, char **argv) |
13 | { | 12 | { |
14 | char *clear; | 13 | char salt[sizeof("$N$XXXXXXXX")]; |
15 | char salt[sizeof("$N$XXXXXXXX")]; /* "$N$XXXXXXXX" or "XX" */ | ||
16 | const char *opt_a = "md5"; | ||
17 | |||
18 | getopt32(argc, argv, "a:", &opt_a); | ||
19 | /* move past the commandline options */ | ||
20 | /*argc -= optind; - unused */ | ||
21 | argv += optind; | ||
22 | 14 | ||
23 | crypt_make_salt(salt, 1); /* des */ | 15 | if (!getopt32(argc, argv, "a:", NULL) || argv[optind - 1][0] != 'd') { |
24 | if (strcasecmp(opt_a, "md5") == 0) { | ||
25 | strcpy(salt, "$1$"); | 16 | strcpy(salt, "$1$"); |
26 | crypt_make_salt(salt + 3, 4); | 17 | /* Too ugly, and needs even more magic to handle endianness: */ |
27 | } else if (strcasecmp(opt_a, "des") != 0) { | 18 | //((uint32_t*)&salt)[0] = '$' + '1'*0x100 + '$'*0x10000; |
28 | bb_show_usage(); | 19 | /* Hope one day gcc will do it itself (inlining strcpy) */ |
20 | crypt_make_salt(salt + 3, 4); /* md5 */ | ||
21 | } else { | ||
22 | crypt_make_salt(salt, 1); /* des */ | ||
29 | } | 23 | } |
30 | 24 | ||
31 | clear = argv[0]; | 25 | puts(pw_encrypt(argv[optind] ? argv[optind] : xmalloc_getline(stdin), salt)); |
32 | if (!clear) | ||
33 | clear = xmalloc_getline(stdin); | ||
34 | 26 | ||
35 | puts(pw_encrypt(clear, salt)); | ||
36 | return 0; | 27 | return 0; |
37 | } | 28 | } |