es-que / cpuset

Automatically exported from code.google.com/p/cpuset
GNU General Public License v2.0
0 stars 0 forks source link

Process listing fails with getpwuid error if a process runs with an invalid uid. #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. start a process using a uid that is not listed in /etc/passwd (or NIS)
2. List the processes for your cpuset:
    cset proc -s system -l

What is the expected output? What do you see instead?
    Expect a process listing, instead get the following exception:

# cset proc -s system -l
Traceback (most recent call last):
  File "/usr/bin/cset", line 47, in ?
    main()
  File "/usr/lib/python2.4/site-packages/cpuset/main.py", line 228, in main
    command.func(parser, options, args)
  File "/usr/lib/python2.4/site-packages/cpuset/commands/proc.py", line
231, in func
    list_sets(tset)
  File "/usr/lib/python2.4/site-packages/cpuset/commands/proc.py", line
347, in list_sets
    log_detailed_task_table(s, ' ', 78)
  File "/usr/lib/python2.4/site-packages/cpuset/commands/proc.py", line
779, in log_detailed_task_table
    l.extend(task_detail_table(set.tasks, indent, width))
  File "/usr/lib/python2.4/site-packages/cpuset/commands/proc.py", line
768, in task_detail_table
    if width: l.append(istr + task_detail(task, width))
  File "/usr/lib/python2.4/site-packages/cpuset/commands/proc.py", line
716, in task_detail
    out.append(pwd.getpwuid(int(stdict['Uid'].split()[0]))[0][:8].ljust(8))
KeyError: 'getpwuid(): uid not found: 65534'

What version of the product are you using? On what operating system?
   cpuset-1.5.3-3.1.x86_64.rpm installed on RHEL5.4

Please provide any additional information below.

Here's a simple patch (also attached):

--- ./proc.py   2010-03-03 13:13:21.000000000 -0600
+++ /usr/lib/python2.4/site-packages/cpuset/commands/proc.py    2010-03-04
06:58:30.000000000 -0600
@@ -713,7 +713,11 @@
     cmdline = cmdline.replace('\0', ' ')

     out = []
-    out.append(pwd.getpwuid(int(stdict['Uid'].split()[0]))[0][:8].ljust(8))
+    try:
+        uid=pwd.getpwuid(int(stdict['Uid'].split()[0]))[0][:8].ljust(8)
+    except:
+        uid=stdict['Uid'].split()[0][:8].ljust(8)
+    out.append(uid)
     out.append(stdict['Pid'].rjust(5))
     out.append(stdict['PPid'].rjust(5))

Original issue reported on code.google.com by mostro...@gmail.com on 4 Mar 2010 at 1:12

Attachments:

GoogleCodeExporter commented 8 years ago
I'll take a look.  Thanks for the report and patch!

Original comment by tsariou...@gmail.com on 30 Apr 2010 at 2:47

GoogleCodeExporter commented 8 years ago
Hi mostroski: Your patch looks good, I'll apply it.  Sorry for the delay, but I
didn't even know that the project had an issue tracker.... ran into it today by
accident :)  If you email me your name, I'll add you to the credits.  Also, 
tell me
if you don't want your email published in AUTHORS.  My email is
alext|AT|novell|DOT|com Thanks.

Original comment by tsariou...@gmail.com on 30 Apr 2010 at 3:29

GoogleCodeExporter commented 8 years ago
Ok, not heard back, so I will attribute with your handle, "mostroski".  If you 
want
that changed in a subsequent release, please drop me a line.

Closing as fixed in rel_1.5.4

Original comment by tsariou...@gmail.com on 7 May 2010 at 10:36