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