adamwill / rpms / openscap

Forked from rpms/openscap 3 years ago
Clone

Blame SOURCES/openscap-1.2.18-oscap-ssh-sudo.patch

d7b4b6
diff --git a/utils/oscap-ssh b/utils/oscap-ssh
d7b4b6
index 658cc2ee4..bd2e209c4 100755
d7b4b6
--- a/utils/oscap-ssh
d7b4b6
+++ b/utils/oscap-ssh
d7b4b6
@@ -280,7 +280,12 @@ echo "Starting the evaluation..."
d7b4b6
 # changing directory because of --oval-results support. oval results files are
d7b4b6
 # dumped into PWD, and we can't be sure by the file names - we need controlled
d7b4b6
 # environment
d7b4b6
-ssh_execute_with_command_and_options "cd $REMOTE_TEMP_DIR; $OSCAP_SUDO oscap $(command_array_to_string oscap_args)" "$SSH_TTY_ALLOCATION_OPTION"
d7b4b6
+if [ -z "$OSCAP_SUDO" ]; then
d7b4b6
+    ssh_execute_with_command_and_options "cd $REMOTE_TEMP_DIR; oscap $(command_array_to_string oscap_args)" "$SSH_TTY_ALLOCATION_OPTION"
d7b4b6
+else
d7b4b6
+    OSCAP_CMD="oscap $(command_array_to_string oscap_args); rc=\$?; chown \$SUDO_USER $REMOTE_TEMP_DIR/*; exit \$rc"
d7b4b6
+    ssh_execute_with_command_and_options "cd $REMOTE_TEMP_DIR; $OSCAP_SUDO sh -c '$OSCAP_CMD'" "$SSH_TTY_ALLOCATION_OPTION"
d7b4b6
+fi
d7b4b6
 OSCAP_EXIT_CODE=$?
d7b4b6
 echo "oscap exit code: $OSCAP_EXIT_CODE"
d7b4b6