I have the following requierements:
- produce audit log when bash session has been terminated by the user (exit)
- produce audit log when bash session has timed out
Those audit logs must be different. I am playing around with the following script trap.sh:
export TMOUT=10
function handle-timeout {
echo "Timeout"
}
function handle-exit {
echo "Exit"
}
trap handle-exit EXIT
Now if I do:
valegon@precision ~ (master) $ bash
valegon@precision ~ (master) $ source trap.sh
valegon@precision ~ (master) $ exit
Exit
It works as expected. If instead, I wait for the timeout to happen:
valegon@precision ~ (master) $ bash
valegon@precision ~ (master) $ source trap.sh
valegon@precision ~ (master) $ timed out waiting for input: auto-logout
Exit
There are two problems here:
- the timeout is triggering EXIT, which I do not want
- I do not know how to trap the timeout specifically
How can I solve these open issues?