diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2018-04-12 09:43:12 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2018-04-12 09:43:12 +0200 |
commit | e206c39bb6bf91808dbcd2cfbd572525825982cd (patch) | |
tree | 385b7472d0212dc14f83f7adb5173dc6bb711c59 /winsup/cygwin | |
parent | 5d99256613ccbdf4dfe7ea5f01d11f0bc4775326 (diff) | |
download | newlib-e206c39bb6bf91808dbcd2cfbd572525825982cd.zip newlib-e206c39bb6bf91808dbcd2cfbd572525825982cd.tar.gz newlib-e206c39bb6bf91808dbcd2cfbd572525825982cd.tar.bz2 |
Cygwin: fix guard checking for current user's AuthZ context
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/sec_helper.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc index 3478360..a1d8cba 100644 --- a/winsup/cygwin/sec_helper.cc +++ b/winsup/cygwin/sec_helper.cc @@ -821,12 +821,16 @@ authz_ctx::get_user_attribute (mode_t *attribute, PSECURITY_DESCRIPTOR psd, if (RtlEqualSid (user_sid, cygheap->user.sid ()) && !cygheap->user.issetuid ()) { + /* Avoid lock in default case. */ if (!user_ctx_hdl) { authz_guard.acquire (); - if (!AuthzInitializeContextFromToken (0, hProcToken, authz, NULL, - authz_dummy_luid, NULL, - &user_ctx_hdl)) + /* Check user_ctx_hdl again under lock to avoid overwriting + user_ctx_hdl if it has already been initialized. */ + if (!user_ctx_hdl + && !AuthzInitializeContextFromToken (0, hProcToken, authz, NULL, + authz_dummy_luid, NULL, + &user_ctx_hdl)) debug_printf ("AuthzInitializeContextFromToken, %E"); authz_guard.release (); } |