Bash

From Briki
Revision as of 09:48, 6 September 2006 by 205.228.74.13 (talk) (Force autologout of root and other privileged account shells after inactivity)
Jump to: navigation, search

Force autologout of root and other privileged account shells after inactivity

Add to /etc/profile:
if [ `id -u` -lt 500 ]; then
    # Override console timeout for root and other system users
    TMOUT_ROOT=3600
    if [ -n "$TMOUT" ]; then
        if [ "$TMOUT" -eq "0" -o "$TMOUT" -gt "$TMOUT_ROOT" ]; then
            TMOUT=$TMOUT_ROOT
        fi
    else
        TMOUT=$TMOUT_ROOT
    fi
fi
type declare > /dev/null 2>&1 && declare -r TMOUT

You can probably get rid of the declare line at the bottom - this just ensures that TMOUT cannot subsequently be modified.