From c1123d19cc3d40c0ee66f6ad80efec475720b221 Mon Sep 17 00:00:00 2001 From: Orsiris de Jong Date: Thu, 2 Jul 2015 16:37:05 +0200 Subject: [PATCH] Fixed empty optionnal commands make everything executable --- ssh_filter.sh | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/ssh_filter.sh b/ssh_filter.sh index 2b5bf45..7cdc9b8 100755 --- a/ssh_filter.sh +++ b/ssh_filter.sh @@ -1,6 +1,6 @@ #!/bin/bash -##### Osync ssh command filter build 2015070201 +##### Osync ssh command filter build 2015070202 ##### This script should be located in /usr/local/bin in the remote system to sync / backup ##### It will filter the commands that can be run remotely via ssh. ##### Please chmod 755 and chown root:root this file @@ -46,11 +46,20 @@ case ${SSH_ORIGINAL_COMMAND%% *} in "df") Go ;; "$CMD1") - Go ;; + if [ "$CMD1" != "" ] + then + Go ;; + fi "$CMD2") - Go ;; + if [ "$CMD2" != "" ] + then + Go ;; + fi "$CMD3") - Go ;; + if [ "$CMD3" != "" ] + then + Go ;; + fi "sudo") if [ "$SUDO_EXEC" == "yes" ] then @@ -77,13 +86,22 @@ case ${SSH_ORIGINAL_COMMAND%% *} in Go elif [[ "$SSH_ORIGINAL_COMMAND" == "sudo $CMD1"* ]] then + if [ "$CMD1" != "" ] + then Go + fi elif [[ "$SSH_ORIGINAL_COMMAND" == "sudo $CMD2"* ]] then + if [ "$CMD2" != "" ] + then Go + fi elif [[ "$SSH_ORIGINAL_COMMAND" == "sudo $CMD3"* ]] then + if [ "$CMD3" != "" ] + then Go + fi else Log "Command [$SSH_ORIGINAL_COMMAND] not allowed." exit 1