[ale] Adding entry to utmp

Chris Fowler cfowler at outpostsentinel.com
Wed Dec 12 16:26:13 EST 2001


I'm creating my own replacement for login.c and I'm am assuming that it is login's responsibility to add entries to /var/run/utmp.  Basically the standard netkit-telnet 
daemon calls my login program via exec().  My login program continues the process of loging in a user.  Below it my utmp code.

        
       struct utmp entry;
        /* Time to write to UTMP */
        entry.ut_type = USER_PROCESS;
        entry.ut_pid = getpid();
        strcpy(entry.ut_line, ttyname(0) + strlen("/dev/"));
        time(&entry.ut_time);
        strcpy(entry.ut_user, user->username);
        memset(entry.ut_host, 0 , UT_HOSTSIZE);
        entry.ut_addr = 0;

        setutent();
        pututline(&entry);
        endutent();

       /* Do some stuff */
       exec("/bin/sh", "/bin/sh", environ);


Output of who  It will be cleaned up.
Users:
user       port              login         idle   host
root       /dev/ports/kvm      Dec 12 13:24  00:04  local
root       ttyp0             Dec 12 13:30         local

Now if I go to another machine and telnet in again I get the following who output
Users:
user       port              login         idle   host
root       /dev/ports/kvm      Dec 12 13:24  00:04  local
root       ttyp1             Dec 12 13:30         local

It appears to have overwritten my last entry and now I have an invisible user.    What did I do wrong?

I also notice that if I exit from the shell on ttyp1 then the entry is removed.  My login does exec()  so it is not removing the
entry.  Who is? Or is a value changed that my Who skips over?

Thanks,
Chris Fowler



---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list