Skip to content

Commit

Permalink
Fixed issues with EL6 and simplified scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-vaughan committed Jul 25, 2018
1 parent 146ab5d commit 797cb1e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
27 changes: 11 additions & 16 deletions doc/profile.d/tlog.csh
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,30 @@
# limitations under the License.
#
set TLOG_USERS="/etc/security/tlog.users"
set TLOG_CMD="/usr/bin/tlog-rec-session"

if ( -f "$TLOG_USERS" ) then
if ( ! ($?TLOG_RUNNING) ) then

set D='$'
set PATTERN="^(%$GROUP|$USER)$D"
set MATCH=`grep -E "$PATTERN" "$TLOG_USERS"`
set TLOG_D='$'
set TLOG_PATTERN="^(%$GROUP|$USER)$TLOG_D"
set TLOG_MATCH=`grep -E "$TLOG_PATTERN" "$TLOG_USERS"`

if ( "$MATCH" != "" ) then
if ( "$TLOG_MATCH" != "" ) then
setenv TLOG_RUNNING true

setenv TLOG_REC_SESSION_SHELL $SHELL

set CMD="/usr/bin/tlog-rec-session"

set PATTERN='-c .\+'
set PASSTHROUGH_CMD=`ps --no-headers -o args $$ | grep -oe "$PATTERN"`

if ($?prompt || $?loginsh) then
set CMD="$CMD -l"
set TLOG_CMD="$TLOG_CMD -l"
endif

if ( "$PASSTHROUGH_CMD" != "" ) then
set CMD="$CMD $PASSTHROUGH_CMD"
else
set CMD="exec $CMD"
endif
set TLOG_PATTERN='-c[[:space:]]\+.\+'
set TLOG_PASSTHROUGH_CMD=`ps --no-headers -o args $$ | grep -oe "$TLOG_PATTERN"`

$CMD
if ( "$TLOG_PASSTHROUGH_CMD" == "" ) then
exec $TLOG_CMD
endif
endif
endif
endif
38 changes: 22 additions & 16 deletions doc/profile.d/tlog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,38 @@
# limitations under the License.
#
TLOG_USERS="/etc/security/tlog.users"
TLOG_CMD="/usr/bin/tlog-rec-session"

if [ -f "${TLOG_USERS}" ]; then
if [ -z "$TLOG_RUNNING" ]; then
MATCH=`grep -E "^(%${GROUP}|${USER})$" "${TLOG_USERS}"`
tlog_parent(){
retval=1

if [ -n "$MATCH" ]; then
export TLOG_RUNNING=true
readonly TLOG_RUNNING
ppid=`ps --no-headers -o ppid $1`

TLOG_REC_SESSION_SHELL=$SHELL
if [ $ppid -gt 1 ]; then
if `ps --no-headers -o ppid,args $1 | grep -q 'tlog-rec-session'`; then
return 0
else
tlog_parent $ppid
retval=$?
fi

CMD="/usr/bin/tlog-rec-session"
fi

PASSTHROUGH_CMD=`ps --no-headers -o args $$ | grep -oe "-c .\+"`
return $retval
}

if [ -f "${TLOG_USERS}" ]; then
if ! `tlog_parent $PPID`; then
if `grep -qE "^(%${GROUP}|${USER})$" "${TLOG_USERS}"`; then
if [[ $- == *i* ]] || `shopt -q login_shell`; then
CMD="$CMD -l"
TLOG_CMD="${TLOG_CMD} -l"
fi

if [ -n "$PASSTHROUGH_CMD" ]; then
CMD="$CMD $PASSTHROUGH_CMD"
else
CMD="exec $CMD"
fi
if ! `ps --no-headers -o args $$ | grep -qe "-c[[:space:]]\+.\+"`; then
TLOG_REC_SESSION_SHELL=$SHELL

$CMD
exec $TLOG_CMD
fi
fi
fi
fi

0 comments on commit 797cb1e

Please sign in to comment.