Explorar o código

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 %!s(int64=8) %!d(string=hai) anos
pai
achega
369a236de1
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  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")
 	{