adamwill / rpms / openscap

Forked from rpms/openscap 4 years ago
Clone

Blame SOURCES/fix_oscap_ssh_sudo.patch

9319e0
diff --git a/utils/oscap-ssh b/utils/oscap-ssh
9319e0
index ee6eb9c81..6d60a369e 100755
9319e0
--- a/utils/oscap-ssh
9319e0
+++ b/utils/oscap-ssh
9319e0
@@ -115,6 +115,11 @@ function scp_retreive_from_temp_dir {
9319e0
     scp -o ControlPath="$MASTER_SOCKET" -P "$SSH_PORT" $SSH_ADDITIONAL_OPTIONS "$SSH_HOST:$REMOTE_TEMP_DIR/$1" "$2"
9319e0
 }
9319e0
 
9319e0
+function first_argument_is_sudo {
9319e0
+	[ "$1" == "sudo" ] || [ "$1" == "--sudo" ]
9319e0
+	return $?
9319e0
+}
9319e0
+
9319e0
 function sanity_check_arguments {
9319e0
     if [ $# -lt 1 ]; then
9319e0
         echo "No arguments provided."
9319e0
@@ -123,7 +128,7 @@ function sanity_check_arguments {
9319e0
     elif [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
9319e0
         usage
9319e0
         die
9319e0
-    elif [ "$1" == "sudo" ] || [ "$1" == "--sudo" ]; then
9319e0
+    elif first_argument_is_sudo "$@"; then
9319e0
         OSCAP_SUDO="sudo"
9319e0
         # force pseudo-tty allocation so that users can type their password if necessary
9319e0
         SSH_TTY_ALLOCATION_OPTION="-t"
9319e0
@@ -155,6 +160,7 @@ function check_oscap_arguments {
9319e0
 }
9319e0
 
9319e0
 sanity_check_arguments "$@"
9319e0
+first_argument_is_sudo "$@" && shift
9319e0
 
9319e0
 SSH_HOST="$1"
9319e0
 SSH_PORT="$2"