rachiele@nadc.arpa (05/08/87)
I am in need of an automatic logout program for unix sys V (2.2) running on a VAX785. By this I mean, some software which will logout inactive users after some set amount of idle time. Can anyone help me out? Thanks. Jim rachiele@nadc.arpa
gwyn@brl-smoke.ARPA (Doug Gwyn ) (05/08/87)
In article <7305@brl-adm.ARPA> rachiele@nadc.arpa writes: >I am in need of an automatic logout program for unix sys V (2.2) running on >a VAX785. By this I mean, some software which will logout inactive >users after some set amount of idle time. Can anyone help me out? This comes up every so often. The general answer is, there is no good way to determine that a user has really abandoned his terminal. He might be staring at the file he printed while he works out what to do next, or he might be running a downloaded application that only occasionally needs to access the host. Some versions of the Bourne shell have a TIMEOUT variable that you can set to the number of minutes for the shell to wait after a PS1 prompt before giving up on the user interactive input and terminating the shell. If you enable some such feature, please provide the users with a way of disabling it (e.g. by setting TIMEOUT=0).
wmf@chinet.UUCP (Bill Fischer) (05/10/87)
In article <7305@brl-adm.ARPA> rachiele@nadc.arpa writes: > >I am in need of an automatic logout program for unix sys V (2.2) running on >a VAX785. By this I mean, some software which will logout inactive Rich $alz, moderator of mod.sources (now known as comp.sources.) recently posted a index of the sources posted to date. One of the sources posted was untamo[2-3] which handles idle user logout against a specified set of circumstances. -- +-----------------------------------------------------------------------------+ | Bill Fischer "When the gods wish to punish us, | | ...!ihnp4!chinet!wmf they answer our prayers." - Oscar Wilde | +-----------------------------------------------------------------------------+
asgard@cpro.UUCP (J.R. Stoner) (05/10/87)
in article <999@chinet.UUCP>, wmf@chinet.UUCP (Bill Fischer) says: -> In article <7305@brl-adm.ARPA> rachiele@nadc.arpa writes: ->>I am in need of an automatic logout program for unix sys V (2.2) running on ->>a VAX785. By this I mean, some software which will logout inactive -> Rich $alz, moderator of mod.sources (now known as comp.sources.) recently -> posted a index of the sources posted to date. One of the sources posted -> was untamo[2-3] which handles idle user logout against a specified set -> of circumstances. Incomplete. The untamo posting will work ONLY with BSD systems. What rachiele@nadc.arpa wants is a SYS5 version of the same functionality. -- "To prevent having to tell fools to RTFM don't let on you WTFM to begin with." J.R. Stoner asgard@cpro.UUCP asgard@wotan.UUCP P.S. I help CompuPro make computers. They do not help me make my opinions.
mangler@cit-vax.Caltech.Edu (System Mangler) (05/11/87)
In article <7305@brl-adm.ARPA> rachiele@nadc.arpa writes: >I am in need of an automatic logout program for unix sys V (2.2) running on When our computing center installed an idle timeout on their terminal switch, it took very little time for the students to figure out how to defeat it. "In Use" programs were rampant. No matter how sophisticated your idle logout daemon, it can be defeated. If nothing else, the user can plunk a paperweight on some auto-repeating key on his terminal. If there are no auto-repeat keys, there are still interesting things one can do with answerback messages (on VMS, try setting the answerback to ^E. Fun) I hope you have enough CPU cycles to still get some work done after the idle-daemon defeaters take their toll. Buy yourself a used Able DH/DM instead; they're cheap, and very good. Don Speck speck@vlsi.caltech.edu {seismo,rutgers,ames}!cit-vax!speck
mechjgh@tness1.UUCP (8753) (05/12/87)
In article <7305@brl-adm.ARPA>, rachiele@nadc.arpa writes: > > I am in need of an automatic logout program for unix sys V (2.2) running on > a VAX785. By this I mean, some software which will logout inactive > users after some set amount of idle time. Can anyone help me out? > Thanks. > Jim > rachiele@nadc.arpa Here is the source for hogs.c which I wrote specifically for our VAX 785 with S5R2. It ignores the root login, handles users that are on sxt pseudo ports, and has an anti-logoff file for special users. The code isn't state-of-the-art, but neither am I ! It's your's to try. Greg Hackney -----<cut here>----- /* hogs.c Greg Hackney 8-16-86 ihnp4!tness1!mechjgh * Southwestern Bell Telephone Co. (713+521-8753) * 3100 Main, Room 1009 * Houston, Texas 77001 * * to compile: make hogs * * run as root in cron to kill idle users * as often as desired (tested on AT&T S5R2 only) * * Usage: hogs -t time-in-minutes [ -f Anti_Kill_File ] * i.e.: hogs -t 30 -f /etc/antikill (to kill users idle for 30 minutes or more) * * Typical crontab entry: * 0,15,30,45 * * * * /etc/hogs -t 30 -f /etc/antikill * * optional Anti_Kill_File may contain a vertical list of * lognames to be made exempt from the kill * * * This is considered public domain software and not for resale */ #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <utmp.h> #include <string.h> #include <termio.h> #include <fcntl.h> #define USAGE "Usage: hogs -t time-in-mins [ -f Anti_Kill_File ]" extern char *optarg; FILE *anti; int DEV, DEBUG; #define YES 1 #define NO 0 char *malloc(); time_t ktime; /*minutes of grace allowed before kill*/ long now; /*number of clock ticks since 1-1-70 AD (after dec)*/ struct utmp *getutent(); struct utmp *READ; struct stat statbuf; struct termio term; char *string; char antifile[40], /*pathname to antikill exemption file*/ Device[20]; /*pathname to users tty*/ int aflag; main(argc,argv) int argc; char *argv[]; { int c; DEBUG=NO; if(argc < 2){ fprintf(stderr,"%s\n",USAGE); exit(1); } while((c=getopt(argc,argv,"dt:f:"))!=EOF){ switch(c){ case 'f': aflag=YES; strcpy(antifile,optarg); break; case 't': /*get cutoff time*/ ktime=atol(optarg); break; case 'd': DEBUG = YES; break; default: fprintf(stderr,"%s\n",USAGE); exit(1); break; } } if((string=malloc(512))==NULL){ fprintf(stderr,"Memory allocation error\n"); exit(1); } if(aflag==YES){ /*if antikill file requested with -f option*/ if((anti=fopen(antifile,"r"))==NULL) aflag=NO; } /*get current time*/ now=time((long *)0); while((READ = getutent() )!=NULL){ if(READ->ut_type != USER_PROCESS) /*look for user process*/ continue; /*get idle time for the device*/ strcpy(Device,"/dev/"); strcat(Device,READ->ut_line); stat(Device,&statbuf); if(((now - statbuf.st_mtime)/60) < ktime) /*skip active users*/ continue; if(aflag == YES) /*if antikill file is open*/ if(nokill() == YES) continue; /*an exempt user*/ /*don't ever kill console*/ if((strcmp("root",READ->ut_user))==0) continue; /* sxt devices */ if((strncmp("sxt\0",READ->ut_line,3))==0){ if((kill(READ->ut_pid,1)) != -1) if((kill(READ->ut_pid,0)) != -1) if((kill(READ->ut_pid,9)) != -1) ; continue; } /*hang up modem*/ if((DEV=open(Device,O_RDWR))==-1) continue; if((ioctl(DEV,TCGETA,&term))==-1){ close(DEV); continue; } if(DEBUG == NO){ /*initiate hangup*/ term.c_cflag &= ~CBAUD; term.c_cflag |= B0 & CBAUD; } if((ioctl(DEV,TCSETAW,&term))==-1){ close(DEV); continue; } close(DEV); KILLALL(); /*obliterate the hog's processes !!!*/ } fclose(anti); /*be neat and tidy*/ exit(0); } nokill() /*if user is exempt, return YES, else NO */ { rewind(anti); while((fgets(string,512,anti))!=NULL){ string=strtok(string,"\n"); if((strcmp(string,READ->ut_user))==0) return(YES); } return(NO); } KILLALL() /* kill all processes associated with a given tty*/ { FILE *ps; char buf[512]; sprintf(buf,"/bin/nohup /bin/ps -t %s\0",READ->ut_line); if((ps=popen(buf,"r"))==NULL) return(1); fgets(buf,512,ps); while((fgets(buf,512,ps))!=NULL){ string=strtok(buf," "); if(DEBUG == YES) printf("kill process %s\n",string); else kill(atoi(string),1); if((kill(READ->ut_pid,0))==0) kill(READ->ut_pid,9); } pclose(ps); } ----<cut here>-----