|
|
6bbd11 |
autofs-5.0.8 - fix map source with type lookup
|
|
|
6bbd11 |
|
|
|
6bbd11 |
From: Ian Kent <raven@themaw.net>
|
|
|
6bbd11 |
|
|
|
6bbd11 |
If the map source type is specified the map name must be a full
|
|
|
6bbd11 |
path.
|
|
|
6bbd11 |
|
|
|
6bbd11 |
But we should be able to give a plain map name and expect autofs
|
|
|
6bbd11 |
to look in the compiled in maps directory.
|
|
|
6bbd11 |
---
|
|
|
6bbd11 |
CHANGELOG | 1
|
|
|
6bbd11 |
daemon/lookup.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++-------
|
|
|
6bbd11 |
2 files changed, 99 insertions(+), 13 deletions(-)
|
|
|
6bbd11 |
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/CHANGELOG
|
|
|
6bbd11 |
+++ autofs-5.0.7/CHANGELOG
|
|
|
6bbd11 |
@@ -94,6 +94,7 @@
|
|
|
6bbd11 |
- add negative cache lookup to hesiod lookup.
|
|
|
6bbd11 |
- fix external env configure.
|
|
|
6bbd11 |
- make autofs(5) consistent with auto.master(5).
|
|
|
6bbd11 |
+- fix map source with type lookup.
|
|
|
6bbd11 |
|
|
|
6bbd11 |
25/07/2012 autofs-5.0.7
|
|
|
6bbd11 |
=======================
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/daemon/lookup.c
|
|
|
6bbd11 |
+++ autofs-5.0.7/daemon/lookup.c
|
|
|
6bbd11 |
@@ -100,6 +100,27 @@ static int do_read_master(struct master
|
|
|
6bbd11 |
return status;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
+static char *find_map_path(struct map_source *map)
|
|
|
6bbd11 |
+{
|
|
|
6bbd11 |
+ struct stat st;
|
|
|
6bbd11 |
+ char *path;
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ path = malloc(strlen(AUTOFS_MAP_DIR) + strlen(map->argv[0]) + 2);
|
|
|
6bbd11 |
+ if (!path)
|
|
|
6bbd11 |
+ return NULL;
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ strcpy(path, AUTOFS_MAP_DIR);
|
|
|
6bbd11 |
+ strcat(path, "/");
|
|
|
6bbd11 |
+ strcat(path, map->argv[0]);
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ if (!stat(path, &st))
|
|
|
6bbd11 |
+ return path;
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ free(path);
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ return NULL;
|
|
|
6bbd11 |
+}
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
static int read_master_map(struct master *master, char *type, time_t age)
|
|
|
6bbd11 |
{
|
|
|
6bbd11 |
unsigned int logopt = master->logopt;
|
|
|
6bbd11 |
@@ -392,6 +413,42 @@ static void argv_cleanup(void *arg)
|
|
|
6bbd11 |
return;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
+static int lookup_map_read_map(struct autofs_point *ap,
|
|
|
6bbd11 |
+ struct map_source *map, time_t age)
|
|
|
6bbd11 |
+{
|
|
|
6bbd11 |
+ char *path;
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ if (!map->argv[0])
|
|
|
6bbd11 |
+ return NSS_STATUS_UNKNOWN;
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ /*
|
|
|
6bbd11 |
+ * This is only called when map->type != NULL.
|
|
|
6bbd11 |
+ * We only need to look for a map if source type is
|
|
|
6bbd11 |
+ * file and the map name doesn't begin with a "/".
|
|
|
6bbd11 |
+ */
|
|
|
6bbd11 |
+ if (strncmp(map->type, "file", 4))
|
|
|
6bbd11 |
+ return do_read_map(ap, map, age);
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ if (map->argv[0][0] == '/')
|
|
|
6bbd11 |
+ return do_read_map(ap, map, age);
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ path = find_map_path(map);
|
|
|
6bbd11 |
+ if (!path)
|
|
|
6bbd11 |
+ return NSS_STATUS_UNKNOWN;
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ if (map->argc >= 1) {
|
|
|
6bbd11 |
+ if (map->argv[0])
|
|
|
6bbd11 |
+ free((char *) map->argv[0]);
|
|
|
6bbd11 |
+ map->argv[0] = path;
|
|
|
6bbd11 |
+ } else {
|
|
|
6bbd11 |
+ error(ap->logopt, "invalid arguments for autofs_point");
|
|
|
6bbd11 |
+ free(path);
|
|
|
6bbd11 |
+ return NSS_STATUS_UNKNOWN;
|
|
|
6bbd11 |
+ }
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ return do_read_map(ap, map, age);
|
|
|
6bbd11 |
+}
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
static enum nsswitch_status read_map_source(struct nss_source *this,
|
|
|
6bbd11 |
struct autofs_point *ap, struct map_source *map, time_t age)
|
|
|
6bbd11 |
{
|
|
|
6bbd11 |
@@ -428,14 +485,10 @@ static enum nsswitch_status read_map_sou
|
|
|
6bbd11 |
tmap.argc = 0;
|
|
|
6bbd11 |
tmap.argv = NULL;
|
|
|
6bbd11 |
|
|
|
6bbd11 |
- path = malloc(strlen(AUTOFS_MAP_DIR) + strlen(map->argv[0]) + 2);
|
|
|
6bbd11 |
+ path = find_map_path(map);
|
|
|
6bbd11 |
if (!path)
|
|
|
6bbd11 |
return NSS_STATUS_UNKNOWN;
|
|
|
6bbd11 |
|
|
|
6bbd11 |
- strcpy(path, AUTOFS_MAP_DIR);
|
|
|
6bbd11 |
- strcat(path, "/");
|
|
|
6bbd11 |
- strcat(path, map->argv[0]);
|
|
|
6bbd11 |
-
|
|
|
6bbd11 |
if (map->argc >= 1) {
|
|
|
6bbd11 |
tmap.argc = map->argc;
|
|
|
6bbd11 |
tmap.argv = copy_argv(map->argc, map->argv);
|
|
|
6bbd11 |
@@ -496,7 +549,7 @@ int lookup_nss_read_map(struct autofs_po
|
|
|
6bbd11 |
debug(ap->logopt,
|
|
|
6bbd11 |
"reading map %s %s",
|
|
|
6bbd11 |
map->type, map->argv[0]);
|
|
|
6bbd11 |
- result = do_read_map(ap, map, age);
|
|
|
6bbd11 |
+ result = lookup_map_read_map(ap, map, age);
|
|
|
6bbd11 |
map = map->next;
|
|
|
6bbd11 |
continue;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
@@ -758,6 +811,43 @@ static int lookup_name_source_instance(s
|
|
|
6bbd11 |
return do_lookup_mount(ap, instance, name, name_len);
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
+static int do_name_lookup_mount(struct autofs_point *ap,
|
|
|
6bbd11 |
+ struct map_source *map,
|
|
|
6bbd11 |
+ const char *name, int name_len)
|
|
|
6bbd11 |
+{
|
|
|
6bbd11 |
+ char *path;
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ if (!map->argv[0])
|
|
|
6bbd11 |
+ return NSS_STATUS_UNKNOWN;
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ /*
|
|
|
6bbd11 |
+ * This is only called when map->type != NULL.
|
|
|
6bbd11 |
+ * We only need to look for a map if source type is
|
|
|
6bbd11 |
+ * file and the map name doesn't begin with a "/".
|
|
|
6bbd11 |
+ */
|
|
|
6bbd11 |
+ if (strncmp(map->type, "file", 4))
|
|
|
6bbd11 |
+ return do_lookup_mount(ap, map, name, name_len);
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ if (map->argv[0][0] == '/')
|
|
|
6bbd11 |
+ return do_lookup_mount(ap, map, name, name_len);
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ path = find_map_path(map);
|
|
|
6bbd11 |
+ if (!path)
|
|
|
6bbd11 |
+ return NSS_STATUS_UNKNOWN;
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ if (map->argc >= 1) {
|
|
|
6bbd11 |
+ if (map->argv[0])
|
|
|
6bbd11 |
+ free((char *) map->argv[0]);
|
|
|
6bbd11 |
+ map->argv[0] = path;
|
|
|
6bbd11 |
+ } else {
|
|
|
6bbd11 |
+ error(ap->logopt, "invalid arguments for autofs_point");
|
|
|
6bbd11 |
+ free(path);
|
|
|
6bbd11 |
+ return NSS_STATUS_UNKNOWN;
|
|
|
6bbd11 |
+ }
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
+ return do_lookup_mount(ap, map, name, name_len);
|
|
|
6bbd11 |
+}
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
static enum nsswitch_status lookup_map_name(struct nss_source *this,
|
|
|
6bbd11 |
struct autofs_point *ap, struct map_source *map,
|
|
|
6bbd11 |
const char *name, int name_len)
|
|
|
6bbd11 |
@@ -793,14 +883,10 @@ static enum nsswitch_status lookup_map_n
|
|
|
6bbd11 |
tmap.argc = 0;
|
|
|
6bbd11 |
tmap.argv = NULL;
|
|
|
6bbd11 |
|
|
|
6bbd11 |
- path = malloc(strlen(AUTOFS_MAP_DIR) + strlen(map->argv[0]) + 2);
|
|
|
6bbd11 |
+ path = find_map_path(map);
|
|
|
6bbd11 |
if (!path)
|
|
|
6bbd11 |
return NSS_STATUS_UNKNOWN;
|
|
|
6bbd11 |
|
|
|
6bbd11 |
- strcpy(path, AUTOFS_MAP_DIR);
|
|
|
6bbd11 |
- strcat(path, "/");
|
|
|
6bbd11 |
- strcat(path, map->argv[0]);
|
|
|
6bbd11 |
-
|
|
|
6bbd11 |
if (map->argc >= 1) {
|
|
|
6bbd11 |
tmap.argc = map->argc;
|
|
|
6bbd11 |
tmap.argv = copy_argv(map->argc, map->argv);
|
|
|
6bbd11 |
@@ -909,8 +995,7 @@ int lookup_nss_mount(struct autofs_point
|
|
|
6bbd11 |
sched_yield();
|
|
|
6bbd11 |
|
|
|
6bbd11 |
if (map->type) {
|
|
|
6bbd11 |
- result = do_lookup_mount(ap, map, name, name_len);
|
|
|
6bbd11 |
-
|
|
|
6bbd11 |
+ result = do_name_lookup_mount(ap, map, name, name_len);
|
|
|
6bbd11 |
if (result == NSS_STATUS_SUCCESS)
|
|
|
6bbd11 |
break;
|
|
|
6bbd11 |
|