Blob Blame History Raw
diff --git a/daemon/automount.c b/daemon/automount.c
index e9cae4e..3d6a703 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -986,6 +986,8 @@ static void *do_read_master(void *arg)
 	if (status)
 		fatal(status);
 
+	defaults_read_config();
+
 	status = master_read_master(master, age, readall);
 
 	master->reading = 0;
diff --git a/lib/master.c b/lib/master.c
index da05bb6..637ce04 100644
--- a/lib/master.c
+++ b/lib/master.c
@@ -1169,6 +1169,10 @@ int master_mount_mounts(struct master *master, time_t age, int readall)
 			continue;
 		}
 
+		master_source_writelock(this);
+		lookup_close_lookup(ap);
+		master_source_unlock(this);
+
 		cache_readlock(nc);
 		ne = cache_lookup_distinct(nc, this->path);
 		if (ne && this->age > ne->age) {
diff --git a/modules/cyrus-sasl.c b/modules/cyrus-sasl.c
index 8821f84..9aac792 100644
--- a/modules/cyrus-sasl.c
+++ b/modules/cyrus-sasl.c
@@ -528,6 +528,7 @@ sasl_do_kinit(struct lookup_context *ctxt)
 	return 0;
 
 out_cleanup_unparse:
+	krb5cc_in_use--;
 	krb5_free_unparsed_name(ctxt->krb5ctxt, tgs_name);
 out_cleanup_cc:
 	status = pthread_mutex_lock(&krb5cc_mutex);
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index 49a9a9b..2baf8b8 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -174,7 +174,7 @@ LDAP *init_ldap_connection(struct lookup_context *ctxt)
 static int get_query_dn(LDAP *ldap, struct lookup_context *ctxt, const char *class, const char *key)
 {
 	char buf[PARSE_MAX_BUF];
-	char *query, *dn;
+	char *query, *dn, *qdn;
 	LDAPMessage *result = NULL, *e;
 	struct ldap_searchdn *sdns = NULL;
 	char *attrs[2];
@@ -225,15 +225,18 @@ static int get_query_dn(LDAP *ldap, struct lookup_context *ctxt, const char *cla
 
 	if (!ctxt->base) {
 		sdns = defaults_get_searchdns();
-		if (sdns)
+		if (sdns) {
+			if (ctxt->sdns)
+				defaults_free_searchdns(ctxt->sdns);
 			ctxt->sdns = sdns;
+		}
 	}
 
-	if (!sdns)
+	if (!ctxt->sdns)
 		rv = ldap_search_s(ldap, ctxt->base,
 				   scope, query, attrs, 0, &result);
 	else {
-		struct ldap_searchdn *this = sdns;
+		struct ldap_searchdn *this = ctxt->sdns;
 
 		debug(LOGOPT_NONE, MODPREFIX
 			      "check search base list");
@@ -269,7 +272,6 @@ static int get_query_dn(LDAP *ldap, struct lookup_context *ctxt, const char *cla
 	if (e) {
 		dn = ldap_get_dn(ldap, e);
 		debug(LOGOPT_NONE, MODPREFIX "query dn %s", dn);
-		ldap_msgfree(result);
 	} else {
 		debug(LOGOPT_NONE,
 		      MODPREFIX "query succeeded, no matches for %s",
@@ -278,7 +280,16 @@ static int get_query_dn(LDAP *ldap, struct lookup_context *ctxt, const char *cla
 		return 0;
 	}
 
-	ctxt->qdn = dn;
+	qdn = strdup(dn);
+	ldap_memfree(dn);
+	ldap_msgfree(result);
+	if (!qdn)
+		return 0;
+
+	if (ctxt->qdn)
+		free(ctxt->qdn);
+
+	ctxt->qdn = qdn;
 
 	return 1;
 }
@@ -1018,7 +1029,7 @@ static void free_context(struct lookup_context *ctxt)
 	if (ctxt->mapname)
 		free(ctxt->mapname);
 	if (ctxt->qdn)
-		ldap_memfree(ctxt->qdn);
+		free(ctxt->qdn);
 	if (ctxt->server)
 		free(ctxt->server);
 	if (ctxt->cur_host)
@@ -1600,14 +1611,14 @@ static int lookup_one(struct autofs_point *ap,
 	}
 	query[ql] = '\0';
 
-	debug(ap->logopt,
-	      MODPREFIX "searching for \"%s\" under \"%s\"", query, ctxt->qdn);
-
 	/* Initialize the LDAP context. */
 	ldap = do_connect(ctxt);
 	if (!ldap)
 		return CHE_FAIL;
 
+	debug(ap->logopt,
+	      MODPREFIX "searching for \"%s\" under \"%s\"", query, ctxt->qdn);
+
 	rv = ldap_search_s(ldap, ctxt->qdn, scope, query, attrs, 0, &result);
 
 	if ((rv != LDAP_SUCCESS) || !result) {