|
|
914530 |
From e355d9b35e713d3b5f814d5226bda359c93446d1 Mon Sep 17 00:00:00 2001
|
|
|
914530 |
From: =?UTF-8?q?Mat=C4=9Bj=20T=C3=BD=C4=8D?= <matyc@redhat.com>
|
|
|
914530 |
Date: Thu, 11 Oct 2018 15:18:49 +0200
|
|
|
914530 |
Subject: [PATCH] Fixed a bug with sudo as the first argument.
|
|
|
914530 |
|
|
|
914530 |
A call to `shift` is necessarry outside of any function, because
|
|
|
914530 |
one can't use `shift` to shift script's arguments from a function.
|
|
|
914530 |
---
|
|
|
914530 |
utils/oscap-ssh | 8 +++++++-
|
|
|
914530 |
1 file changed, 7 insertions(+), 1 deletion(-)
|
|
|
914530 |
|
|
|
914530 |
diff --git a/utils/oscap-ssh b/utils/oscap-ssh
|
|
|
914530 |
index ee6eb9c81..6d60a369e 100755
|
|
|
914530 |
--- a/utils/oscap-ssh
|
|
|
914530 |
+++ b/utils/oscap-ssh
|
|
|
914530 |
@@ -115,6 +115,11 @@ function scp_retreive_from_temp_dir {
|
|
|
914530 |
scp -o ControlPath="$MASTER_SOCKET" -P "$SSH_PORT" $SSH_ADDITIONAL_OPTIONS "$SSH_HOST:$REMOTE_TEMP_DIR/$1" "$2"
|
|
|
914530 |
}
|
|
|
914530 |
|
|
|
914530 |
+function first_argument_is_sudo {
|
|
|
914530 |
+ [ "$1" == "sudo" ] || [ "$1" == "--sudo" ]
|
|
|
914530 |
+ return $?
|
|
|
914530 |
+}
|
|
|
914530 |
+
|
|
|
914530 |
function sanity_check_arguments {
|
|
|
914530 |
if [ $# -lt 1 ]; then
|
|
|
914530 |
echo "No arguments provided."
|
|
|
914530 |
@@ -123,7 +128,7 @@ function sanity_check_arguments {
|
|
|
914530 |
elif [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
|
|
|
914530 |
usage
|
|
|
914530 |
die
|
|
|
914530 |
- elif [ "$1" == "sudo" ] || [ "$1" == "--sudo" ]; then
|
|
|
914530 |
+ elif first_argument_is_sudo "$@"; then
|
|
|
914530 |
OSCAP_SUDO="sudo"
|
|
|
914530 |
# force pseudo-tty allocation so that users can type their password if necessary
|
|
|
914530 |
SSH_TTY_ALLOCATION_OPTION="-t"
|
|
|
914530 |
@@ -155,6 +160,7 @@ function check_oscap_arguments {
|
|
|
914530 |
}
|
|
|
914530 |
|
|
|
914530 |
sanity_check_arguments "$@"
|
|
|
914530 |
+first_argument_is_sudo "$@" && shift
|
|
|
914530 |
|
|
|
914530 |
SSH_HOST="$1"
|
|
|
914530 |
SSH_PORT="$2"
|