From 4b7e717da1196e00e9fc2043094a51f700218031 Mon Sep 17 00:00:00 2001 From: redxef Date: Tue, 22 Nov 2022 00:43:16 +0100 Subject: [PATCH] Use subshell for output redirection security. If a command were to be something like `echo a; echo b;` redirection would only happen on the `echo b;` messing up everything. --- src/scripts/put_files.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/scripts/put_files.sh b/src/scripts/put_files.sh index b6de702..b049027 100644 --- a/src/scripts/put_files.sh +++ b/src/scripts/put_files.sh @@ -27,16 +27,16 @@ stdout_file="${STDOUT_FILE}" # dont write anything to stdout, since that would get appended to the tar file if [ "$stderr_file" = "-" ] && [ "$stdout_file" = "-" ]; then # redirect stdout to stderr - ${COMMAND} 1>&2 + ( ${COMMAND} ) 1>&2 elif [ "$stderr_file" != "-" ] && [ "$stdout_file" = "-" ]; then # stderr to file, stdout to stderr - ( ${COMMAND} 2>"$stderr_file" ) 1>&2 + ( ( ${COMMAND} ) 2>"$stderr_file" ) 1>&2 elif [ "$stderr_file" = "-" ] && [ "$stdout_file" != "-" ]; then # stdout to file - ${COMMAND} 1>"$stdout_file" + ( ${COMMAND} ) 1>"$stdout_file" else # both files specified - ${COMMAND} 1>>"$stdout_file" 2>>"$stderr_file" + ( ${COMMAND} ) 1>>"$stdout_file" 2>>"$stderr_file" fi )