diff options
author | Robin Hack <hack.robin@gmail.com> | 2015-01-23 15:12:43 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2015-01-28 17:17:07 +0100 |
commit | b21106a1a1c940151d2e56608aea35dab714b773 (patch) | |
tree | 76eec6202919262e6c42ff0426f6301bf18dbce5 /lib | |
parent | 199b7b7fe87b32daa599b61c595d3148e407861d (diff) | |
download | samba-b21106a1a1c940151d2e56608aea35dab714b773.tar.gz samba-b21106a1a1c940151d2e56608aea35dab714b773.tar.xz samba-b21106a1a1c940151d2e56608aea35dab714b773.zip |
uid_wrapper: Fix race condition - uwrap_init.
Patch moves uwrap_id_mutex before if (uwrap.initialised) statement
which can be passed by concurrent threads.
Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/uid_wrapper/uid_wrapper.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/uid_wrapper/uid_wrapper.c b/lib/uid_wrapper/uid_wrapper.c index 772dc93616..578977dadc 100644 --- a/lib/uid_wrapper/uid_wrapper.c +++ b/lib/uid_wrapper/uid_wrapper.c @@ -575,17 +575,16 @@ static void uwrap_init(void) const char *env = getenv("UID_WRAPPER"); pthread_t tid = pthread_self(); - - + UWRAP_LOCK(uwrap_id); if (uwrap.initialised) { struct uwrap_thread *id = uwrap_tls_id; int rc; if (id != NULL) { + UWRAP_UNLOCK(uwrap_id); return; } - UWRAP_LOCK(uwrap_id); id = find_uwrap_id(tid); if (id == NULL) { rc = uwrap_new_id(tid, true); @@ -605,8 +604,6 @@ static void uwrap_init(void) UWRAP_LOG(UWRAP_LOG_DEBUG, "Initialize uid_wrapper"); - UWRAP_LOCK(uwrap_id); - uwrap.initialised = true; uwrap.enabled = false; |