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

Process SE DEBUG mode is not set on Windows #1429

Merged
merged 7 commits into from
Feb 25, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
comments
  • Loading branch information
giampaolo committed Feb 25, 2019
commit 194930a9f57782b7cd4baa1b1124ddd1c909fc16
14 changes: 7 additions & 7 deletions psutil/arch/windows/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ psutil_set_privilege(HANDLE hToken, LPCTSTR Privilege, BOOL bEnablePrivilege) {
return 1;
}

// second pass. set privilege based on previous setting
// Second pass. Set privilege based on previous setting.
tpPrevious.PrivilegeCount = 1;
tpPrevious.Privileges[0].Luid = luid;

Expand Down Expand Up @@ -99,11 +99,10 @@ psutil_get_thisproc_token() {


static void
psutil_handle_error() {
psutil_print_err() {
char *msg = "psutil module couldn't set SE DEBUG mode for this process; " \
"please file an issue against psutil bug tracker";
if (PSUTIL_DEBUG)
psutil_debug(msg);
psutil_debug(msg);
if (GetLastError() != ERROR_ACCESS_DENIED)
PyErr_WarnEx(PyExc_RuntimeWarning, msg, 1);
PyErr_Clear();
Expand All @@ -123,13 +122,14 @@ psutil_set_se_debug() {
int err = 1;

if ((hToken = psutil_get_thisproc_token()) == NULL) {
psutil_handle_error();
// "return 1;" to get an exception
psutil_print_err();
return 0;
}

// enable SeDebugPrivilege (open any process)
if (psutil_set_privilege(hToken, SE_DEBUG_NAME, TRUE) != 0) {
psutil_handle_error();
// "return 1;" to get an exception
psutil_print_err();
}

RevertToSelf();
Expand Down