Blame SOURCES/autofs-5.1.1-add-type-to-struct-lookup_mod.patch

306fa1
autofs-5.1.1 - add type to struct lookup_mod
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
Add opened map type field to struct lookup_mod for module comparison
306fa1
during reinit.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 daemon/module.c     |   18 ++++++++++++++++++
306fa1
 include/automount.h |    1 +
306fa1
 2 files changed, 19 insertions(+)
306fa1
306fa1
diff --git a/daemon/module.c b/daemon/module.c
306fa1
index 3bd7a0c..d9921f4 100644
306fa1
--- a/daemon/module.c
306fa1
+++ b/daemon/module.c
306fa1
@@ -61,6 +61,7 @@ int open_lookup(const char *name, const char *err_prefix, const char *mapfmt,
306fa1
 	char buf[MAX_ERR_BUF];
306fa1
 	char fnbuf[PATH_MAX];
306fa1
 	size_t size;
306fa1
+	char *type;
306fa1
 	void *dh;
306fa1
 	int *ver;
306fa1
 
306fa1
@@ -75,10 +76,20 @@ int open_lookup(const char *name, const char *err_prefix, const char *mapfmt,
306fa1
 		return NSS_STATUS_UNAVAIL;
306fa1
 	}
306fa1
 
306fa1
+	type = strdup(name);
306fa1
+	if (!type) {
306fa1
+		free(mod);
306fa1
+		if (err_prefix) {
306fa1
+			char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
306fa1
+			logerr("%s%s", err_prefix, estr);
306fa1
+		}
306fa1
+	}
306fa1
+
306fa1
 	size = snprintf(fnbuf, sizeof(fnbuf),
306fa1
 			"%s/lookup_%s.so", AUTOFS_LIB_DIR, name);
306fa1
 	if (size >= sizeof(fnbuf)) {
306fa1
 		free(mod);
306fa1
+		free(type);
306fa1
 		if (err_prefix) {
306fa1
 			char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
306fa1
 			logerr("%s%s", err_prefix, estr);
306fa1
@@ -91,6 +102,7 @@ int open_lookup(const char *name, const char *err_prefix, const char *mapfmt,
306fa1
 			logerr("%scannot open lookup module %s (%s)",
306fa1
 			       err_prefix, name, dlerror());
306fa1
 		free(mod);
306fa1
+		free(type);
306fa1
 		return NSS_STATUS_UNAVAIL;
306fa1
 	}
306fa1
 
306fa1
@@ -101,6 +113,7 @@ int open_lookup(const char *name, const char *err_prefix, const char *mapfmt,
306fa1
 			     err_prefix, name);
306fa1
 		dlclose(dh);
306fa1
 		free(mod);
306fa1
+		free(type);
306fa1
 		return NSS_STATUS_UNAVAIL;
306fa1
 	}
306fa1
 
306fa1
@@ -114,14 +127,18 @@ int open_lookup(const char *name, const char *err_prefix, const char *mapfmt,
306fa1
 			logerr("%slookup module %s corrupt", err_prefix, name);
306fa1
 		dlclose(dh);
306fa1
 		free(mod);
306fa1
+		free(type);
306fa1
 		return NSS_STATUS_UNAVAIL;
306fa1
 	}
306fa1
 
306fa1
 	if (mod->lookup_init(mapfmt, argc, argv, &mod->context)) {
306fa1
 		dlclose(dh);
306fa1
 		free(mod);
306fa1
+		free(type);
306fa1
 		return NSS_STATUS_NOTFOUND;
306fa1
 	}
306fa1
+
306fa1
+	mod->type = type;
306fa1
 	mod->dlhandle = dh;
306fa1
 	*lookup = mod;
306fa1
 
306fa1
@@ -145,6 +162,7 @@ int close_lookup(struct lookup_mod *mod)
306fa1
 {
306fa1
 	int rv = mod->lookup_done(mod->context);
306fa1
 	dlclose(mod->dlhandle);
306fa1
+	free(mod->type);
306fa1
 	free(mod);
306fa1
 	return rv;
306fa1
 }
306fa1
diff --git a/include/automount.h b/include/automount.h
306fa1
index ab3e360..3ea2381 100644
306fa1
--- a/include/automount.h
306fa1
+++ b/include/automount.h
306fa1
@@ -301,6 +301,7 @@ struct lookup_mod {
306fa1
 	lookup_read_map_t lookup_read_map;
306fa1
 	lookup_mount_t lookup_mount;
306fa1
 	lookup_done_t lookup_done;
306fa1
+	char *type;
306fa1
 	void *dlhandle;
306fa1
 	void *context;
306fa1
 };