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
set_security_attribute appropriately.
* external.cc (cygwin_internal): Ditto.
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))
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,