Public bug reported:

Log into tty1, then tty2 and then log out of both.  Now run a w command
and you should see something similar to the following;

[EMAIL PROTECTED]:~/source/procps-3.2.7/proc$ w
 10:39:09 up 33 days, 23:11,  4 users,  load average: 1.31, 0.62, 0.39
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
mac     tty7     :0               11Jan08  4:34m  7:24m 36.02s x-session-manager
mac     pts/1    :0.0             08:54    0.00s  0.19s  0.00s w

It shows that 4 users are logged in.  Obviously this is wrong.  I wrote
a small C utility to hack out what w and uptime get as information from
utmp.


#include <string.h>
#include <stdlib.h>
#include <pwd.h>
#include <unistd.h>
#include <utmp.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
  struct utmp *utmpstruct;
  struct utmp entry;

  //system("echo before adding entry:;who");

  setutent();
  //pututline(&entry);
  while ((utmpstruct = getutent())){
        if ((utmpstruct->ut_type == USER_PROCESS) && (utmpstruct->ut_name[0] != 
'\0'))
        printf(utmpstruct->ut_line);
        printf("\t");
        printf("%d",utmpstruct->ut_pid);
        printf("\n");
  }
  endutent();
  return 0;
}

You'll get an output like this

[EMAIL PROTECTED]:~$ ./a.out 
        0
        50
        4305
        4306
tty2    14989
        4312
tty1    4313
        4314
tty7    30255
        0
pts/1   9712
        0
        0
        0
        0
        0
        20929
        14914
        15034

However, running the following , to try to find the pid for the tty1
process, gives;

[EMAIL PROTECTED]:~/source/procps-3.2.7/proc$ ps aux | grep 4313
mac     15524  0.0  0.0   2988   768 pts/1    R+   10:42   0:00 grep 4313
[EMAIL PROTECTED]:~/source/procps-3.2.7/proc$ 

This is obviously wrong, utmp still has the old process id's associated
as being logged in.

Running the following gives the new tty pid

[EMAIL PROTECTED]:~/source/procps-3.2.7/proc$ ps aux | grep tty1
root     14914  0.0  0.0   1692   516 tty1     Ss+  10:33   0:00 /sbin/getty 
38400 tty1
mac     15605  0.0  0.0   2988   764 pts/1    R+   10:44   0:00 grep tty1
[EMAIL PROTECTED]:~/source/procps-3.2.7/proc$ 

There is now a new pid for tty1

** Affects: ubuntu
     Importance: Undecided
         Status: New

-- 
utmp not cleared on tty logout
https://bugs.launchpad.net/bugs/183729
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to