فهرست منبع

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 8 سال پیش
والد
کامیت
369a236de1
1فایلهای تغییر یافته به همراه2 افزوده شده و 1 حذف شده
  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")
 	{