Bash

From Briki
Revision as of 10:30, 7 September 2006 by 205.228.73.12 (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/bash.bashrc (not /etc/profile, or it will only be set when running su - and not su):
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.