diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2004-03-13 21:11:13 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2004-03-13 21:11:13 +0300 |
commit | 5817840adfff858867a0b9dfec089a2b67751cb9 (patch) | |
tree | 806c978a8667f7fc9e5160a8c6e7f1f7ab549713 /winsup/utils/kill.cc | |
parent | 2e93c97146c56855dbf88d4d1ba9cd7ceaf4ab45 (diff) |
* kill.cc (get_debug_priv): New function.
(forcekill): Call get_debug_priv before trying to kill process.
Diffstat (limited to 'winsup/utils/kill.cc')
-rw-r--r-- | winsup/utils/kill.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/winsup/utils/kill.cc b/winsup/utils/kill.cc index a4dba050d..deb0b41a3 100644 --- a/winsup/utils/kill.cc +++ b/winsup/utils/kill.cc @@ -125,9 +125,38 @@ listsig (const char *in_sig) } } +static void +get_debug_priv (void) +{ + HANDLE tok; + LUID luid; + TOKEN_PRIVILEGES tkp; + + if (!OpenProcessToken (GetCurrentProcess (), + TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &tok)) + return; + + if (!LookupPrivilegeValue (NULL, SE_DEBUG_NAME, &luid)) + { + CloseHandle (tok); + return; + } + + tkp.PrivilegeCount = 1; + tkp.Privileges[0].Luid = luid; + tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + + AdjustTokenPrivileges (tok, FALSE, &tkp, sizeof tkp, NULL, NULL); + + CloseHandle (tok); +} + static void __stdcall forcekill (int pid, int sig, int wait) { + // try to acquire SeDebugPrivilege + get_debug_priv(); + external_pinfo *p = (external_pinfo *) cygwin_internal (CW_GETPINFO_FULL, pid); DWORD dwpid = p ? p->dwProcessId : (DWORD) pid; HANDLE h = OpenProcess (PROCESS_TERMINATE, FALSE, (DWORD) dwpid); @@ -254,3 +283,4 @@ out: } return ret; } + |