]> sourceware.org Git - newlib-cygwin.git/commitdiff
* sec_helper.cc (set_process_privilege): Rename restore_priv to
authorCorinna Vinschen <corinna@vinschen.de>
Wed, 26 Nov 2003 14:29:22 +0000 (14:29 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Wed, 26 Nov 2003 14:29:22 +0000 (14:29 +0000)
priv_luid.

* sec_helper.cc (set_process_privilege): Call LookupPrivilegeValue
before opening the token.

winsup/cygwin/ChangeLog
winsup/cygwin/sec_helper.cc

index a19126aa15630942f96e52b598e20b5fd9deacc7..ad11c505a21e4ed2af737ffc9346828bc341b5e5 100644 (file)
@@ -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
index f0b851be87e21bffa10c90eb41da75c77cabf40d..9d810043135dd48915761991386947c095b3797c 100644 (file)
@@ -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,
This page took 0.03456 seconds and 5 git commands to generate.