Blame SOURCES/autofs-5.0.7-fix-dumpmaps-multi-output.patch

304803
autofs-5.0.7 - fix dumpmaps multi output
304803
304803
From: Ian Kent <raven@themaw.net>
304803
304803
If the maps contain the old style "multi" type the dumped map information
304803
isn't right.
304803
---
304803
 CHANGELOG    |    1 
304803
 lib/master.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++------------
304803
 2 files changed, 50 insertions(+), 12 deletions(-)
304803
304803
--- autofs-5.0.7.orig/CHANGELOG
304803
+++ autofs-5.0.7/CHANGELOG
304803
@@ -58,6 +58,7 @@
304803
 - add after sssd dependency to unit file.
304803
 - fix syncronize handle_mounts() shutdown.
304803
 - fix fix wildcard multi map regression.
304803
+- fix dumpmaps multi output.
304803
 
304803
 25/07/2012 autofs-5.0.7
304803
 =======================
304803
--- autofs-5.0.7.orig/lib/master.c
304803
+++ autofs-5.0.7/lib/master.c
304803
@@ -1281,6 +1281,54 @@ static void list_source_instances(struct
304803
 	return;
304803
 }
304803
 
304803
+static void print_map_info(struct map_source *source)
304803
+{
304803
+	int argc = source->argc;
304803
+	int i, multi, map_num;
304803
+
304803
+	multi = (source->type && !strcmp(source->type, "multi"));
304803
+	map_num = 1;
304803
+	for (i = 0; i < argc; i++) {
304803
+		if (source->argv[i] && *source->argv[i] != '-') {
304803
+			if (!multi)
304803
+				printf("  map: %s\n", source->argv[i]);
304803
+			else
304803
+				printf("  map[%i]: %s\n", map_num, source->argv[i]);
304803
+			i++;
304803
+		}
304803
+
304803
+		if (i >= argc)
304803
+			return;
304803
+
304803
+		if (!strcmp(source->argv[i], "--"))
304803
+			continue;
304803
+
304803
+		if (source->argv[i]) {
304803
+			int need_newline = 0;
304803
+			int j;
304803
+
304803
+			if (!multi)
304803
+				printf("  arguments:");
304803
+			else
304803
+				printf("  arguments[%i]:", map_num);
304803
+
304803
+			for (j = i; j < source->argc; j++) {
304803
+				if (!strcmp(source->argv[j], "--"))
304803
+					break;
304803
+				printf(" %s", source->argv[j]);
304803
+				i++;
304803
+				need_newline = 1;
304803
+			}
304803
+			if (need_newline)
304803
+				printf("\n");
304803
+		}
304803
+		if (multi)
304803
+			map_num++;
304803
+	}
304803
+
304803
+	return;
304803
+}
304803
+
304803
 int master_show_mounts(struct master *master)
304803
 {
304803
 	struct list_head *p, *head;
304803
@@ -1311,7 +1359,6 @@ int master_show_mounts(struct master *ma
304803
 		struct autofs_point *ap;
304803
 		time_t now = time(NULL);
304803
 		unsigned int count = 0;
304803
-		int i;
304803
 
304803
 		this = list_entry(p, struct master_mapent, list);
304803
 		p = p->next;
304803
@@ -1357,20 +1404,10 @@ int master_show_mounts(struct master *ma
304803
 			}
304803
 
304803
 			if (source->argc >= 1) {
304803
-				i = 0;
304803
-				if (source->argv[0] && *source->argv[0] != '-') {
304803
-					printf("  map: %s\n", source->argv[0]);
304803
-					i = 1;
304803
-				}
304803
+				print_map_info(source);
304803
 				if (count && ap->type == LKP_INDIRECT)
304803
 					printf("  duplicate indirect map entry"
304803
 					       " will be ignored at run time\n");
304803
-				if (source->argc > 1) {
304803
-					printf("  arguments: ");
304803
-					for (; i < source->argc; i++)
304803
-						printf("%s ", source->argv[i]);
304803
-					printf("\n");
304803
-				}
304803
 			}
304803
 
304803
 			printf("\n");