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