ps and username size
Lombard, David N
dnlombar at ichips.intel.com
Wed Jan 9 15:31:01 PST 2008
On Wed, Jan 09, 2008 at 09:01:44PM +0100, Cristian Ionescu-Idbohrn wrote:
> On Tue, 8 Jan 2008, Cristian Ionescu-Idbohrn wrote:
>
> > > > The current svn chops of long usernames to 8 chars. That may create
> > > > confusion if the output from ps is in any way used to identify
> > > > process owners. Users:
> > > >
> > > > 'longnameA' and 'longnameB' will both be displayed as 'longname'.
> > > >
> > > > Please consider replacing usernames longer than 8 chars with the
> > > > corresponding uids. That will make them unique in the ps list.
> > >
> > > Good idea.
> >
> > Super. I made an attempt in a previous sent patch to do just that.
> > It probably just passed unnoticed :(
Just to be sure, this doesn't guarantee unique output. An integer string
is a perfectly valid username, both on a full distro and bb/uc (just tested
both). It may be quite demented, but this is legal in /etc/passwd:
42:...:100:100:user 42:/home/42:/bin/sh
frederick:...:42:100:some user:/home/frederick:/bin/sh
So, when ps displays "42", which is it? Here's an example of the proposed
patch w/ ssh logins by "42" and "frederick"
~ # ps
PID Uid VSZ Stat Command
1 root 508 S init
...
87 root 504 S udhcpc -n -s /sbin/udhcpc.script
97 root 528 S dropbear -j
101 root 512 R -sh
106 root 508 S /bin/sh /sbin/acpid
108 root 584 S dropbear -j
109 42 508 S -sh
114 root 584 S dropbear -j
115 42 508 S -sh
121 root 508 R ps
~ #
Without the patch, pid 115 is written as:
115 frederick 508 S -sh
As noted, the full procps version creates equally confused output:
4 S root 27060 2997 0 75 0 - 1105 wait 15:24 pts/4 00:00:00 su - 4242
4 S 4242 27063 27060 0 83 0 - 1095 - 15:24 pts/4 00:00:00 -bash
4 S root 27108 27089 0 75 0 - 1106 wait 15:24 pts/5 00:00:00 su - frederick
4 S 4242 27112 27108 0 85 0 - 1095 - 15:24 pts/5 00:00:00 -bash
Again, this is truly a corner case, and I'm quite happy to argue any confusion
is richly deserved...
--
David N. Lombard, Intel, Irvine, CA
I do not speak for Intel Corporation; all comments are strictly my own.
More information about the busybox
mailing list