jamesa@dadla.UUCP (James Akiyama) (07/19/85)
This is a program which allows a user to set and maintain a specified idle time on his tty. The default (giving no parameters) sets the idle time to zero every 10 minutes. It is useful for those who need to maintain control on their idle time without being present at their terminals. To use the program one types: setidle [idle time] [update time] I hope this finds use with some of you out there. --------CUT HERE----------------------------------------------------------- #include <stdio.h> #include <sys/types.h> main(argc,argv) int argc; char **argv; { long now; long idle[2]; long i; int k; nice(20); if (argc == 1) { i = 0; k = 600; } else if (argc == 3) { sscanf(argv[1],"%d",&i); sscanf(argv[2],"%d",&k); } else { fprintf(stderr,"Useage: setidle [idle time] [update time]\n"); exit(1); } while (getppid() != 1) { time(&now); idle[0] = now - i; idle[1] = now - i; utime(ttyname(1),idle); sleep(k); } exit(0); }
notes@ucf-cs.UUCP (07/25/85)
>This is a program which allows a user to set and maintain a specified idle >time on his tty. The default (giving no parameters) sets the idle time to >zero every 10 minutes. It is useful for those who need to maintain control >on their idle time without being present at their terminals. So who needs to do that? Generally, users who want to circumvent an automatic logout program. I have such a program here and I have a set of users who sometimes rambunctiously attempt to circumvent such controls by using programs like this one. So in retaliation, I offer the following diff representing a 4.2bsd kernel change to disallow this kind of thing. The file is ufs_syscalls.c. (We use RCS, so line numbers may differ from yours.) *** /tmp/,RCSt1001235 Wed Jul 24 12:29:27 1985 --- /tmp/,RCSt2001235 Wed Jul 24 12:29:30 1985 *************** *** 20,25 /* * $Log: ufs_syscalls.c,v $ * Revision 1.1 84/09/25 10:01:00 root * Initial revision * --- 20,29 ----- /* * $Log: ufs_syscalls.c,v $ + * Revision 1.2 84/09/25 11:54:59 root + * Fixed to disallow utimes() calls to modify char special device + * times for non-super-user. + * * Revision 1.1 84/09/25 10:01:00 root * Initial revision * *************** *** 651,656 if ((ip = owner(1)) == NULL) return; u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)); if (u.u_error == 0) { ip->i_flag |= IACC|IUPD|ICHG; --- 655,665 ----- if ((ip = owner(1)) == NULL) return; + /* no utimes on char spec. devices except superuser */ + if ((ip->i_ic.ic_mode & IFCHR) && !suser()) { + u.u_error = EACCES; + goto utbad; + } u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)); if (u.u_error == 0) { ip->i_flag |= IACC|IUPD|ICHG; *************** *** 656,661 ip->i_flag |= IACC|IUPD|ICHG; iupdat(ip, &tv[0], &tv[1], 0); } iput(ip); } --- 665,671 ----- ip->i_flag |= IACC|IUPD|ICHG; iupdat(ip, &tv[0], &tv[1], 0); } + utbad: iput(ip); } ---------------- Ben Goldfarb University of Central Florida uucp: {decvax,akgua}!ucf-cs!goldfarb ARPA: goldfarb.ucf-cs@csnet.relay.CSNET csnet: goldfarb@ucf.CSNET BITNET: goldfarb@ucf2vm.BITNET
peter@kitty.UUCP (Peter DaSilva) (07/31/85)
> >This is a program which allows a user to set and maintain a specified idle > >time on his tty.... > > So who needs to do that? Generally, users who want to circumvent an > automatic logout program... If you have a terminal that can be convinced to respond to a string (like a VT100 or equivalent) you can always send that string every 10 minutes & then do a read. Implementation is left to the reader. I am tempted to flame you for putting up an autologout program. Reminds me of a mod at berkeley known as the "Fascist File System" (really, that was the official name!). But since I don't know your circumstances I won't.