autofs-5.1.1 - add config option to suppress not found log message From: Ian Kent Signed-off-by: Ian Kent --- CHANGELOG | 1 + daemon/lookup.c | 11 +++++++++-- include/defaults.h | 4 +++- lib/defaults.c | 17 +++++++++++++++++ man/autofs.conf.5.in | 7 +++++++ modules/lookup_hesiod.c | 6 ++++-- redhat/autofs.conf.default.in | 8 ++++++++ samples/autofs.conf.default.in | 8 ++++++++ 8 files changed, 57 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2fdb0f2..247e0fe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -52,6 +52,7 @@ - add remote-fs.target systemd dependency. - fix typo in autofs.conf. - fix yp map age not updated during map lookup. +- add config option to supress not found log message. 21/04/2015 autofs-5.1.1 ======================= diff --git a/daemon/lookup.c b/daemon/lookup.c index 173f53e..201ccbb 100644 --- a/daemon/lookup.c +++ b/daemon/lookup.c @@ -1036,8 +1036,15 @@ static void update_negative_cache(struct autofs_point *ap, struct map_source *so */ cache_unlock(me->mc); else { - /* Notify only once after fail */ - logmsg("key \"%s\" not found in map source(s).", name); + if (!defaults_disable_not_found_message()) { + /* This really should be a warning but the original + * request for this needed it to be unconditional. + * That produces, IMHO, unnecessary noise in the log + * so a configuration option has been added to provide + * the ability to turn it off. + */ + logmsg("key \"%s\" not found in map source(s).", name); + } /* Doesn't exist in any source, just add it somewhere */ if (source) diff --git a/include/defaults.h b/include/defaults.h index 3788078..8db2bb1 100644 --- a/include/defaults.h +++ b/include/defaults.h @@ -47,7 +47,8 @@ #define DEFAULT_MAP_HASH_TABLE_SIZE "1024" -#define DEFAULT_USE_HOSTNAME_FOR_MOUNTS "0" +#define DEFAULT_USE_HOSTNAME_FOR_MOUNTS "0" +#define DEFAULT_DISABLE_NOT_FOUND_MESSAGE "0" /* Config entry flags */ #define CONF_NONE 0x00000000 @@ -165,6 +166,7 @@ unsigned int defaults_get_umount_wait(void); const char *defaults_get_auth_conf_file(void); unsigned int defaults_get_map_hash_table_size(void); unsigned int defaults_use_hostname_for_mounts(void); +unsigned int defaults_disable_not_found_message(void); unsigned int conf_amd_mount_section_exists(const char *); char *conf_amd_get_arch(void); diff --git a/lib/defaults.c b/lib/defaults.c index 7159536..0e48a78 100644 --- a/lib/defaults.c +++ b/lib/defaults.c @@ -74,6 +74,7 @@ #define NAME_MAP_HASH_TABLE_SIZE "map_hash_table_size" #define NAME_USE_HOSTNAME_FOR_MOUNTS "use_hostname_for_mounts" +#define NAME_DISABLE_NOT_FOUND_MESSAGE "disable_not_found_message" #define NAME_AMD_ARCH "arch" #define NAME_AMD_AUTO_ATTRCACHE "auto_attrcache" @@ -342,6 +343,11 @@ static int conf_load_autofs_defaults(void) if (ret == CFG_FAIL) goto error; + ret = conf_update(sec, NAME_DISABLE_NOT_FOUND_MESSAGE, + DEFAULT_DISABLE_NOT_FOUND_MESSAGE, CONF_ENV); + if (ret == CFG_FAIL) + goto error; + /* LDAP_URI and SEARCH_BASE can occur multiple times */ while ((co = conf_lookup(sec, NAME_LDAP_URI))) conf_delete(co->section, co->name); @@ -1719,6 +1725,17 @@ unsigned int defaults_use_hostname_for_mounts(void) return res; } +unsigned int defaults_disable_not_found_message(void) +{ + int res; + + res = conf_get_yesno(autofs_gbl_sec, NAME_DISABLE_NOT_FOUND_MESSAGE); + if (res < 0) + res = atoi(DEFAULT_DISABLE_NOT_FOUND_MESSAGE); + + return res; +} + unsigned int conf_amd_mount_section_exists(const char *section) { return conf_section_exists(section); diff --git a/man/autofs.conf.5.in b/man/autofs.conf.5.in index 6eb5d02..4405ac8 100644 --- a/man/autofs.conf.5.in +++ b/man/autofs.conf.5.in @@ -129,6 +129,13 @@ name resolving to one that isn't responding and while the number of attempts at a successful mount will correspond to the number of addresses the host name resolves to the order will also not correspond to fastest responding hosts. +.TP +.B disable_not_found_message +.br +The original request to add this log message needed it to be unconditional. +That produces, IMHO, unnecessary noise in the log so a configuration option +has been added to provide the ability to turn it off. The default is "no" +to maintain the current behaviour. .SS LDAP Configuration .P Configuration settings available are: diff --git a/modules/lookup_hesiod.c b/modules/lookup_hesiod.c index 12ccf41..3bd6200 100644 --- a/modules/lookup_hesiod.c +++ b/modules/lookup_hesiod.c @@ -194,8 +194,10 @@ static int lookup_one(struct autofs_point *ap, hes_result = hesiod_resolve(ctxt->hesiod_context, key, "filsys"); if (!hes_result || !hes_result[0]) { int err = errno; - error(ap->logopt, - MODPREFIX "key \"%s\" not found in map", key); + if (!defaults_disable_not_found_message()) { + error(ap->logopt, + MODPREFIX "key \"%s\" not found in map", key); + } status = pthread_mutex_unlock(&hesiod_mutex); if (status) fatal(status); diff --git a/redhat/autofs.conf.default.in b/redhat/autofs.conf.default.in index e09386b..d114249 100644 --- a/redhat/autofs.conf.default.in +++ b/redhat/autofs.conf.default.in @@ -151,6 +151,14 @@ mount_nfs_default_protocol = 4 # #use_hostname_for_mounts = "no" # +# disable_not_found_message - The original request to add this log message +# needed it to be unconditional. That produces, IMHO, +# unnecessary noise in the log so a configuration option +# has been added to provide the ability to turn it off. +# The default is "no" to maintain the current behaviour. +# +#disable_not_found_message = "no" +# # Otions for the amd parser within autofs. # # amd configuration options that are aren't used, haven't been diff --git a/samples/autofs.conf.default.in b/samples/autofs.conf.default.in index 75c3efa..bc25f52 100644 --- a/samples/autofs.conf.default.in +++ b/samples/autofs.conf.default.in @@ -150,6 +150,14 @@ browse_mode = no # #use_hostname_for_mounts = "no" # +# disable_not_found_message - The original request to add this log message +# needed it to be unconditional. That produces, IMHO, +# unnecessary noise in the log so a configuration option +# has been added to provide the ability to turn it off. +# The default is "no" to maintain the current behaviour. +# +#disable_not_found_message = "no" +# # Otions for the amd parser within autofs. # # amd configuration options that are aren't used, haven't been