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:::
This should never be a bug especially on such a basic and time tested command like w
Seems fine here. What version of procps and shadow?
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.
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 ...
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?
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.
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?
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