aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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}