From 7c0b8bae2612b4f2b0a4c310d7663323ef5e658d Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Wed, 29 Jan 2020 05:19:19 +0100 Subject: [PATCH] mail_wrap_script.sh: secure output log and allow multiple simultaneous instances --- mail_wrap_script.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mail_wrap_script.sh b/mail_wrap_script.sh index 7b11349..09aa395 100755 --- a/mail_wrap_script.sh +++ b/mail_wrap_script.sh @@ -4,11 +4,16 @@ SCRIPT=$1 shift -$SCRIPT "$@" 2>&1 | tee /tmp/backup.log +FILE_ID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1) + +touch /tmp/$FILE_ID.log +chmod a-rwx,u+r /tmp/$FILE_ID.log + +$SCRIPT "$@" 2>&1 | tee /tmp/$FILE_ID.log ERR=$? -OUTPUT=$(cat /tmp/backup.log) -rm /tmp/backup.log +OUTPUT=$(cat /tmp/$FILE_ID.log) +rm /tmp/$FILE_ID.log if [ $ERR -ne 0 ]; then MAILTO=$(cat "$HOME/.admin_mail")