uwrap: Fix a deadlock if uid_wrapper is not enabled
authorAndreas Schneider <asn@samba.org>
Fri, 21 Jul 2017 06:28:50 +0000 (08:28 +0200)
committerAndreas Schneider <asn@samba.org>
Fri, 21 Jul 2017 15:19:24 +0000 (17:19 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
src/uid_wrapper.c

index bbd2c17b207fe9b0d71995fc586be5c8f10dee89..5e2b9ee612c79fd1e1fa25de04a127e625181def 100644 (file)
@@ -887,13 +887,13 @@ static void uwrap_thread_prepare(void)
 {
        struct uwrap_thread *id = uwrap_tls_id;
 
+       UWRAP_LOCK_ALL;
+
        /* uid_wrapper is loaded but not enabled */
        if (id == NULL) {
                return;
        }
 
-       UWRAP_LOCK_ALL;
-
        /*
         * What happens if another atfork prepare functions calls a uwrap
         * function? So disable it in case another atfork prepare function
@@ -909,6 +909,7 @@ static void uwrap_thread_parent(void)
 
        /* uid_wrapper is loaded but not enabled */
        if (id == NULL) {
+               UWRAP_UNLOCK_ALL;
                return;
        }
 
@@ -924,6 +925,7 @@ static void uwrap_thread_child(void)
 
        /* uid_wrapper is loaded but not enabled */
        if (id == NULL) {
+               UWRAP_UNLOCK_ALL;
                return;
        }