From: juyin Date: Thu, 31 Mar 2022 08:48:52 +0000 (+0800) Subject: chpasswd: fix function problem with -R parameter X-Git-Tag: 4.12~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3732cf72d6f05fcd9d9f301eac84c1a61443e379;p=thirdparty%2Fshadow.git chpasswd: fix function problem with -R parameter Generating salt value depends on /dev/urandom. But after the function process_root_flag changed the root directory, It does not exist. So, generate salt value before changeing the directory. Fixes: #514 --- diff --git a/src/chpasswd.c b/src/chpasswd.c index 94e923abe..d0da14c69 100644 --- a/src/chpasswd.c +++ b/src/chpasswd.c @@ -451,10 +451,11 @@ int main (int argc, char **argv) (void) bindtextdomain (PACKAGE, LOCALEDIR); (void) textdomain (PACKAGE); - process_root_flag ("-R", argc, argv); - process_flags (argc, argv); + salt = get_salt(); + process_root_flag ("-R", argc, argv); + #ifdef USE_PAM if (md5flg || eflg || cflg) { use_pam = false; @@ -545,7 +546,6 @@ int main (int argc, char **argv) const struct passwd *pw; struct passwd newpw; - salt = get_salt(); if (salt) { cp = pw_encrypt (newpwd, salt); if (NULL == cp) {