aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-05-09 21:27:15 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-05-09 21:27:15 +0000
commitb0752f081e8296645e5ccf605e953b42993ef75c (patch)
tree73c8241c94c6be8edc40e5761be496f9c17b0b26
parent84fe510bef96554da6fe462a12d0a91023812982 (diff)
downloadbusybox-w32-b0752f081e8296645e5ccf605e953b42993ef75c.tar.gz
busybox-w32-b0752f081e8296645e5ccf605e953b42993ef75c.tar.bz2
busybox-w32-b0752f081e8296645e5ccf605e953b42993ef75c.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 git-svn-id: svn://busybox.net/trunk/busybox@18595 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--loginutils/cryptpw.c27
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 @@
11int cryptpw_main(int argc, char **argv); 10int cryptpw_main(int argc, char **argv);
12int cryptpw_main(int argc, char **argv) 11int 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}