Procházet zdrojové kódy

fix on sudo commands

The '--prompt' param of the sudo command was changed at some point, and now ignores it if the string is empty, this leads the agent to return the default prompt in the answer, this problem has been solved by using a custom prompt that is removed from the response.
DieFeM před 8 roky
rodič
revize
369a236de1
1 změnil soubory, kde provedl 2 přidání a 1 odebrání
  1. 2 1
      ogp_agent.pl

+ 2 - 1
ogp_agent.pl

@@ -2760,10 +2760,11 @@ sub sudo_exec_without_decrypt
 	my ($sudo_exec) = @_;
 	$sudo_exec =~ s/('+)/'"$1"'/g;
 	logger "Running the following command \"" . $sudo_exec . "\" with sudo.";
-	my $command = "echo '$SUDOPASSWD'|sudo -kS -p \"\" su -c '$sudo_exec;echo \$?' root 2>&1";
+	my $command = "echo '$SUDOPASSWD'|sudo -kS -p \"<prompt>\" su -c '$sudo_exec;echo \$?' root 2>&1";
 	my @cmdret = qx($command);
 	chomp(@cmdret);
 	my $ret = pop(@cmdret);
+	$cmdret[0] =~ s/<prompt>//g;
 	chomp($ret);
 	if ("X$ret" eq "X0")
 	{