@@ -413,7 +413,7 @@ static bool ChangePasswordHashUsingChpasswd(const char *puser, const char *passw
413413 int status ;
414414 const char * cmd_str = CHPASSWD " -e" ;
415415 Log (LOG_LEVEL_VERBOSE , "Changing password hash for user '%s'. (command: '%s')" , puser , cmd_str );
416- FILE * cmd = cf_popen_sh (cmd_str , "w" );
416+ FILE * cmd = cf_popen (cmd_str , "w" , true );
417417 if (!cmd )
418418 {
419419 Log (LOG_LEVEL_ERR , "Could not launch password changing command '%s': %s." , cmd_str , GetErrorStr ());
@@ -645,12 +645,20 @@ static bool ExecuteUserCommand(const char *puser, const char *cmd, size_t sizeof
645645
646646 Log (LOG_LEVEL_VERBOSE , "%s user '%s'. (command: '%s')" , cap_action_msg , puser , cmd );
647647
648- int status = system (cmd );
649- if (!WIFEXITED ( status ) || WEXITSTATUS ( status ) != 0 )
648+ FILE * fptr = cf_popen (cmd , "w" , true );
649+ if (!fptr )
650650 {
651651 Log (LOG_LEVEL_ERR , "Command returned error while %s user '%s'. (Command line: '%s')" , action_msg , puser , cmd );
652652 return false;
653653 }
654+
655+ int status = cf_pclose (fptr );
656+ if (status )
657+ {
658+ Log (LOG_LEVEL_ERR , "'%s' returned non-zero status: %i\n" , cmd , status );
659+ return false;
660+ }
661+
654662 return true;
655663}
656664
0 commit comments