diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-05-08 17:52:17 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-05-08 17:52:17 +0000 |
commit | 722cfbe0032c15b1bc9cf13a94197564b0860b09 (patch) | |
tree | c03518f2059504a513119cf4d499ccf5c7233f83 /loginutils | |
parent | 92ce299856803ce2a2e59c4bfd2cc9edce90d3f7 (diff) | |
download | busybox-w32-722cfbe0032c15b1bc9cf13a94197564b0860b09.tar.gz busybox-w32-722cfbe0032c15b1bc9cf13a94197564b0860b09.tar.bz2 busybox-w32-722cfbe0032c15b1bc9cf13a94197564b0860b09.zip |
cryptpw: new applet (a bit less than 3k added)
(by Thomas Lundquist <lists@zelow.no>)
git-svn-id: svn://busybox.net/trunk/busybox@18586 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/Config.in | 6 | ||||
-rw-r--r-- | loginutils/Kbuild | 1 | ||||
-rw-r--r-- | loginutils/passwd.c | 50 |
3 files changed, 7 insertions, 50 deletions
diff --git a/loginutils/Config.in b/loginutils/Config.in index e8ab9ec3c..919091ec6 100644 --- a/loginutils/Config.in +++ b/loginutils/Config.in | |||
@@ -166,6 +166,12 @@ config FEATURE_PASSWD_WEAK_CHECK | |||
166 | help | 166 | help |
167 | With this option passwd will refuse new passwords which are "weak". | 167 | With this option passwd will refuse new passwords which are "weak". |
168 | 168 | ||
169 | config CRYPTPW | ||
170 | bool "cryptpw" | ||
171 | default n | ||
172 | help | ||
173 | Applet for crypting a string. | ||
174 | |||
169 | config SU | 175 | config SU |
170 | bool "su" | 176 | bool "su" |
171 | default n | 177 | default n |
diff --git a/loginutils/Kbuild b/loginutils/Kbuild index 6c9d193e1..1b1165a6e 100644 --- a/loginutils/Kbuild +++ b/loginutils/Kbuild | |||
@@ -7,6 +7,7 @@ | |||
7 | lib-y:= | 7 | lib-y:= |
8 | lib-$(CONFIG_ADDGROUP) += addgroup.o | 8 | lib-$(CONFIG_ADDGROUP) += addgroup.o |
9 | lib-$(CONFIG_ADDUSER) += adduser.o | 9 | lib-$(CONFIG_ADDUSER) += adduser.o |
10 | lib-$(CONFIG_CRYPTPW) += cryptpw.o | ||
10 | lib-$(CONFIG_GETTY) += getty.o | 11 | lib-$(CONFIG_GETTY) += getty.o |
11 | lib-$(CONFIG_LOGIN) += login.o | 12 | lib-$(CONFIG_LOGIN) += login.o |
12 | lib-$(CONFIG_PASSWD) += passwd.o | 13 | lib-$(CONFIG_PASSWD) += passwd.o |
diff --git a/loginutils/passwd.c b/loginutils/passwd.c index b937ce45e..a323c0a40 100644 --- a/loginutils/passwd.c +++ b/loginutils/passwd.c | |||
@@ -12,44 +12,6 @@ static void nuke_str(char *str) | |||
12 | if (str) memset(str, 0, strlen(str)); | 12 | if (str) memset(str, 0, strlen(str)); |
13 | } | 13 | } |
14 | 14 | ||
15 | |||
16 | static int i64c(int i) | ||
17 | { | ||
18 | i &= 0x3f; | ||
19 | if (i == 0) | ||
20 | return '.'; | ||
21 | if (i == 1) | ||
22 | return '/'; | ||
23 | if (i < 12) | ||
24 | return ('0' - 2 + i); | ||
25 | if (i < 38) | ||
26 | return ('A' - 12 + i); | ||
27 | return ('a' - 38 + i); | ||
28 | } | ||
29 | |||
30 | |||
31 | static void crypt_make_salt(char *p, int cnt) | ||
32 | { | ||
33 | unsigned x = x; /* it's pointless to initialize it anyway :) */ | ||
34 | |||
35 | x += getpid() + time(NULL) + clock(); | ||
36 | do { | ||
37 | /* x = (x*1664525 + 1013904223) % 2^32 generator is lame | ||
38 | * (low-order bit is not "random", etc...), | ||
39 | * but for our purposes it is good enough */ | ||
40 | x = x*1664525 + 1013904223; | ||
41 | /* BTW, Park and Miller's "minimal standard generator" is | ||
42 | * x = x*16807 % ((2^31)-1) | ||
43 | * It has no problem with visibly alternating lowest bit | ||
44 | * but is also weak in cryptographic sense + needs div, | ||
45 | * which needs more code (and slower) on many CPUs */ | ||
46 | *p++ = i64c(x >> 16); | ||
47 | *p++ = i64c(x >> 22); | ||
48 | } while (--cnt); | ||
49 | *p = '\0'; | ||
50 | } | ||
51 | |||
52 | |||
53 | static char* new_password(const struct passwd *pw, uid_t myuid, int algo) | 15 | static char* new_password(const struct passwd *pw, uid_t myuid, int algo) |
54 | { | 16 | { |
55 | char salt[sizeof("$N$XXXXXXXX")]; /* "$N$XXXXXXXX" or "XX" */ | 17 | char salt[sizeof("$N$XXXXXXXX")]; /* "$N$XXXXXXXX" or "XX" */ |
@@ -109,18 +71,6 @@ static char* new_password(const struct passwd *pw, uid_t myuid, int algo) | |||
109 | } | 71 | } |
110 | 72 | ||
111 | 73 | ||
112 | #if 0 | ||
113 | static int get_algo(char *a) | ||
114 | { | ||
115 | /* standard: MD5 */ | ||
116 | int x = 1; | ||
117 | if (strcasecmp(a, "des") == 0) | ||
118 | x = 0; | ||
119 | return x; | ||
120 | } | ||
121 | #endif | ||
122 | |||
123 | |||
124 | static int update_passwd(const char *filename, const char *username, | 74 | static int update_passwd(const char *filename, const char *username, |
125 | const char *new_pw) | 75 | const char *new_pw) |
126 | { | 76 | { |