autofs-5.0.1 - fix libxml2 non-thread-safe calls From: Ian Kent <raven@themaw.net> The libxml2 call xmlCleanupParser() is definitely not thread safe. This patch moves it and the xmlInitParser() call to the location of the code to workaround the libxml2 incorrect TSD handling so they are called only at start and at exit. --- daemon/Makefile | 5 +++++ daemon/automount.c | 11 ++++++++--- modules/lookup_ldap.c | 2 -- 3 files changed, 13 insertions(+), 5 deletions(-) --- autofs-5.0.1.orig/daemon/Makefile +++ autofs-5.0.1/daemon/Makefile @@ -22,6 +22,11 @@ CFLAGS += -DVERSION_STRING=\"$(version)\ LDFLAGS += -rdynamic LIBS = -ldl +ifeq ($(LDAP), 1) + CFLAGS += $(XML_FLAGS) + LIBS += $(XML_LIBS) +endif + all: automount automount: $(OBJS) $(AUTOFS_LIB) --- autofs-5.0.1.orig/daemon/automount.c +++ autofs-5.0.1/daemon/automount.c @@ -41,6 +41,7 @@ #include "automount.h" #ifdef LIBXML2_WORKAROUND #include <dlfcn.h> +#include <libxml/parser.h> #endif const char *program; /* Initialized with argv[0] */ @@ -2112,10 +2113,12 @@ int main(int argc, char *argv[]) exit(1); } -#ifdef LIBXML2_WORKAROUND +#if defined(WITH_LDAP) && defined(LIBXML2_WORKAROUND) void *dh_xml2 = dlopen("libxml2.so", RTLD_NOW); if (!dh_xml2) dh_xml2 = dlopen("libxml2.so.2", RTLD_NOW); + if (dh_xml2) + xmlInitParser(); #endif if (!master_read_master(master_list, age, 0)) { @@ -2147,9 +2150,11 @@ int main(int argc, char *argv[]) } closelog(); -#ifdef LIBXML2_WORKAROUND - if (dh_xml2) +#if defined(WITH_LDAP) && defined(LIBXML2_WORKAROUND) + if (dh_xml2) { + xmlCleanupParser(); dlclose(dh_xml2); + } #endif close_ioctl_ctl(); --- autofs-5.0.1.orig/modules/lookup_ldap.c +++ autofs-5.0.1/modules/lookup_ldap.c @@ -822,7 +822,6 @@ int parse_ldap_config(unsigned logopt, s return -1; } - xmlInitParser(); doc = xmlParseFile(auth_conf); if (!doc) { error(logopt, MODPREFIX @@ -994,7 +993,6 @@ int parse_ldap_config(unsigned logopt, s out: xmlFreeDoc(doc); - xmlCleanupParser(); if (fallback) return 0;