Catching user switching and getting current active user from root on linux
Tim Chase
python.list at tim.thechases.com
Sat Dec 11 16:01:52 EST 2010
On 12/11/2010 01:43 PM, mpnordland wrote:
> it's on linux, and current active user is the user currently
> using the computer. My program needs to switch log files when
> a different user starts using the computer.
The problem is that multiple users can be logged on at the same
time. You might be able to come up with a solution that works
for a small set of use-cases, but I admin several Linux boxes
where multiple people can be logged-in at the same time. There
are also some multi-head arrangements (multiple
keyboards/mice/monitors and sometimes even sound-cards attached
to the same motherboard) and people can log into each "terminal"
(if you will) concurrently, all on the same box. So if I'm using
the computer, and a co-worker logs in, I'm still using it at the
same time you might catch the "new user logged in" event.
Watching wtmp (or possibly /var/log/auth) can capture the "hey,
somebody logged in" event, but that doesn't mean that other
previous users are done with their sessions.
-tkc
More information about the Python-list
mailing list