From 1e5c10f963f077bd4463eac2c7719c2367c7adce Mon Sep 17 00:00:00 2001 From: Marc Schoechlin Date: Tue, 10 Sep 2013 13:24:29 +0200 Subject: [PATCH] Bugfix --- helpers/recordshell | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/helpers/recordshell b/helpers/recordshell index c4722ff..68dabc2 100755 --- a/helpers/recordshell +++ b/helpers/recordshell @@ -3,10 +3,25 @@ LOGDIR="/var/log/recordshell" LOGGING_PID="$$" FILEPREFIX="$LOGDIR/$(date '+%Y-%m-%d')/$(date '+%Y-%m-%d_%H-%M-%S')-$LOGGING_PID"; -EXTRA_ARGS="-c 'su -c /bin/bash $SUDO_USER'" - CFG_FILE="/etc/recordshell" +TARGET_USER="$1" + +#EXTRA_ARGS="-c 'su -c \"/bin/bash -l\" - $TARGET_USER'" +EXTRA_ARGS="-c 'su -s /bin/bash - $TARGET_USER'" + +if [ "`whoami`" != "root" ];then + set -x + exec sudo $0 "`whoami`" + set +x +fi + + +if [ -z "$TARGET_USER" ];then + echo "$0 " + exit 1 +fi + if ( bash $CFG_FILE &> /dev/null );then source $CFG_FILE; else @@ -27,7 +42,8 @@ fi echo "*********************************" logger -s -t recordshell "[$LOGGING_PID] Starting logged shell session: ${FILEPREFIX}/{typescript,timing} $SUDO_MSG" set -x -script $EXTRA_ARGS -e -q -f -t ${FILEPREFIX}/typescript 2>${FILEPREFIX}/timing + +eval script $EXTRA_ARGS -e -q -f -t ${FILEPREFIX}/typescript 2>${FILEPREFIX}/timing set +x logger -s -t recordshell "[$LOGGING_PID] Finished logged shell session: ${FILEPREFIX}/{typescript,timing} $SUDO_MSG" echo "*********************************"