diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2003-11-26 17:29:22 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2003-11-26 17:29:22 +0300 |
commit | cb55867514230d86e2383f0a52ee8d2c6fd6dd7c (patch) | |
tree | 42212c78aca186c1fe9fcb35954f892af8ac47f9 /winsup | |
parent | 12069cf31bcd401720e1a86b353ac6237b5e29a3 (diff) |
* sec_helper.cc (set_process_privilege): Rename restore_priv to
priv_luid.
* sec_helper.cc (set_process_privilege): Call LookupPrivilegeValue
before opening the token.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 10 | ||||
-rw-r--r-- | winsup/cygwin/sec_helper.cc | 16 |
2 files changed, 18 insertions, 8 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a19126aa1..ad11c505a 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,15 @@ 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. diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc index f0b851be8..9d8100431 100644 --- a/winsup/cygwin/sec_helper.cc +++ b/winsup/cygwin/sec_helper.cc @@ -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, |