LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-24-2004, 09:39 AM   #1
prell
Member
 
Registered: Jul 2004
Posts: 73

Rep: Reputation: 15
auto logging out users on input timeout


I'm interested in logging out users that have not sent anything to stdin in [x] minutes. Can this be done in Linux?

Our users log in and are sent into a program rather than a typical shell prompt. What I'd like to do is monitor input in a non-polling fashion and log out a user who has not entered anything in [x] minutes.

For fun, I ran ltrace on the program in question, and monitored for "get" commands (getc, etc). I was able to detect the return of some getc( )s, however it seems as though some of the input is retrieved through a forked process. I tried running ltrace on this program with "fork trace" on, and the program dumped and I didn't proceed further.

I assume Linux is suitably equipped to handle this task. Thanks for any input!
 
Old 08-28-2004, 05:57 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Our users log in and are sent into a program rather than a typical shell prompt.
...then they'll use keepalives to thwart your timeout policy :-]
OTOH, if you add a (too short) fixed session timeout they'll stand a chance loosing data.
What application we're talking about (URI?)?
Does it keep per user session state?
Does it allow for interaction?
IOW, can you send users messages?
 
Old 08-28-2004, 10:37 AM   #3
prell
Member
 
Registered: Jul 2004
Posts: 73

Original Poster
Rep: Reputation: 15
It's a third party application that is launched inside of a bash script. So perhaps my initial post was misleading!

Anyway, the application is used to look up account information, and should be receiving input from employees with intervals of inactivity of no longer than a few minutes, I imagine. I do have concerns about it, which you touch upon, but I was asked to look into this by my boss, so here I am.

I was looking around for ways to do this, and didn't really find anything outside the bash "auto-logout" variable, which doesn't take effect until users drop back into the shell. So, I played around with ptrace for a few days, and had a good time and learned some things, but I really don't want to use that solution since wrapping this application on a step-by-step machine instruction basis for 200+ users would put a heavy (and unjustifiable) burden on the system.

I'm thinking that since Linux represents everything as a file, I could somehow listen on /dev/stdin so I could grab any input before this application gets it. This app is "feisty" in that it forks to receive input sometimes. Perhaps, though, I could redirect the standard input to this application so that it gets it from a program I created? Can this be done dynamically like this? Or will the application wait until stdin receives EOF?
 
Old 08-28-2004, 11:30 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If you know the name of the app, or user, you could just use
ps -ef
and check the STIME column (start time) or TIME column (time used).
Or use 'last' cmd and get the start (login) time of each user.

Last edited by chrism01; 08-28-2004 at 11:31 AM.
 
Old 08-30-2004, 09:53 AM   #5
prell
Member
 
Registered: Jul 2004
Posts: 73

Original Poster
Rep: Reputation: 15
listening to file changes?

This morning, I was playing with named pipes and I noticed that the timestamp on the file (or at least the timestamp printed by bash, whatever it may be bound to) was set to the last time the file was written to. I guess this makes sense since that's how it works for "other" files. I suppose I should have thought about this before!

Now to relate it to my predicament: Can I listen to changes being made to this file? I remember reading a while ago that Linux has a way of listening to file and directory changes in a non-polling manner. Is this true? Does anyone know the name of this capability/library?
 
Old 08-30-2004, 10:13 AM   #6
prell
Member
 
Registered: Jul 2004
Posts: 73

Original Poster
Rep: Reputation: 15
It looks like epoll(2) is exactly what I'm looking for, however epoll is not fully functional (or even available, really) in the 2.4 kernel. I need to be able to do this in 2.4, so I guess epoll is out of the question.

Last edited by prell; 08-30-2004 at 10:44 AM.
 
Old 08-31-2004, 07:32 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
How about a FAM based app?
 
Old 09-01-2004, 09:27 AM   #8
prell
Member
 
Registered: Jul 2004
Posts: 73

Original Poster
Rep: Reputation: 15
FAM would be great, but I don't like the idea of installing a kernel module just to do this. Cool project, though!

And it does look like the later 2.4 builds come with epoll, but I don't really want to upgrade the kernel either, though I'd be more willing to do that. However, like I said, the timestamps are always the current time, so I don't know how reliable this method is.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GTK input and timeout joakim12 Programming 1 07-15-2005 03:44 PM
stat=timeout waiting for input during message collect Wimpie22 Linux - Software 0 03-18-2005 02:45 PM
Sendmail: timeout waiting for input from local during Draining Input andrewstr Linux - Software 0 07-14-2004 01:43 PM
xcdroast - cdrecord.mmap: Input/output error. write_g1: scsi sendcmd: cmd timeout masgari Linux - Software 11 03-17-2004 10:55 PM
logging all keyboard input/output to a file div Linux - General 0 02-20-2001 05:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration