Blame SOURCES/autofs-5.1.1-add-config-option-to-suppress-not-found-log-message.patch

4d476f
autofs-5.1.1 - add config option to suppress not found log message
4d476f
4d476f
From: Ian Kent <raven@themaw.net>
4d476f
4d476f
Signed-off-by: Ian Kent <raven@themaw.net>
4d476f
---
4d476f
 CHANGELOG                      |    1 +
4d476f
 daemon/lookup.c                |   11 +++++++++--
4d476f
 include/defaults.h             |    4 +++-
4d476f
 lib/defaults.c                 |   17 +++++++++++++++++
4d476f
 man/autofs.conf.5.in           |    7 +++++++
4d476f
 modules/lookup_hesiod.c        |    6 ++++--
4d476f
 redhat/autofs.conf.default.in  |    8 ++++++++
4d476f
 samples/autofs.conf.default.in |    8 ++++++++
4d476f
 8 files changed, 57 insertions(+), 5 deletions(-)
4d476f
4d476f
--- autofs-5.0.7.orig/CHANGELOG
4d476f
+++ autofs-5.0.7/CHANGELOG
4d476f
@@ -205,6 +205,7 @@
4d476f
 - fix typo in autofs_sasl_bind().
4d476f
 - add configuration option to use fqdn in mounts.
4d476f
 - fix use-after-free in st_queue_handler().
4d476f
+- add config option to supress not found log message.
4d476f
 
4d476f
 25/07/2012 autofs-5.0.7
4d476f
 =======================
