|
|
306fa1 |
autofs-5.0.9 - amd lookup add parent prefix handling
|
|
|
306fa1 |
|
|
|
306fa1 |
From: Ian Kent <raven@themaw.net>
|
|
|
306fa1 |
|
|
|
306fa1 |
|
|
|
306fa1 |
---
|
|
|
306fa1 |
include/automount.h | 1 +
|
|
|
306fa1 |
lib/master.c | 3 +++
|
|
|
306fa1 |
modules/parse_amd.c | 31 +++++++++++++++++++++++++++++++
|
|
|
306fa1 |
3 files changed, 35 insertions(+)
|
|
|
306fa1 |
|
|
|
306fa1 |
diff --git a/include/automount.h b/include/automount.h
|
|
|
306fa1 |
index b304517..615efcc 100644
|
|
|
306fa1 |
--- a/include/automount.h
|
|
|
306fa1 |
+++ b/include/automount.h
|
|
|
306fa1 |
@@ -491,6 +491,7 @@ struct kernel_mod_version {
|
|
|
306fa1 |
struct autofs_point {
|
|
|
306fa1 |
pthread_t thid;
|
|
|
306fa1 |
char *path; /* Mount point name */
|
|
|
306fa1 |
+ char *pref; /* amd prefix */
|
|
|
306fa1 |
int pipefd; /* File descriptor for pipe */
|
|
|
306fa1 |
int kpipefd; /* Kernel end descriptor for pipe */
|
|
|
306fa1 |
int ioctlfd; /* File descriptor for ioctls */
|
|
|
306fa1 |
diff --git a/lib/master.c b/lib/master.c
|
|
|
306fa1 |
index 4ac3c6a..df4aef6 100644
|
|
|
306fa1 |
--- a/lib/master.c
|
|
|
306fa1 |
+++ b/lib/master.c
|
|
|
306fa1 |
@@ -86,6 +86,7 @@ int master_add_autofs_point(struct master_mapent *entry, unsigned logopt,
|
|
|
306fa1 |
free(ap);
|
|
|
306fa1 |
return 0;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
+ ap->pref = NULL;
|
|
|
306fa1 |
|
|
|
306fa1 |
ap->entry = entry;
|
|
|
306fa1 |
ap->exp_thread = 0;
|
|
|
306fa1 |
@@ -144,6 +145,8 @@ void master_free_autofs_point(struct autofs_point *ap)
|
|
|
306fa1 |
if (status)
|
|
|
306fa1 |
fatal(status);
|
|
|
306fa1 |
|
|
|
306fa1 |
+ if (ap->pref)
|
|
|
306fa1 |
+ free(ap->pref);
|
|
|
306fa1 |
free(ap->path);
|
|
|
306fa1 |
free(ap);
|
|
|
306fa1 |
}
|
|
|
306fa1 |
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
|
|
|
306fa1 |
index 54da1a5..295a10f 100644
|
|
|
306fa1 |
--- a/modules/parse_amd.c
|
|
|
306fa1 |
+++ b/modules/parse_amd.c
|
|
|
306fa1 |
@@ -736,6 +736,36 @@ static void normalize_sublink(unsigned int logopt,
|
|
|
306fa1 |
return;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
+/*
|
|
|
306fa1 |
+ * Set the prefix.
|
|
|
306fa1 |
+ *
|
|
|
306fa1 |
+ * This is done in a couple of places, here is as good a place as
|
|
|
306fa1 |
+ * any to describe it.
|
|
|
306fa1 |
+ *
|
|
|
306fa1 |
+ * If a prefix is present in the map entry then use it.
|
|
|
306fa1 |
+ *
|
|
|
306fa1 |
+ * A pref option with the value none is required to use no prefix,
|
|
|
306fa1 |
+ * otherwise the prefix of the parent map, if any, will be used.
|
|
|
306fa1 |
+ */
|
|
|
306fa1 |
+static void update_prefix(struct autofs_point *ap,
|
|
|
306fa1 |
+ struct amd_entry *entry, const char *name)
|
|
|
306fa1 |
+{
|
|
|
306fa1 |
+ size_t len;
|
|
|
306fa1 |
+ char *new;
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ if (!entry->pref && ap->pref) {
|
|
|
306fa1 |
+ len = strlen(ap->pref) + strlen(name) + 2;
|
|
|
306fa1 |
+ new = malloc(len);
|
|
|
306fa1 |
+ if (new) {
|
|
|
306fa1 |
+ strcpy(new, ap->pref);
|
|
|
306fa1 |
+ strcat(new, name);
|
|
|
306fa1 |
+ strcat(new, "/");
|
|
|
306fa1 |
+ entry->pref = new;
|
|
|
306fa1 |
+ }
|
|
|
306fa1 |
+ }
|
|
|
306fa1 |
+ return;
|
|
|
306fa1 |
+}
|
|
|
306fa1 |
+
|
|
|
306fa1 |
static struct amd_entry *dup_defaults_entry(struct amd_entry *defaults)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
struct amd_entry *entry;
|
|
|
306fa1 |
@@ -1044,6 +1074,7 @@ int parse_mount(struct autofs_point *ap, const char *name,
|
|
|
306fa1 |
sv = expand_entry(ap, this, flags, sv);
|
|
|
306fa1 |
sv = merge_entry_options(ap, this, sv);
|
|
|
306fa1 |
normalize_sublink(ap->logopt, this, sv);
|
|
|
306fa1 |
+ update_prefix(ap, this, name);
|
|
|
306fa1 |
|
|
|
306fa1 |
dequote_entry(ap, this);
|
|
|
306fa1 |
|