Bug 75002

Summary: ps -ef shows uid not username
Product: [Retired] Red Hat Linux Reporter: ethane <ethan+redhat>
Component: procpsAssignee: Alexander Larsson <alexl>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: low Docs Contact:
Priority: medium    
Version: 7.3CC: kevin_myer
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-10-03 15:27:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description ethane 2002-10-03 15:27:16 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 
1.0.3705)

Description of problem:
When issuing "ps" commands, such as ps -ef usernames that are longer than 8 
characters show as a uid, instead of an username.  Other utilities such 
as "top", or "id" display correctly. Example:
--------------------
[kabdullah@myhost kabdullah]$ ps -ef
Snip-->
1974      1717  1713  2 08:21 pts/0    00:00:00 -bash
1974      1757  1717  0 08:21 pts/0    00:00:00 ps -ef
<--Snip
[kabdullah@myhost kabdullah]$ id
uid=1974(kabdullah) gid=100(users) groups=100(users)
------------------

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.Create account longer then 8 characters
2.Login as said account
3.Issue "ps -ef | grep bash"
4.Notice uid, not username in first column

Actual Results:  n/a

Expected Results:  n/a

Additional info:

I originally believed it to be an NIS incompatibility, since this user is an 
NIS user, from a Solaris server.  But I created a local username "username2", 
and found the same behavior.

Comment 1 Alexander Larsson 2002-10-08 14:00:32 UTC
This is a feature, not a bug. If you're parsing ps output you can't rely on a
username if it can be truncated, so it's printed as a uid instead.

Comment 2 Kevin M. Myer 2002-11-12 15:48:52 UTC
So let me see if I have this logic right:

if uid<=8, display username,
else display numeric uid.

If I'm parsing ps output, I'd say returning a numeric uid is just as bad as
returning a truncated username (in other words, the whole USER field can't be
relied on in ps output, unless usernames are less than 8 characters).  Since
you're not enforcing an 8 character username anywhere that I can find, it would
seem that the proper response would be to modify ps to support >8 character
usernames.  If I'm not mistaken, useradd supports usernames up to 256
characters.  What am I missing here??

At the very least, I'd like to see a command line option to force display of >8
character usernames.  Ideally, I'd like to see the USER column expanded to at
least 16 characters (actually making it dynamically grow to the length of the
longest username would be great but I know terminals are only 80 characters wide
too...)  Times have changed - its unreasonble to believe that usernames are < 8
characters so lets update our utilities output and embrace that fact :)

If the problem is that scripts will break, then quoting from the procps NEWS:

"Scripts that make assumptions about character position are and
were broken because fields may overflow. Scripts should parse by
whitespace and use -o to get the best results."

My sentiments exactly..

Kevin (who just wants to easily see who has a connection to our netatalk server
by running ps, instead of having to run ps, then do an ldapsearch for that
numeric uid...)

PS:  Anyone perusing these reports who wants to see more of the username, simply
patch procps-2.0.X/ps/output.c:  find the line that reads {"user",      "USER",
   pr_euser,    sr_euser,   8,   0,    U98, USER}, /* BSD n forces this to UID */

and change the 8 to whatever length you want the username to appear as.  You
might have to use the "w" switch with ps to get wide screen output as the
command field might get truncated but this is far better for me than the current
behaviour - hrm feature request for 8.1??

Comment 3 Alexander Larsson 2002-11-12 17:05:25 UTC
If you really want this you have to ask for an opinion upstream. Mail to
procps-list. (More info at http://www.surriel.com/procps/).

I can't make these kind of changes in the stuff i package. It would make it
incompatible with upstream.