From 12a432715f066cf9d677316a39c9e0ebc6d72404 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 13 May 2011 03:19:01 +0200 Subject: adduser: safe username passing to passwd/addgroup passwd: support creating SHA passwords random code shrink function old new delta crypt_make_pw_salt - 87 +87 adduser_main 883 904 +21 ... crypt_make_salt 99 89 -10 chpasswd_main 329 312 -17 packed_usage 28731 28691 -40 passwd_main 1070 1000 -70 cryptpw_main 310 224 -86 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 4/12 up/down: 154/-288) Total: -134 bytes Signed-off-by: Denys Vlasenko --- include/libbb.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libbb.h b/include/libbb.h index 4232c38f4..89e8e4452 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1259,14 +1259,19 @@ extern int correct_password(const struct passwd *pw) FAST_FUNC; #endif extern char *pw_encrypt(const char *clear, const char *salt, int cleanup) FAST_FUNC; extern int obscure(const char *old, const char *newval, const struct passwd *pwdp) FAST_FUNC; -/* rnd is additional random input. New one is returned. +/* + * rnd is additional random input. New one is returned. * Useful if you call crypt_make_salt many times in a row: * rnd = crypt_make_salt(buf1, 4, 0); * rnd = crypt_make_salt(buf2, 4, rnd); * rnd = crypt_make_salt(buf3, 4, rnd); * (otherwise we risk having same salt generated) */ -extern int crypt_make_salt(char *p, int cnt, int rnd) FAST_FUNC; +extern int crypt_make_salt(char *p, int cnt /*, int rnd*/) FAST_FUNC; +/* "$N$" + sha_salt_16_bytes + NUL */ +#define MAX_PW_SALT_LEN (3 + 16 + 1) +extern char* crypt_make_pw_salt(char p[MAX_PW_SALT_LEN], const char *algo) FAST_FUNC; + /* Returns number of lines changed, or -1 on error */ #if !(ENABLE_FEATURE_ADDUSER_TO_GROUP || ENABLE_FEATURE_DEL_USER_FROM_GROUP) -- cgit v1.2.3