diff options
| author | Ron Yorston <rmy@pobox.com> | 2025-08-12 08:07:00 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2025-08-12 08:07:00 +0100 |
| commit | 4e6b0b3e8b8f819bc9e2f69b0c267abecfe30968 (patch) | |
| tree | d030cd6daff8d3b79f1fbefa0b33bd02f33c3d5c /loginutils | |
| parent | aa6a7ebcfb93b21916ad5fb97ecf64c22328c07b (diff) | |
| parent | 628a7b2f4708037056a1432d7b6b1792c67e486a (diff) | |
| download | busybox-w32-4e6b0b3e8b8f819bc9e2f69b0c267abecfe30968.tar.gz busybox-w32-4e6b0b3e8b8f819bc9e2f69b0c267abecfe30968.tar.bz2 busybox-w32-4e6b0b3e8b8f819bc9e2f69b0c267abecfe30968.zip | |
Merge branch 'busybox' into merge
Diffstat (limited to 'loginutils')
| -rw-r--r-- | loginutils/Config.src | 11 | ||||
| -rw-r--r-- | loginutils/chpasswd.c | 2 | ||||
| -rw-r--r-- | loginutils/cryptpw.c | 37 | ||||
| -rw-r--r-- | loginutils/sulogin.c | 9 |
4 files changed, 48 insertions, 11 deletions
diff --git a/loginutils/Config.src b/loginutils/Config.src index cbb09646b..a7812bd32 100644 --- a/loginutils/Config.src +++ b/loginutils/Config.src | |||
| @@ -91,6 +91,17 @@ config USE_BB_CRYPT_SHA | |||
| 91 | With this option off, login will fail password check for any | 91 | With this option off, login will fail password check for any |
| 92 | user which has password encrypted with these algorithms. | 92 | user which has password encrypted with these algorithms. |
| 93 | 93 | ||
| 94 | config USE_BB_CRYPT_YES | ||
| 95 | bool "Enable yescrypt functions" | ||
| 96 | default y | ||
| 97 | depends on USE_BB_CRYPT | ||
| 98 | help | ||
| 99 | Enable this if you have passwords starting with "$y$" or | ||
| 100 | in your /etc/passwd or /etc/shadow files. These passwords | ||
| 101 | are hashed using yescrypt algorithms. | ||
| 102 | With this option off, login will fail password check for any | ||
| 103 | user which has password encrypted with these algorithms. | ||
| 104 | |||
| 94 | INSERT | 105 | INSERT |
| 95 | 106 | ||
| 96 | endmenu | 107 | endmenu |
diff --git a/loginutils/chpasswd.c b/loginutils/chpasswd.c index 65530b614..353f19961 100644 --- a/loginutils/chpasswd.c +++ b/loginutils/chpasswd.c | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | //config: default "des" | 17 | //config: default "des" |
| 18 | //config: depends on PASSWD || CRYPTPW || CHPASSWD | 18 | //config: depends on PASSWD || CRYPTPW || CHPASSWD |
| 19 | //config: help | 19 | //config: help |
| 20 | //config: Possible choices are "d[es]", "m[d5]", "s[ha256]" or "sha512". | 20 | //config: Possible choices: "d[es]", "m[d5]", "s[ha256]", "sha512", "yescrypt" |
| 21 | 21 | ||
| 22 | //applet:IF_CHPASSWD(APPLET(chpasswd, BB_DIR_USR_SBIN, BB_SUID_DROP)) | 22 | //applet:IF_CHPASSWD(APPLET(chpasswd, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
| 23 | 23 | ||
diff --git a/loginutils/cryptpw.c b/loginutils/cryptpw.c index 1c338540f..666deff0b 100644 --- a/loginutils/cryptpw.c +++ b/loginutils/cryptpw.c | |||
| @@ -84,8 +84,7 @@ to cryptpw. -a option (alias for -m) came from cryptpw. | |||
| 84 | int cryptpw_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 84 | int cryptpw_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 85 | int cryptpw_main(int argc UNUSED_PARAM, char **argv) | 85 | int cryptpw_main(int argc UNUSED_PARAM, char **argv) |
| 86 | { | 86 | { |
| 87 | /* Supports: cryptpw -m sha256 PASS 'rounds=999999999$SALT' */ | 87 | char salt[MAX_PW_SALT_LEN]; |
| 88 | char salt[MAX_PW_SALT_LEN + sizeof("rounds=999999999$")]; | ||
| 89 | char *salt_ptr; | 88 | char *salt_ptr; |
| 90 | char *password; | 89 | char *password; |
| 91 | const char *opt_m, *opt_S; | 90 | const char *opt_m, *opt_S; |
| @@ -100,7 +99,7 @@ int cryptpw_main(int argc UNUSED_PARAM, char **argv) | |||
| 100 | ; | 99 | ; |
| 101 | #endif | 100 | #endif |
| 102 | fd = STDIN_FILENO; | 101 | fd = STDIN_FILENO; |
| 103 | opt_m = CONFIG_FEATURE_DEFAULT_PASSWD_ALGO; | 102 | opt_m = NULL; |
| 104 | opt_S = NULL; | 103 | opt_S = NULL; |
| 105 | /* at most two non-option arguments; -P NUM */ | 104 | /* at most two non-option arguments; -P NUM */ |
| 106 | getopt32long(argv, "^" "sP:+S:m:a:" "\0" "?2", | 105 | getopt32long(argv, "^" "sP:+S:m:a:" "\0" "?2", |
| @@ -114,10 +113,34 @@ int cryptpw_main(int argc UNUSED_PARAM, char **argv) | |||
| 114 | if (argv[0] && !opt_S) | 113 | if (argv[0] && !opt_S) |
| 115 | opt_S = argv[1]; | 114 | opt_S = argv[1]; |
| 116 | 115 | ||
| 117 | salt_ptr = crypt_make_pw_salt(salt, opt_m); | 116 | if (opt_S && !opt_S[0]) { |
| 118 | if (opt_S) | 117 | /* mkpasswd 5.6.2 compat: SALT of "" |
| 119 | /* put user's data after the "$N$" prefix */ | 118 | * is treated as not specified |
| 120 | safe_strncpy(salt_ptr, opt_S, sizeof(salt) - (sizeof("$N$")-1)); | 119 | * (both forms: -S "" and argv[1] of "") |
| 120 | */ | ||
| 121 | opt_S = NULL; | ||
| 122 | } | ||
| 123 | |||
| 124 | if (opt_m) { | ||
| 125 | /* "cryptpw -m ALGO PASSWORD [SALT]" */ | ||
| 126 | /* generate "$x$" algo prefix + random salt */ | ||
| 127 | salt_ptr = crypt_make_pw_salt(salt, opt_m); | ||
| 128 | if (opt_S) { | ||
| 129 | /* "cryptpw -m ALGO PASSWORD SALT" */ | ||
| 130 | /* put SALT data after the "$x$" prefix */ | ||
| 131 | safe_strncpy(salt_ptr, opt_S, sizeof(salt) - (sizeof("$N$")-1)); | ||
| 132 | } | ||
| 133 | } else { | ||
| 134 | if (!opt_S) { | ||
| 135 | /* "cryptpw PASSWORD" */ | ||
| 136 | /* generate random salt with default algo */ | ||
| 137 | crypt_make_pw_salt(salt, CONFIG_FEATURE_DEFAULT_PASSWD_ALGO); | ||
| 138 | } else { | ||
| 139 | /* "cryptpw PASSWORD '$x$SALT'" */ | ||
| 140 | /* use given salt; algo will be detected by pw_encrypt() */ | ||
| 141 | safe_strncpy(salt, opt_S, sizeof(salt)); | ||
| 142 | } | ||
| 143 | } | ||
| 121 | 144 | ||
| 122 | xmove_fd(fd, STDIN_FILENO); | 145 | xmove_fd(fd, STDIN_FILENO); |
| 123 | 146 | ||
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c index 9c927ed79..984889915 100644 --- a/loginutils/sulogin.c +++ b/loginutils/sulogin.c | |||
| @@ -79,7 +79,7 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) | |||
| 79 | break; | 79 | break; |
| 80 | } | 80 | } |
| 81 | pause_after_failed_login(); | 81 | pause_after_failed_login(); |
| 82 | bb_simple_info_msg("Login incorrect"); | 82 | bb_simple_error_msg("Login incorrect"); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | /* util-linux 2.36.1 compat: no message */ | 85 | /* util-linux 2.36.1 compat: no message */ |
| @@ -119,9 +119,12 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) | |||
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | /* | 121 | /* |
| 122 | * Note: login does this (should we do it too?): | 122 | * Note: login does this. util-linux's sulogin does NOT. |
| 123 | * But it's rather unpleasant to have non-functioning ^C in a shell, | ||
| 124 | * and surprisingly, there is no easy way to remove SIG_IGN from ^C | ||
| 125 | * in the shell. So, we are doing it: | ||
| 123 | */ | 126 | */ |
| 124 | /*signal(SIGINT, SIG_DFL);*/ | 127 | signal(SIGINT, SIG_DFL); |
| 125 | 128 | ||
| 126 | /* Exec shell with no additional parameters. Never returns. */ | 129 | /* Exec shell with no additional parameters. Never returns. */ |
| 127 | exec_shell(shell, /* -p? then shell is login:*/(opts & 1), NULL); | 130 | exec_shell(shell, /* -p? then shell is login:*/(opts & 1), NULL); |
