Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 40512 - System information command "w" reports strange amount of logged in time
Summary: System information command "w" reports strange amount of logged in time
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-05 12:13 UTC by Jibie
Modified: 2005-02-10 22:01 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jibie 2004-02-05 12:13:59 UTC
first i created a new user as follows
useradd groggy -m -G users -s /bin/bash
then i set the passwd with passwd groggy
and logged into groggy
then in the root console i ran the command 
>w
to see what was up
groggy   pts/1     15:04   12453days  0.02s  0.02s -bash
this is basically a few seconds into the connect and keeps up for the first minute
I tried the same procedure on other distributions and didnt see such a thing and it looks like its echoing the number in /etc/shadow
groggy:$1$M0A/qhxo$TY9tf0xE5W6zZ9dwzXOxC/:12453:0:99999:7:::

any idea why this is so and how it should be fixed? it should say 1 or 2 secs like it does on other distros i think this might be a build or configuration problem




Reproducible: Always
Steps to Reproduce:
1.create new user >useradd groggy -m -G users -s /bin/bash
2.set passwd
3.log into groggy
4.in separate connection i ran >w

Actual Results:  
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
groggy   pts/1     15:04   12453days  0.02s  0.02s -bash

Expected Results:  
it should show the actual idle time of 0.00
This idle time actually starts to get calculated after the first minute

it seems to be echoing the number in /etc/shadow
groggy:$1$M0A/qhxo$TY9tf0xE5W6zZ9dwzXOxC/:12453:0:99999:7:::
Comment 1 Jibie 2004-02-05 12:15:01 UTC
This should never be a bug especially on such a basic and time tested command like w
Comment 2 Martin Schlemmer (RETIRED) gentoo-dev 2004-02-08 05:53:25 UTC
Seems fine here.  What version of procps and shadow?
Comment 3 Jibie 2004-02-08 09:35:03 UTC
i'm using the Gentoo GRP image posted on the ibiblio servers
procps-3.1.9

Timing is important as this bug only shows up during the first minute of the login and it doesnt show if the new user is logged at a console terminal. (vc/1 or something)

I got several other gentoo users to verify it. So i'm not seeing things :-D

I poked through w.c and it looks like it's doing what would be the correct thing by looking at struct stat. 

I use ssh to get into the system so the user is logged in through a pts so I think this just might be an error in what the pts does right after login possibly it updates the idle time correctly after the first minute but doesnt set it initially or sets in incorrectly? It becomes correct after that. So maybe it isn't with the w command but maybe with the pts driver? I'm thinking the contents of struct stat is wrong which is what is causing this.

Just throwing out ideas. But first you need to replicate the error otherwise you can't fix it. 
Comment 4 Martin Schlemmer (RETIRED) gentoo-dev 2004-02-08 20:26:41 UTC
I wonder if its not a kernel problem with pty's and the first minute?  I
do not get this for normal tty's, and the code is sane ...
Comment 5 Jibie 2004-02-09 16:06:31 UTC
have you been able to replicate it? different kernel versions? i'm using 2.4.20

In any case I'm no expert on linux kernel code so I'll follow along and hopefully this will get fixed soon. I tried looking through the kernel source but I'm not sure where to look... pty.c?
Comment 6 Jibie 2004-02-09 16:51:43 UTC
did some more digging used stat on the user as soon as it was created and look what i found for a new user called lissy logged into pts/1

used the following to create this
date;stat /dev/pts/1;w;grep lissy /etc/shadow

Mon Feb  9 19:28:31 EST 2004
  File: `/dev/pts/1'
  Size: 0               Blocks: 0          IO Block: 1024   Character Device
Device: 8h/8d   Inode: 827         Links: 1     Device type: 88,1
Access: (0620/crw--w----)  Uid: ( 1001/   lissy)   Gid: (    5/     tty)
Access: 1969-12-31 19:00:00.000000000 -0500  *----Note this
Modify: 2004-02-09 19:28:17.000000000 -0500
Change: 2004-02-09 19:28:16.000000000 -0500

 19:28:31 up 1 day, 53 min,  2 users,  load average: 0.01, 0.03, 0.03
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0     19:06    0.00s 21.85s  0.01s -bash
lissy    pts/1     19:28   12458days  0.05s  0.05s -bash

lissy:$1$krJonFR9$OsWdZosZzqJel2CHqbpoM.:12458:0:99999:7:::

As to why it's using the password last modified for idle time that's beyond me but apparently the inode is created wrongly so the w.c code is fine. 

I took a look at the code in /usr/src/linux/fs/devpts/ . But i'm not really sure what's going on in there. Or if there is a subtle bug in some pointer math, because most of the assignment code does something like this where it sets mtime=ctime=atime=currenttime as one would expect.

Hope this simplifies the search.  
Comment 7 Martin Schlemmer (RETIRED) gentoo-dev 2004-02-15 12:30:17 UTC
Same thing for 2.4.17.  I will try to have a look when I have time.  Any other
x86 kernel devs with more spare time?
Comment 8 SpanKY gentoo-dev 2005-02-10 22:01:28 UTC
just tested a bunch of 2.6 machines and they all showed correct times:
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
vapier   pts/0     00:56    0.00s  0.06s  0.03s w