4d476f
--- autofs-5.0.7.orig/daemon/lookup.c
4d476f
+++ autofs-5.0.7/daemon/lookup.c
4d476f
@@ -1036,8 +1036,15 @@ static void update_negative_cache(struct
4d476f
 		 */
4d476f
 		cache_unlock(me->mc);
4d476f
 	else {
4d476f
-		/* Notify only once after fail */
4d476f
-		logmsg("key \"%s\" not found in map source(s).", name);
4d476f
+		if (!defaults_disable_not_found_message()) {
4d476f
+			/* This really should be a warning but the original
4d476f
+			 * request for this needed it to be unconditional.
4d476f
+			 * That produces, IMHO, unnecessary noise in the log
4d476f
+			 * so a configuration option has been added to provide
4d476f
+			 * the ability to turn it off.
4d476f
+			 */
4d476f
+			logmsg("key \"%s\" not found in map source(s).", name);
4d476f
+		}
4d476f
 
4d476f
 		/* Doesn't exist in any source, just add it somewhere */
4d476f
 		if (source)
4d476f
--- autofs-5.0.7.orig/include/defaults.h
4d476f
+++ autofs-5.0.7/include/defaults.h
4d476f
@@ -47,7 +47,8 @@
4d476f
 
4d476f
 #define DEFAULT_MAP_HASH_TABLE_SIZE	"1024"
4d476f
 
4d476f
-#define DEFAULT_USE_HOSTNAME_FOR_MOUNTS	"0"
4d476f
+#define DEFAULT_USE_HOSTNAME_FOR_MOUNTS  "0"
4d476f
+#define DEFAULT_DISABLE_NOT_FOUND_MESSAGE "0"
4d476f
 
4d476f
 /* Config entry flags */
4d476f
 #define CONF_NONE			0x00000000
4d476f
@@ -165,6 +166,7 @@ unsigned int defaults_get_umount_wait(vo
4d476f
 const char *defaults_get_auth_conf_file(void);
4d476f
 unsigned int defaults_get_map_hash_table_size(void);
4d476f
 unsigned int defaults_use_hostname_for_mounts(void);
4d476f
+unsigned int defaults_disable_not_found_message(void);
4d476f
 
4d476f
 unsigned int conf_amd_mount_section_exists(const char *);
4d476f
 char *conf_amd_get_arch(void);
4d476f
--- autofs-5.0.7.orig/lib/defaults.c
4d476f
+++ autofs-5.0.7/lib/defaults.c
4d476f
@@ -73,6 +73,7 @@
4d476f
 #define NAME_MAP_HASH_TABLE_SIZE	"map_hash_table_size"
4d476f
 
4d476f
 #define NAME_USE_HOSTNAME_FOR_MOUNTS	"use_hostname_for_mounts"
4d476f
+#define NAME_DISABLE_NOT_FOUND_MESSAGE	"disable_not_found_message"
4d476f
 
4d476f
 #define NAME_AMD_ARCH				"arch"
4d476f
 #define NAME_AMD_AUTO_ATTRCACHE			"auto_attrcache"
4d476f
@@ -341,6 +342,11 @@ static int conf_load_autofs_defaults(voi
4d476f
 	if (ret == CFG_FAIL)
4d476f
 		goto error;
4d476f
 
4d476f
+	ret = conf_update(sec, NAME_DISABLE_NOT_FOUND_MESSAGE,
4d476f
+			  DEFAULT_DISABLE_NOT_FOUND_MESSAGE, CONF_ENV);
4d476f
+	if (ret == CFG_FAIL)
4d476f
+		goto error;
4d476f
+
4d476f
 	/* LDAP_URI and SEARCH_BASE can occur multiple times */
4d476f
 	while ((co = conf_lookup(sec, NAME_LDAP_URI)))
4d476f
 		conf_delete(co->section, co->name);
4d476f
@@ -1717,6 +1723,17 @@ unsigned int defaults_use_hostname_for_m
4d476f
 
4d476f
 	return res;
4d476f
 }
4d476f
+
4d476f
+unsigned int defaults_disable_not_found_message(void)
4d476f
+{
4d476f
+	int res;
4d476f
+
4d476f
+	res = conf_get_yesno(autofs_gbl_sec, NAME_DISABLE_NOT_FOUND_MESSAGE);
4d476f
+	if (res < 0)
4d476f
+		res = atoi(DEFAULT_DISABLE_NOT_FOUND_MESSAGE);
4d476f
+
4d476f
+	return res;
4d476f
+}
4d476f
 
4d476f
 unsigned int conf_amd_mount_section_exists(const char *section)
4d476f
 {
4d476f
--- autofs-5.0.7.orig/man/autofs.conf.5.in
4d476f
+++ autofs-5.0.7/man/autofs.conf.5.in
4d476f
@@ -129,6 +129,13 @@ name resolving to one that isn't respond
4d476f
 of attempts at a successful mount will correspond to the number of
4d476f
 addresses the host name resolves to the order will also not correspond
4d476f
 to fastest responding hosts.
4d476f
+.TP
4d476f
+.B disable_not_found_message
4d476f
+.br
4d476f
+The original request to add this log message needed it to be unconditional.
4d476f
+That produces, IMHO, unnecessary noise in the log so a configuration option
4d476f
+has been added to provide the ability to turn it off. The default is "no"
4d476f
+to maintain the current behaviour.
4d476f
 .SS LDAP Configuration
4d476f
 .P
4d476f
 Configuration settings available are:
4d476f
--- autofs-5.0.7.orig/modules/lookup_hesiod.c
4d476f
+++ autofs-5.0.7/modules/lookup_hesiod.c
4d476f
@@ -194,8 +194,10 @@ static int lookup_one(struct autofs_poin
4d476f
 	hes_result = hesiod_resolve(ctxt->hesiod_context, key, "filsys");
4d476f
 	if (!hes_result || !hes_result[0]) {
4d476f
 		int err = errno;
4d476f
-		error(ap->logopt,
4d476f
-		      MODPREFIX "key \"%s\" not found in map", key);
4d476f
+		if (!defaults_disable_not_found_message()) {
4d476f
+			error(ap->logopt,
4d476f
+			      MODPREFIX "key \"%s\" not found in map", key);
4d476f
+		}
4d476f
 		status = pthread_mutex_unlock(&hesiod_mutex);
4d476f
 		if (status)
4d476f
 			fatal(status);
4d476f
--- autofs-5.0.7.orig/redhat/autofs.conf.default.in
4d476f
+++ autofs-5.0.7/redhat/autofs.conf.default.in
4d476f
@@ -151,6 +151,14 @@ mount_nfs_default_protocol = 4
4d476f
 #
4d476f
 #use_hostname_for_mounts = "no"
4d476f
 #
4d476f
+# disable_not_found_message - The original request to add this log message
4d476f
+# 			 needed it to be unconditional. That produces, IMHO,
4d476f
+# 			 unnecessary noise in the log so a configuration option
4d476f
+# 			 has been added to provide the ability to turn it off.
4d476f
+# 			 The default is "no" to maintain the current behaviour.
4d476f
+#
4d476f
+#disable_not_found_message = "no"
4d476f
+#
4d476f
 # Otions for the amd parser within autofs.
4d476f
 #
4d476f
 # amd configuration options that are aren't used, haven't been
4d476f
--- autofs-5.0.7.orig/samples/autofs.conf.default.in
4d476f
+++ autofs-5.0.7/samples/autofs.conf.default.in
4d476f
@@ -150,6 +150,14 @@ browse_mode = no
4d476f
 #
4d476f
 #use_hostname_for_mounts = "no"
4d476f
 #
4d476f
+# disable_not_found_message - The original request to add this log message
4d476f
+# 			 needed it to be unconditional. That produces, IMHO,
4d476f
+# 			 unnecessary noise in the log so a configuration option
4d476f
+# 			 has been added to provide the ability to turn it off.
4d476f
+# 			 The default is "no" to maintain the current behaviour.
4d476f
+#
4d476f
+#disable_not_found_message = "no"
4d476f
+#
4d476f
 # Otions for the amd parser within autofs.
4d476f
 #
4d476f
 # amd configuration options that are aren't used, haven't been