* kill.cc (get_debug_priv): New function.

(forcekill): Call get_debug_priv before trying to kill process.
This commit is contained in:
Corinna Vinschen 2004-03-13 18:11:13 +00:00
parent 2e93c97146
commit 5817840adf
2 changed files with 35 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2004-03-13 Rob Siklos <rob2@siklos.ca>
* kill.cc (get_debug_priv): New function.
(forcekill): Call get_debug_priv before trying to kill process.
2004-02-24 Christopher Faylor <cgf@redhat.com>
* cygpath.cc (long_options): Add "mode" option.

View File

@ -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;
}