* sec_helper.cc (set_process_privilege): Rename restore_priv to
priv_luid. * sec_helper.cc (set_process_privilege): Call LookupPrivilegeValue before opening the token.
This commit is contained in:
parent
12069cf31b
commit
cb55867514
|
@ -1,3 +1,13 @@
|
|||
2003-11-26 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* sec_helper.cc (set_process_privilege): Rename restore_priv to
|
||||
priv_luid.
|
||||
|
||||
2003-11-26 Pierre Humblet <pierre.humblet@ieee.org>
|
||||
|
||||
* sec_helper.cc (set_process_privilege): Call LookupPrivilegeValue
|
||||
before opening the token.
|
||||
|
||||
2003-11-26 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* dir.cc (mkdir): Use local security_descriptor. Call
|
||||
|
|
|
@ -329,11 +329,17 @@ int
|
|||
set_process_privilege (const char *privilege, bool enable, bool use_thread)
|
||||
{
|
||||
HANDLE hToken = NULL;
|
||||
LUID restore_priv;
|
||||
LUID priv_luid;
|
||||
TOKEN_PRIVILEGES new_priv, orig_priv;
|
||||
int ret = -1;
|
||||
DWORD size;
|
||||
|
||||
if (!LookupPrivilegeValue (NULL, privilege, &priv_luid))
|
||||
{
|
||||
__seterrno ();
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((use_thread
|
||||
&& !OpenThreadToken (GetCurrentThread (), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES,
|
||||
0, &hToken))
|
||||
|
@ -345,14 +351,8 @@ set_process_privilege (const char *privilege, bool enable, bool use_thread)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (!LookupPrivilegeValue (NULL, privilege, &restore_priv))
|
||||
{
|
||||
__seterrno ();
|
||||
goto out;
|
||||
}
|
||||
|
||||
new_priv.PrivilegeCount = 1;
|
||||
new_priv.Privileges[0].Luid = restore_priv;
|
||||
new_priv.Privileges[0].Luid = priv_luid;
|
||||
new_priv.Privileges[0].Attributes = enable ? SE_PRIVILEGE_ENABLED : 0;
|
||||
|
||||
if (!AdjustTokenPrivileges (hToken, FALSE, &new_priv,
|
||||
|
|
Loading…
Reference in New Issue