loggin out automatically

Antonio Cuni TOGLIMIcuni at programmazione.it
Wed Nov 6 15:39:52 EST 2002


trewornan wrote:

> I am responsible for maintaining a PC in a hotel which is available for
> use of guests, basically just e-mail and web browsing. We are currently
> using a program called "timewatcher" which allows me to provide "access
> codes" each code providing a particular period of access - 20, 30, 60
> min or whatever

You could use this script as the default shell for guests; it 
automatically kills bash after a fixed amount of time:

import os
import time
import signal

MAX_LOGIN_TIME = 5 # seconds

pid = os.fork()

if pid == 0:
    # the child
    os.execv('/bin/bash', ['/bin/bash'])
else:
    # the parent
    time.sleep(MAX_LOGIN_TIME)
    os.kill(pid, signal.SIGTERM)

Ciao Anto
-- 
"Computer science is not about computers any more than astronomy
is about telescopes." -- EW Dijkstra



More information about the Python-list mailing list