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
This commit is contained in:
parent
a026154c6f
commit
3732cf72d6
@ -451,10 +451,11 @@ int main (int argc, char **argv)
|
|||||||
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
(void) textdomain (PACKAGE);
|
(void) textdomain (PACKAGE);
|
||||||
|
|
||||||
process_root_flag ("-R", argc, argv);
|
|
||||||
|
|
||||||
process_flags (argc, argv);
|
process_flags (argc, argv);
|
||||||
|
|
||||||
|
salt = get_salt();
|
||||||
|
process_root_flag ("-R", argc, argv);
|
||||||
|
|
||||||
#ifdef USE_PAM
|
#ifdef USE_PAM
|
||||||
if (md5flg || eflg || cflg) {
|
if (md5flg || eflg || cflg) {
|
||||||
use_pam = false;
|
use_pam = false;
|
||||||
@ -545,7 +546,6 @@ int main (int argc, char **argv)
|
|||||||
const struct passwd *pw;
|
const struct passwd *pw;
|
||||||
struct passwd newpw;
|
struct passwd newpw;
|
||||||
|
|
||||||
salt = get_salt();
|
|
||||||
if (salt) {
|
if (salt) {
|
||||||
cp = pw_encrypt (newpwd, salt);
|
cp = pw_encrypt (newpwd, salt);
|
||||||
if (NULL == cp) {
|
if (NULL == cp) {
|
||||||
|
Loading…
Reference in New Issue
Block a user