Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AccessDenied errors for most operations not owned by my user #280

Closed
giampaolo opened this issue May 23, 2014 · 2 comments
Closed

AccessDenied errors for most operations not owned by my user #280

giampaolo opened this issue May 23, 2014 · 2 comments

Comments

@giampaolo
Copy link
Owner

From kurzedme...@gmail.com on June 11, 2012 22:46:39

What steps will reproduce the problem?  
This code generates AccessDenied exceptions for all operations (except getting 
the PID) on processes not owned by my user in W7 64bits, python 2.7.3 64bits, 
psutil 0.4.1 64bits, even if i have admin rights and the python process is elevated.



import psutil
import logging

logging.basicConfig()
log = logging.getLogger(__name__)

for p in psutil.process_iter():
    if p.pid == 0:
        continue
    process_attributes = list()
    for attribute in ['username', 'pid', 'nice', 'exe']:
        try:
            process_attributes.append(getattr(p, attribute))
        except (psutil.AccessDenied) as err:
            log.error('{}: Trying to access {} of 
{}'.format(err.__class__.__name__,
                                                             attribute, err))
    print process_attributes


Output is something like this:
ERROR:__main__:AccessDenied: Trying to access username of (pid=1636)
ERROR:__main__:AccessDenied: Trying to access nice of (pid=1636)
ERROR:__main__:AccessDenied: Trying to access exe of (pid=1636)
[1636]
ERROR:__main__:AccessDenied: Trying to access username of (pid=2556)
ERROR:__main__:AccessDenied: Trying to access nice of (pid=2556)
ERROR:__main__:AccessDenied: Trying to access exe of (pid=2556)
[2556]
ERROR:__main__:AccessDenied: Trying to access username of (pid=1548)
ERROR:__main__:AccessDenied: Trying to access nice of (pid=1548)
ERROR:__main__:AccessDenied: Trying to access exe of (pid=1548)
[1548]
['MYUSER', 4264, 32, 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe']
ERROR:__main__:AccessDenied: Trying to access username of (pid=3260)
ERROR:__main__:AccessDenied: Trying to access nice of (pid=3260)
ERROR:__main__:AccessDenied: Trying to access exe of (pid=3260)
[3260]
ERROR:__main__:AccessDenied: Trying to access username of (pid=4752)
ERROR:__main__:AccessDenied: Trying to access nice of (pid=4752)
ERROR:__main__:AccessDenied: Trying to access exe of (pid=4752)
[4752]
['MYUSER', 5020, 32, 'C:\\Program Files (x86)\\Mozilla 
Thunderbird\\thunderbird.exe']
['MYUSER', 4796, 32, 'C:\\Program Files (x86)\\GNU\\GnuPG\\gpg-agent.exe']
ERROR:__main__:AccessDenied: Trying to access username of (pid=328)
ERROR:__main__:AccessDenied: Trying to access nice of (pid=328)
ERROR:__main__:AccessDenied: Trying to access exe of (pid=328)
[328]
['MYUSER', 4436, 32, 'C:\\Program Files (x86)\\Mozilla 
Thunderbird\\plugin-container.exe']
['MYUSER', 4492, 32, 'C:\\Python27\\Scripts\\ipython.exe']
ERROR:__main__:AccessDenied: Trying to access exe of (pid=5948)
['MYUSER', 5948, 32]
['MYUSER', 5176, 32, 'C:\\Python27\\python.exe']
['MYUSER', 4676, 128, 'C:\\Program Files\\Process Hacker 2\\ProcessHacker.exe']
['MYUSER', 5100, 32, 'C:\\Windows\\system32\\cmd.exe']
ERROR:__main__:AccessDenied: Trying to access exe of (pid=5660)
['MYUSER', 5660, 32]
['MYUSER', 5696, 32, 'C:\\Python27\\python.exe']
['MYUSER', 2852, 32, 'C:\\Python27\\python.exe']


I got curious what process 5660 was...
'\??\C:\Windows\system32\conhost.exe 
"-819514783406431421117177328-3794250371789057852-943298914-27174460378563238 '
That's the commandline ProcessHacker got. 

What is the expected output?  
Information about each process in the system, like ProcessHacker do when i 
elevate it. 

What do you see instead?  
No information except PID, like ProcessHacker would do when it isn't elevated. 

What version of psutil are you using? What Python version?  
python 2.7.3 64bits, psutil 0.4.1 64bits 

On what operating system? Is it 32bit or 64bit version?  
W7 64bits

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

@giampaolo
Copy link
Owner Author

From g.rodola on June 12, 2012 08:59:43

Yes, I'm aware of this and I don't know any workaround.
AFAIK, process hacker is able to determine those information because it is 
installed as a driver or something like that, something which shouldn't be 
easily suitable for a Python module.

Cc: wj32...@gmail.com
Labels: OpSys-Windows

@giampaolo
Copy link
Owner Author

From g.rodola on June 21, 2012 09:35:24

Closing out as won't fix.

Status: WontFix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant