Blame SOURCES/autofs-5.1.5-log-mount-call-arguments-if-mount_verbose-is-set.patch

135b98
autofs-5.1.5 - log mount call arguments if mount_verbose is set
135b98
135b98
From: Lars R. Damerow <lars@pixar.com>
135b98
135b98
Override the debug log only setting if mount_verbose is set so that
135b98
mount parameter information is logged on mount.
135b98
135b98
Signed-off-by: Lars R. Damerow <lars@pixar.com>
135b98
Signed-off-by: Ian Kent <raven@themaw.net>
135b98
---
135b98
 CHANGELOG               |    1 +
135b98
 modules/mount_afs.c     |    6 +++++-
135b98
 modules/mount_bind.c    |   10 +++++++---
135b98
 modules/mount_ext2.c    |   16 ++++++++++------
135b98
 modules/mount_generic.c |   14 +++++++++-----
135b98
 modules/mount_nfs.c     |   29 +++++++++++++++++------------
135b98
 6 files changed, 49 insertions(+), 27 deletions(-)
135b98
135b98
--- autofs-5.1.4.orig/CHANGELOG
135b98
+++ autofs-5.1.4/CHANGELOG
135b98
@@ -49,6 +49,7 @@ xx/xx/2018 autofs-5.1.5
135b98
 - use malloc(3) in spawn.c.
135b98
 - add mount_verbose configuration option.
135b98
 - optionally log mount requestor process info.
135b98
+- log mount call arguments if mount_verbose is set.
135b98
 
135b98
 19/12/2017 autofs-5.1.4
135b98
 - fix spec file url.
