Blame SOURCES/autofs-5.0.9-amd-lookup-add-parent-prefix-handling.patch

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