ldb-samba: require pid match for cached ldb
authorGary Lockyer <gary@catalyst.net.nz>
Tue, 13 Mar 2018 03:43:54 +0000 (16:43 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 Apr 2018 03:15:17 +0000 (05:15 +0200)
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
lib/ldb-samba/ldb_wrap.c

index 53255556e7c96d2d56b06c8ff487dfc860364598..143e128d5d771ed77f254e721ea26ca9c159d1e4 100644 (file)
@@ -94,6 +94,8 @@ static struct ldb_wrap {
                /* the context is what we use to tell if two ldb
                 * connections are exactly equivalent
                 */
+               pid_t pid; /* We want to re-open in a new PID due to
+                           * the LMDB backend */
                const char *url;
                struct tevent_context *ev;
                struct loadparm_context *lp_ctx;
@@ -186,10 +188,12 @@ char *wrap_casefold(void *context, void *mem_ctx, const char *s, size_t n)
                                   struct cli_credentials *credentials,
                                   unsigned int flags)
 {
+       pid_t pid = getpid();
        struct ldb_wrap *w;
        /* see if we can re-use an existing ldb */
        for (w=ldb_wrap_list; w; w=w->next) {
-               if (w->context.ev == ev &&
+               if (w->context.pid == pid &&
+                   w->context.ev == ev &&
                    w->context.lp_ctx == lp_ctx &&
                    w->context.session_info == session_info &&
                    w->context.credentials == credentials &&
@@ -249,6 +253,7 @@ int samba_ldb_connect(struct ldb_context *ldb, struct loadparm_context *lp_ctx,
                return false;
        }
 
+       c.pid          = getpid();
        c.url          = url;
        c.ev           = ev;
        c.lp_ctx       = lp_ctx;