Skip to content

An InsufficientPrivilegesError exception is needed #21

Closed
@giampaolo

Description

From billiej...@gmail.com on February 23, 2009 18:11:52

What steps will reproduce the problem?  
Windows:

1. Log in as a limited user (not Administrator)
2. Attempt to fetch some information from a process owned by a
high-privileged user:

>>> import psutil
>>> p = psutil.Process(1016)  # svchost.exe owned by "SYSTEM" 
>>> p.name
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python26\Lib\site-packages\psutil\psutil.py", line 106, in name
    self.deproxy()
  File "C:\Python26\Lib\site-packages\psutil\psutil.py", line 65, in deproxy
    self._procinfo = _platform_impl.get_process_info(self._procinfo.pid)
  File "C:\Python26\Lib\site-packages\psutil\_psmswindows.py", line 17, in
get_process_info
    infoTuple = _psutil_mswindows.get_process_info(pid)
WindowsError: [Error 5] Access denied
>>>



Linux:

1. Log in as a limited user
2. Attempt to kill a process owned by root (fetching process info is
permitted):

user@ubuntu:~$ whoami
user
user@ubuntu:~$ python
Python 2.4.6 (#1, Jan 26 2009, 11:40:33)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> p = psutil.Process(1)
>>> p.name
'init'
>>> p.kill()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.4/site-packages/psutil/psutil.py", line 136,
in kill
    _platform_impl.kill_process(self.pid, sig)
  File "/usr/local/lib/python2.4/site-packages/psutil/_pslinux.py", line
67, in kill_process
    os.kill(pid, sig)
OSError: [Errno 1] Operation not permitted 

What is the expected output?  


What do you see instead?  
I expect a unique psutil.InsufficientPrivilegesError exception to be raised
on all systems instead of OSError, WindowsError or anything else.
*When* exactly raising the exception (e.g. when instantiating the class or
when accessing properties) needs to be discussed.

Original issue: http://code.google.com/p/psutil/issues/detail?id=21

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions