Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Way to automagically log a session when logging in?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Thiemo
Tux's lil' helper
Tux's lil' helper


Joined: 20 Nov 2002
Posts: 138

PostPosted: Tue Feb 02, 2010 7:49 am    Post subject: Way to automagically log a session when logging in? Reply with quote

Hi all,

is there a way to log everything a user does after he has logged in automagically? I think of something like 'script session_$(date +'%Y%m%dT%H%m%S').log', however I am not sure whether this can be used as 'login shell'.

Cheers

Thiemo
_________________
root ist die wurzel allen uebels
Back to top
View user's profile Send private message
geki
Advocate
Advocate


Joined: 13 May 2004
Posts: 2387
Location: Germania

PostPosted: Tue Feb 02, 2010 9:12 am    Post subject: Reply with quote

I would try a shell wrapper for 'script session_$(date +'%Y%m%dT%H%m%S').log' like
Quote:
#!/bin/bash

# log shell session
script session_$(date +'%Y%m%dT%H%m%S').log
or the alternative of a C wrapper.
_________________
hear hear
Back to top
View user's profile Send private message
Thiemo
Tux's lil' helper
Tux's lil' helper


Joined: 20 Nov 2002
Posts: 138

PostPosted: Tue Feb 02, 2010 10:56 am    Post subject: Reply with quote

And then put the wrapper as login shell in /etc/passwd? Might work, but it looks quite aweful to me. I mean, is this not a feature the big players like AIX, Solaris should have standardized for there high profile production system...

I just forgot to see whether bash or zsh can do the logging right away (not only the history stuff)!

geki wrote:
I would try a shell wrapper for 'script session_$(date +'%Y%m%dT%H%m%S').log' like
Quote:
#!/bin/bash

# log shell session
script session_$(date +'%Y%m%dT%H%m%S').log
or the alternative of a C wrapper.

_________________
root ist die wurzel allen uebels
Back to top
View user's profile Send private message
Thiemo
Tux's lil' helper
Tux's lil' helper


Joined: 20 Nov 2002
Posts: 138

PostPosted: Wed Feb 03, 2010 8:59 am    Post subject: Reply with quote

I put a call of script into .zshrc checking if the log file variable at the beginning was already set and if not, setting it. This prevents inifinite recursion.

Caveat of this solution is that sftp sessions do not get logged.

Thiemo wrote:
And then put the wrapper as login shell in /etc/passwd? Might work, but it looks quite aweful to me. I mean, is this not a feature the big players like AIX, Solaris should have standardized for there high profile production system...

I just forgot to see whether bash or zsh can do the logging right away (not only the history stuff)!

geki wrote:
I would try a shell wrapper for 'script session_$(date +'%Y%m%dT%H%m%S').log' like
Quote:
#!/bin/bash

# log shell session
script session_$(date +'%Y%m%dT%H%m%S').log
or the alternative of a C wrapper.

_________________
root ist die wurzel allen uebels
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum