Univention Bugzilla – Bug 33923
Traceback in top module when uid is unknown
Last modified: 2015-09-09 13:58:51 CEST
I tried my best to reproduce this, but I failed. See the bottom for what we got as feedback. Looks as if the Uid of the process was removed in the meantime or (look at the number) that somehow Uid and Gid swapped. Anyone knows how to run a process with one's Gid as Uid? Anyway, "except KeyError: continue" would _hide_ such a problem. The real cause remains unknown (to me). The processlist is generated by os.listdir('/proc'), the uid is found in /proc/%s/status, line "Uid:". Execution of command 'top/query' has failed: Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/univention/management/console/modules/__init__.py", line 204, in execute func( request ) File "/usr/lib/pymodules/python2.6/univention/management/console/modules/decorators.py", line 178, in _response return function(self, request) File "/usr/lib/pymodules/python2.6/univention/management/console/modules/top/__init__.py", line 63, in query listEntry['user'] = process.username File "/usr/lib/pymodules/python2.6/psutil/__init__.py", line 238, in username self._procinfo.username = pwd.getpwuid(self.uid).pw_name KeyError: 'getpwuid(): uid not found: 5025'
(In reply to Dirk Wiesenthal from comment #0) > Anyone knows how to run a process with one's Gid as Uid? Clarification: Uids normally start with 1000, Gids with 5000. So it seems as if not the Uid, but the Gid was used as Uid. But this is only a guess.
Reported again, again a Uid > 5000: Traceback: Die Ausführung des Kommandos top/query ist fehlgeschlagen: Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/univention/management/console/modules/__init__.py", line 204, in execute func( request ) File "/usr/lib/pymodules/python2.6/univention/management/console/modules/decorators.py", line 178, in _response return function(self, request) File "/usr/lib/pymodules/python2.6/univention/management/console/modules/top/__init__.py", line 63, in query listEntry['user'] = process.username File "/usr/lib/pymodules/python2.6/psutil/__init__.py", line 238, in username self._procinfo.username = pwd.getpwuid(self.uid).pw_name KeyError: 'getpwuid(): uid not found: 5109' Remark: In der UMC auf "Prozesse" geklickt.
maybe there is a broken process with wrong uid: cat <<<"#include <unistd.h> int main() { setuid(12345); char* envp[1]={0}; execle("/usr/bin/python","python",(char*)0,envp); }" > fakeuid.c && gcc fakeuid.c -o fake && ./fake → UMC traceback
Reported again: Ticket #2014092521000292
Reported again, 4.0-0 errata0 (Walle) Remark: Ich wollte mir eine Übersicht über die aktuell laufenden Prozesse mit dem Admin User machen.
It could be that this issue has been resolved in the psutil itself: > root@ucs-6489:~# rgrep getpwuid /usr/share/pyshared/psutil/ > /usr/share/pyshared/psutil/__init__.py: return pwd.getpwuid(self.uids.real).pw_name I would opt for waiting for more feedback with a more recent UCS version.
(In reply to Alexander Kläser from comment #6) > It could be that this issue has been resolved in the psutil itself: → No, i don't think so. We received this traceback with UCS 4.0 which is already a never version. We can also just catch the exception without reproducing it. For the QA it can be reproduced with the script from comment #3.
The UCS 4.0-0 traceback: Die Ausführung des Kommandos top/query ist fehlgeschlagen: Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/univention/management/console/modules/__init__.py", line 176, in _decorated return function(self, request, *args, **kwargs) File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 188, in _response return function(self, request) File "/usr/lib/pymodules/python2.7/univention/management/console/modules/top/__init__.py", line 62, in query listEntry['user'] = process.username File "/usr/lib/pymodules/python2.7/psutil/__init__.py", line 369, in username return pwd.getpwuid(self.uids.real).pw_name KeyError: 'getpwuid(): uid not found: 3000051'
Reported again, 3.2-4 errata277
Reported again, 4.0-1 errata82 (Walle)
It would be fixed in python-psutil "2.2.0", we currently have python-psutil "0.7.0". The behavior from psutil has been integrated into the UMC module. Fixed: r59100 univention-management-console-module-top (4.1.0-4) * Bug #33923: Use process uid as process username if the uid can not be resolved by the system. YAML: r59117
Reproduces with: cat <<<' #include <unistd.h> int main() { setuid(12345); char* envp[1]={0}; execle("/bin/cat","<b>cat</b>",(char*)0,envp); }' > fakeuid.c && gcc fakeuid.c -o fake && ./fake Fix: OK Code-Review: OK YAML: OK
<http://errata.univention.de/ucs/4.0/133.html>
This was btw https://github.com/giampaolo/psutil/issues/547 Fix in psutil 2.2.0: https://github.com/giampaolo/psutil/commit/4dfb4ad8ac0f312c68bf5cececcd3fdd694fcccb