Difference between revisions of "Bash"

From Briki
Jump to: navigation, search
 
(Force autologout of root and other privileged account shells after inactivity)
Line 14: Line 14:
 
type declare > /dev/null 2>&1 && declare -r TMOUT
 
type declare > /dev/null 2>&1 && declare -r TMOUT
 
</pre>
 
</pre>
 +
You can probably get rid of the ''declare'' line at the bottom - this just ensures that ''TMOUT'' cannot subsequently be modified.

Revision as of 10:48, 6 September 2006

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.