Skip to content

Commit 0550108

Browse files
committed
change: oscap-ssh: Simplify sudo test
Change OSCAP_SUDO as array and after this there is no need to test it.
1 parent 9ebf7ea commit 0550108

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

utils/oscap-ssh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function sanity_check_arguments {
141141
usage
142142
exit 0
143143
elif first_argument_is_sudo "$@"; then
144-
OSCAP_SUDO="sudo"
144+
OSCAP_SUDO=("sudo")
145145
# force pseudo-tty allocation so that users can type their password if necessary
146146
SSH_TTY_ALLOCATION_OPTION="-t"
147147
shift
@@ -175,7 +175,7 @@ hash scp 2> /dev/null || die "Cannot find scp, please install the OpenSSH client
175175
hash mktemp 2> /dev/null || die "Cannot find mktemp, please install coreutils."
176176

177177

178-
OSCAP_SUDO=""
178+
OSCAP_SUDO=()
179179
# SSH_ADDITIONAL_OPTIONS may be defined in the calling shell
180180
SSH_TTY_ALLOCATION_OPTION=""
181181

@@ -303,11 +303,7 @@ echo "Starting the evaluation..."
303303
# changing directory because of --oval-results support. oval results files are
304304
# dumped into PWD, and we can't be sure by the file names - we need controlled
305305
# environment
306-
if [ -z "$OSCAP_SUDO" ]; then
307-
ssh_execute_with_command_and_options "cd $REMOTE_TEMP_DIR; oscap $(command_array_to_string "${oscap_args[@]}")" "$SSH_TTY_ALLOCATION_OPTION"
308-
else
309-
ssh_execute_with_command_and_options "cd $REMOTE_TEMP_DIR; umask 022; $OSCAP_SUDO scap $(command_array_to_string "${oscap_args[@]}")" "$SSH_TTY_ALLOCATION_OPTION"
310-
fi
306+
ssh_execute_with_command_and_options "cd $REMOTE_TEMP_DIR; umask 022; ${OSCAP_SUDO[@]} scap $(command_array_to_string "${oscap_args[@]}")" "$SSH_TTY_ALLOCATION_OPTION"
311307
OSCAP_EXIT_CODE=$?
312308
echo "oscap exit code: $OSCAP_EXIT_CODE"
313309

0 commit comments

Comments
 (0)