135b98
--- autofs-5.1.4.orig/modules/mount_afs.c
135b98
+++ autofs-5.1.4/modules/mount_afs.c
135b98
@@ -37,10 +37,14 @@ int mount_mount(struct autofs_point *ap,
135b98
 	char dest[PATH_MAX + 1];
135b98
 	size_t r_len = strlen(root);
135b98
 	size_t d_len = r_len + name_len + 2;
135b98
+	void (*mountlog)(unsigned int, const char*, ...) = &log_debug;
135b98
 
135b98
 	if (ap->flags & MOUNT_FLAG_REMOUNT)
135b98
 		return 0;
135b98
 
135b98
+	if (defaults_get_mount_verbose())
135b98
+		mountlog = &log_info;
135b98
+
135b98
 	if (d_len > PATH_MAX)
135b98
 		return 1;
135b98
 
135b98
@@ -53,7 +57,7 @@ int mount_mount(struct autofs_point *ap,
135b98
 	if (dest[strlen(dest)-1] == '/')
135b98
 	    dest[strlen(dest)-1] = '\0';
135b98
 
135b98
-	debug(ap->logopt, MODPREFIX "mounting AFS %s -> %s", dest, what);
135b98
+	mountlog(ap->logopt, MODPREFIX "mounting AFS %s -> %s", dest, what);
135b98
 
135b98
 	return symlink(what, dest);	/* Try it.  If it fails, return the error. */
135b98
 }
135b98
--- autofs-5.1.4.orig/modules/mount_bind.c
135b98
+++ autofs-5.1.4/modules/mount_bind.c
135b98
@@ -81,10 +81,14 @@ int mount_mount(struct autofs_point *ap,
135b98
 	int err;
135b98
 	int i, len;
135b98
 	int symlnk = (*name != '/' && (ap->flags & MOUNT_FLAG_SYMLINK));
135b98
+	void (*mountlog)(unsigned int, const char*, ...) = &log_debug;
135b98
 
135b98
 	if (ap->flags & MOUNT_FLAG_REMOUNT)
135b98
 		return 0;
135b98
 
135b98
+	if (defaults_get_mount_verbose())
135b98
+		mountlog = &log_info;
135b98
+
135b98
 	/* Extract "symlink" pseudo-option which forces local filesystems
135b98
 	 * to be symlinked instead of bound.
135b98
 	 */
135b98
@@ -164,9 +168,9 @@ int mount_mount(struct autofs_point *ap,
135b98
 		if (!status)
135b98
 			existed = 0;
135b98
 
135b98
-		debug(ap->logopt, MODPREFIX
135b98
-		      "calling mount --bind -o %s %s %s",
135b98
-		      options, what, fullpath);
135b98
+		mountlog(ap->logopt, MODPREFIX
135b98
+			 "calling mount --bind -o %s %s %s",
135b98
+			  options, what, fullpath);
135b98
 
135b98
 		err = spawn_bind_mount(ap->logopt, "-o",
135b98
 				       options, what, fullpath, NULL);
135b98
--- autofs-5.1.4.orig/modules/mount_ext2.c
135b98
+++ autofs-5.1.4/modules/mount_ext2.c
135b98
@@ -47,10 +47,14 @@ int mount_mount(struct autofs_point *ap,
135b98
 	int err, ro = 0;
135b98
 	const char *fsck_prog;
135b98
 	int len, status, existed = 1;
135b98
+	void (*mountlog)(unsigned int, const char*, ...) = &log_debug;
135b98
 
135b98
 	if (ap->flags & MOUNT_FLAG_REMOUNT)
135b98
 		return 0;
135b98
 
135b98
+	if (defaults_get_mount_verbose())
135b98
+		mountlog = &log_info;
135b98
+
135b98
 	/* Root offset of multi-mount */
135b98
 	len = strlen(root);
135b98
 	if (root[len - 1] == '/') {
135b98
@@ -121,15 +125,15 @@ int mount_mount(struct autofs_point *ap,
135b98
 	}
135b98
 
135b98
 	if (options) {
135b98
-		debug(ap->logopt, MODPREFIX
135b98
-		      "calling mount -t %s -o %s %s %s",
135b98
-		      fstype, options, what, fullpath);
135b98
+		mountlog(ap->logopt, MODPREFIX
135b98
+			 "calling mount -t %s -o %s %s %s",
135b98
+			 fstype, options, what, fullpath);
135b98
 		err = spawn_mount(ap->logopt, "-t", fstype,
135b98
 			          "-o", options, what, fullpath, NULL);
135b98
 	} else {
135b98
-		debug(ap->logopt,
135b98
-		      MODPREFIX "calling mount -t %s %s %s",
135b98
-		      fstype, what, fullpath);
135b98
+		mountlog(ap->logopt,
135b98
+			 MODPREFIX "calling mount -t %s %s %s",
135b98
+			 fstype, what, fullpath);
135b98
 		err = spawn_mount(ap->logopt, "-t", fstype, what, fullpath, NULL);
135b98
 	}
135b98
 
135b98
--- autofs-5.1.4.orig/modules/mount_generic.c
135b98
+++ autofs-5.1.4/modules/mount_generic.c
135b98
@@ -46,10 +46,14 @@ int mount_mount(struct autofs_point *ap,
135b98
 	char buf[MAX_ERR_BUF];
135b98
 	int err;
135b98
 	int len, status, existed = 1;
135b98
+	void (*mountlog)(unsigned int, const char*, ...) = &log_debug;
135b98
 
135b98
 	if (ap->flags & MOUNT_FLAG_REMOUNT)
135b98
 		return 0;
135b98
 
135b98
+	if (defaults_get_mount_verbose())
135b98
+		mountlog = &log_info;
135b98
+
135b98
 	/* Root offset of multi-mount */
135b98
 	len = strlen(root);
135b98
 	if (root[len - 1] == '/') {
135b98
@@ -80,15 +84,15 @@ int mount_mount(struct autofs_point *ap,
135b98
 		existed = 0;
135b98
 
135b98
 	if (options && options[0]) {
135b98
-		debug(ap->logopt,
135b98
-		      MODPREFIX "calling mount -t %s -o %s %s %s",
135b98
-		      fstype, options, what, fullpath);
135b98
+		mountlog(ap->logopt,
135b98
+			 MODPREFIX "calling mount -t %s -o %s %s %s",
135b98
+			 fstype, options, what, fullpath);
135b98
 
135b98
 		err = spawn_mount(ap->logopt, "-t", fstype,
135b98
 				  "-o", options, what, fullpath, NULL);
135b98
 	} else {
135b98
-		debug(ap->logopt, MODPREFIX "calling mount -t %s %s %s",
135b98
-		      fstype, what, fullpath);
135b98
+		mountlog(ap->logopt, MODPREFIX "calling mount -t %s %s %s",
135b98
+			 fstype, what, fullpath);
135b98
 		err = spawn_mount(ap->logopt, "-t", fstype, what, fullpath, NULL);
135b98
 	}
135b98
 
135b98
--- autofs-5.1.4.orig/modules/mount_nfs.c
135b98
+++ autofs-5.1.4/modules/mount_nfs.c
135b98
@@ -77,13 +77,17 @@ int mount_mount(struct autofs_point *ap,
135b98
 	int port = -1;
135b98
 	int ro = 0;            /* Set if mount bind should be read-only */
135b98
 	int rdma = 0;
135b98
+	void (*mountlog)(unsigned int, const char*, ...) = &log_debug;
135b98
 
135b98
 	if (ap->flags & MOUNT_FLAG_REMOUNT)
135b98
 		return 0;
135b98
 
135b98
-	debug(ap->logopt,
135b98
-	      MODPREFIX "root=%s name=%s what=%s, fstype=%s, options=%s",
135b98
-	      root, name, what, fstype, options);
135b98
+	if (defaults_get_mount_verbose())
135b98
+		mountlog = &log_info;
135b98
+
135b98
+	mountlog(ap->logopt,
135b98
+		 MODPREFIX "root=%s name=%s what=%s, fstype=%s, options=%s",
135b98
+		 root, name, what, fstype, options);
135b98
 
135b98
 	mount_default_proto = defaults_get_mount_nfs_default_proto();
135b98
 	vers = NFS_VERS_DEFAULT | NFS_PROTO_DEFAULT;
135b98
@@ -203,9 +207,9 @@ int mount_mount(struct autofs_point *ap,
135b98
 		if ((vers & NFS_PROTO_MASK) == 0)
135b98
 			vers |= NFS_PROTO_MASK;
135b98
 
135b98
-		debug(ap->logopt, MODPREFIX
135b98
-		      "nfs options=\"%s\", nobind=%d, nosymlink=%d, ro=%d",
135b98
-		      nfsoptions, nobind, nosymlink, ro);
135b98
+		mountlog(ap->logopt, MODPREFIX
135b98
+			 "nfs options=\"%s\", nobind=%d, nosymlink=%d, ro=%d",
135b98
+			 nfsoptions, nobind, nosymlink, ro);
135b98
 	}
135b98
 
135b98
 	if (!parse_location(ap->logopt, &hosts, what, flags)) {
135b98
@@ -379,17 +383,18 @@ dont_probe:
135b98
 		}
135b98
 
135b98
 		if (nfsoptions && *nfsoptions) {
135b98
-			debug(ap->logopt,
135b98
-			      MODPREFIX "calling mount -t %s " SLOPPY 
135b98
-			      "-o %s %s %s", fstype, nfsoptions, loc, fullpath);
135b98
+			mountlog(ap->logopt,
135b98
+				 MODPREFIX "calling mount -t %s " SLOPPY
135b98
+				 "-o %s %s %s", fstype, nfsoptions, loc,
135b98
+				 fullpath);
135b98
 
135b98
 			err = spawn_mount(ap->logopt,
135b98
 					  "-t", fstype, SLOPPYOPT "-o",
135b98
 					  nfsoptions, loc, fullpath, NULL);
135b98
 		} else {
135b98
-			debug(ap->logopt,
135b98
-			      MODPREFIX "calling mount -t %s %s %s",
135b98
-			      fstype, loc, fullpath);
135b98
+			mountlog(ap->logopt,
135b98
+				 MODPREFIX "calling mount -t %s %s %s",
135b98
+				 fstype, loc, fullpath);
135b98
 			err = spawn_mount(ap->logopt,
135b98
 					  "-t", fstype, loc, fullpath, NULL);
135b98
 		}