On Fri, Dec 18, 2015 at 2:45 PM, Pascal Bach <[email protected]> wrote:
> int chpasswd_main(int argc UNUSED_PARAM, char **argv)
> {
> char *name;
> + char *algo = CONFIG_FEATURE_DEFAULT_PASSWD_ALGO;
It warns here.
> int opt;
>
> if (getuid() != 0)
> bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
>
> - opt_complementary = "m--e:e--m";
> + opt_complementary = "m--ec:e--mc:c--em";
> IF_LONG_OPTS(applet_long_options = chpasswd_longopts;)
> - opt = getopt32(argv, "em");
> + opt = getopt32(argv, "emc:", &algo);
>
> while ((name = xmalloc_fgetline(stdin)) != NULL) {
> char *free_me;
> @@ -77,15 +79,14 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
>
> free_me = NULL;
> if (!(opt & OPT_ENC)) {
> - char salt[sizeof("$N$XXXXXXXX")];
> + char salt[MAX_PW_SALT_LEN];
>
> - crypt_make_salt(salt, 1);
> if (opt & OPT_MD5) {
> - salt[0] = '$';
> - salt[1] = '1';
> - salt[2] = '$';
> - crypt_make_salt(salt + 3, 4);
> + /* Force MD5 if the -m flag is set */
> + algo = "md5";
> }
> +
> + crypt_make_pw_salt(salt, algo);
crypt_make_pw_salt() accepts lowercase algos, such as "md5".
chpasswd examples I googled use uppercase: "MD5".
So, this won't be compatible.
> free_me = pass = pw_encrypt(pass, salt, 0);
> }
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox