Bugzilla (bugzilla.redhat.com) will be under maintenance for infrastructure upgrades and will not be available on July 31st between 12:30 AM - 05:30 AM UTC. We appreciate your understanding and patience. You can follow status.redhat.com for details.
Bug 88981 - "ps" does not consistently translate UIDs to usernames against NIS users
Summary: "ps" does not consistently translate UIDs to usernames against NIS users
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: procps
Version: 7.2
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Daniel Walsh
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-04-15 23:05 UTC by Ross Becker
Modified: 2007-04-18 16:53 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-02-11 13:25:55 UTC


Attachments (Terms of Use)
Patch for output.c file (1.02 KB, patch)
2003-12-18 11:16 UTC, Bhaslinux
no flags Details | Diff

Description Ross Becker 2003-04-15 23:05:22 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2)
Gecko/20030208 Netscape/7.02

Description of problem:
When I am running "ps" to see the process owners in the system, sometimes UIDs
are not translated to usernames. This is becoming a problem as I am having to
institute process monitoring to see who is abusing our systems,  and some
processes are shown with only a UID, other processes are shown using the
username.  We use NIS for distributing our user accounts, so that might be
interacting here. 

Here are some of the other software versions which might be interacting with the
"ps" command.
glibc-2.2.4-19.3
ypbind-1.8-1
pam-0.75-19




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

How reproducible:
Sometimes

Steps to Reproduce:
Here's some snippets showing you what's going on.
[root@stratus root]# ps -ea --format "%p %u %c" | grep rhalbhav | wc -l
      5
[root@stratus root]# ypcat passwd | grep rhalbhav
rhalbhavi:*********:2193:2004:Raj Halbhavi:/home/rhalbhavi:/bin/csh
[root@stratus root]# ps -ea --format "%p %u %c" | grep 2193 | wc -l
     39

After running strace and ltrace on the "ps" command, I cannot determine anything
other than the fact (which I knew) that it's getting it's information from the
/proc filesystem. I cannot find any indication that there is something different
for users that "ps" is not translating UIDs for in the /proc filesystem.

    

Actual Results:  Some processes show up with numeric UIDs, some processes show
up with usernames.

Expected Results:  All processes should show up with usernames

Additional info:

All processes will show full usernames if I only specify ps -ea --format "%p %u"

As soon as I specify ps -ea --format "%p %u %c", some processes get numeric UIDs
instead of usernames. Also, if I use a ps -eaf, I get some usernames, and some UIDs.

The problem seems to occur per-user. If a user is not translating, it will occur
for most or all of that user's processes.

Comment 1 Alexander Larsson 2003-04-16 10:05:37 UTC
I think the problem is the length of the username. If the username is longer
than the column, ps prints the uid instead of a truncated username.



Comment 2 Bhaslinux 2003-12-17 10:40:15 UTC
What Alexander Larsson has stated is right. I am also facing the same 
problem with usernames > 8 chars 

Comment 3 Bhaslinux 2003-12-18 06:18:37 UTC
FIX:
---------------------------------------------------

File: output.c 

The rightward variable stores the value and limits to 8 
Suppose i had 9 chars ( as in bhaslinux ) then i added 1 to it 
which makes it print things properly 

----
1616                 if (fmt->next) 
1617                         max_rightward = fmt->width + 1;
1618                 else
1619                         max_rightward = active_cols - camax + 1;
----

(please see added '1' to it 

Result after this correction
----
[bhaslinux@bhaslinux ps]$ ./ps -f
UID        PID  PPID  C STIME TTY          TIME CMD
bhaslinux 30470 30469  0 11:45 pts/4   00:00:00 bash
bhaslinux 30500 30470  0 11:45 pts/4   00:00:00 ./ps -f


Result before correction ( using /bin/ps ) 
----
UID        PID  PPID  C STIME TTY          TIME CMD
500       30470 30469  0 11:45 pts/4   00:00:00 bash
500       30501 30470  0 11:45 pts/4   00:00:00 ps -f


The final work to be done will be to either remove the
cols check in the line (omit the  (strlen(pp->euser) > max_rightward)
check like 
----
527 pr_euser(void)
528 {
529         if (user_is_number || (strlen(pp->euser) > max_rightward)

which will be a nasty fix 
OR
run through the password file and get the max_rightward as the length 
of the username with maximum chars

But removing the check will be fine as there  are very few people
who will like have extensively long usernames and most of the 
organizations prefer to stop with 8 chars.


Bhasker C V
bhaslinux@yahoo.com

Comment 4 Bhaslinux 2003-12-18 11:16:50 UTC
Created attachment 96600 [details]
Patch for output.c file 

Apply this patch to procps-2.0.11 output.c 

This will truncate the username to 8chars and then display the
username instead of printing the UIDs of the users

Comment 5 Daniel Walsh 2004-02-11 13:25:55 UTC
Fixed in current release


Note You need to log in before you can comment on or make changes to this bug.