Blame SOURCES/autofs-5.1.2-add-sss-master-map-wait-config-option.patch

304803
autofs-5.1.2 - add sss master map wait config option
304803
304803
From: Ian Kent <raven@themaw.net>
304803
304803
When sssd is starting up it can sometimes return "no such entry" for a
304803
short time until it has read in the LDAP map information. This affects
304803
reading the master map at autofs startup and results in no automount
304803
mounts if sssd is the primary map source.
304803
304803
This problem should be resolved in sssd but it's a problem for the
304803
moment so a configuration option, sss_master_map_wait, has been added
304803
to work around it.
304803
304803
The internal program default is 0, don't wait. If the work around is
304803
needed try setting this to 10 seconds to work around it.
304803
304803
Signed-off-by: Ian Kent <raven@themaw.net>
304803
---
304803
 CHANGELOG                      |    1 +
304803
 include/defaults.h             |    2 ++
304803
 lib/defaults.c                 |   17 +++++++++++++++++
304803
 man/autofs.conf.5.in           |    7 +++++++
304803
 modules/lookup_sss.c           |    7 ++++---
304803
 redhat/autofs.conf.default.in  |   10 ++++++++++
304803
 samples/autofs.conf.default.in |   10 ++++++++++
304803
 7 files changed, 51 insertions(+), 3 deletions(-)
304803
304803
--- autofs-5.0.7.orig/CHANGELOG
304803
+++ autofs-5.0.7/CHANGELOG
304803
@@ -241,6 +241,7 @@
304803
 - factor out set_thread_mount_request_log_id().
304803
 - add config option to use mount request log id.
304803
 - work around sss startup delay.
304803
+- add sss master map wait config option.
304803
 
304803
 25/07/2012 autofs-5.0.7
304803
 =======================
304803
--- autofs-5.0.7.orig/include/defaults.h
304803
+++ autofs-5.0.7/include/defaults.h
304803
@@ -51,6 +51,7 @@
304803
 #define DEFAULT_USE_HOSTNAME_FOR_MOUNTS  "0"
304803
 #define DEFAULT_DISABLE_NOT_FOUND_MESSAGE "0"
304803
 
304803
+#define DEFAULT_SSS_MASTER_MAP_WAIT	"0"
304803
 #define DEFAULT_USE_MOUNT_REQUEST_LOG_ID "0"
304803
 
304803
 /* Config entry flags */
304803
@@ -171,6 +172,7 @@ const char *defaults_get_auth_conf_file(
304803
 unsigned int defaults_get_map_hash_table_size(void);
304803
 unsigned int defaults_use_hostname_for_mounts(void);
304803
 unsigned int defaults_disable_not_found_message(void);
304803
+unsigned int defaults_get_sss_master_map_wait(void);
304803
 unsigned int defaults_get_use_mount_request_log_id(void);
304803
 
304803
 unsigned int conf_amd_mount_section_exists(const char *);
304803
--- autofs-5.0.7.orig/lib/defaults.c
304803
+++ autofs-5.0.7/lib/defaults.c
304803
@@ -76,6 +76,7 @@
304803
 #define NAME_USE_HOSTNAME_FOR_MOUNTS	"use_hostname_for_mounts"
304803
 #define NAME_DISABLE_NOT_FOUND_MESSAGE	"disable_not_found_message"
304803
 
304803
+#define NAME_SSS_MASTER_MAP_WAIT	"sss_master_map_wait"
304803
 #define NAME_USE_MOUNT_REQUEST_LOG_ID	"use_mount_request_log_id"
304803
 
304803
 #define NAME_AMD_ARCH				"arch"
304803
@@ -356,6 +357,11 @@ static int conf_load_autofs_defaults(voi
304803
 	if (ret == CFG_FAIL)
304803
 		goto error;
304803
 
304803
+	ret = conf_update(sec, NAME_SSS_MASTER_MAP_WAIT,
304803
+			  DEFAULT_SSS_MASTER_MAP_WAIT, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
 	ret = conf_update(sec, NAME_USE_MOUNT_REQUEST_LOG_ID,
304803
 			  DEFAULT_USE_MOUNT_REQUEST_LOG_ID, CONF_ENV);
304803
 	if (ret == CFG_FAIL)
304803
@@ -1850,6 +1856,17 @@ unsigned int defaults_get_use_mount_requ
304803
 
304803
 	return res;
304803
 }
304803
+
304803
+unsigned int defaults_get_sss_master_map_wait(void)
304803
+{
304803
+	int res;
304803
+
304803
+	res = conf_get_yesno(autofs_gbl_sec, NAME_SSS_MASTER_MAP_WAIT);
304803
+	if (res < 0)
304803
+		res = atoi(DEFAULT_SSS_MASTER_MAP_WAIT);
304803
+
304803
+	return res;
304803
+}
304803
 
304803
 unsigned int conf_amd_mount_section_exists(const char *section)
304803
 {
304803
--- autofs-5.0.7.orig/man/autofs.conf.5.in
304803
+++ autofs-5.0.7/man/autofs.conf.5.in
304803
@@ -142,6 +142,13 @@ That produces, IMHO, unnecessary noise i
304803
 has been added to provide the ability to turn it off. The default is "no"
304803
 to maintain the current behaviour.
304803
 .TP
304803
+.B sss_master_map_wait
304803
+.br
304803
+Set the time to wait and retry if sssd returns "no such entry" when starting
304803
+up. When sssd is starting up it can sometimes return "no such entry" for a
304803
+short time until it has read in the LDAP map information. Default is 0 seconds,
304803
+don't wait.
304803
+.TP
304803
 .B use_mount_request_log_id
304803
 .br
304803
 Set whether to use a mount request log id so that log entries for specific
304803
--- autofs-5.0.7.orig/modules/lookup_sss.c
304803
+++ autofs-5.0.7/modules/lookup_sss.c
304803
@@ -32,8 +32,6 @@
304803
 
304803
 /* Half a second between retries */
304803
 #define SETAUTOMOUNTENT_MASTER_INTERVAL	500000000
304803
-/* Try for 10 seconds */
304803
-#define SETAUTOMOUNTENT_MASTER_RETRIES	10 * 2
304803
 
304803
 #define MODPREFIX "lookup(sss): "
304803
 
304803
@@ -304,7 +302,10 @@ int lookup_read_master(struct master *ma
304803
 		if (ret != ENOENT)
304803
 			return NSS_STATUS_UNAVAIL;
304803
 
304803
-		retries = SETAUTOMOUNTENT_MASTER_RETRIES;
304803
+		retries = defaults_get_sss_master_map_wait() * 2;
304803
+		if (retries <= 0)
304803
+			return NSS_STATUS_NOTFOUND;
304803
+
304803
 		ret = setautomntent_wait(logopt,
304803
 					 ctxt, ctxt->mapname, &sss_ctxt,
304803
 					 retries);
304803
--- autofs-5.0.7.orig/redhat/autofs.conf.default.in
304803
+++ autofs-5.0.7/redhat/autofs.conf.default.in
304803
@@ -173,6 +173,16 @@ mount_nfs_default_protocol = 4
304803
 #
304803
 #disable_not_found_message = "no"
304803
 #
304803
+# sss_master_map_wait - When sssd is starting up it can sometimes return
304803
+# 			"no such entry" for a short time until it has read
304803
+# 			in the LDAP map information. Internal default is 0
304803
+# 			seconds, don't wait but if there is a problem with
304803
+# 			autofs not finding the master map at startup (when
304803
+# 			it should) then try setting this to 10 to work
304803
+# 			around it.
304803
+#
304803
+#sss_master_map_wait = 0
304803
+#
304803
 # Otions for the amd parser within autofs.
304803
 #
304803
 # amd configuration options that are aren't used, haven't been
304803
--- autofs-5.0.7.orig/samples/autofs.conf.default.in
304803
+++ autofs-5.0.7/samples/autofs.conf.default.in
304803
@@ -172,6 +172,16 @@ browse_mode = no
304803
 #
304803
 #disable_not_found_message = "no"
304803
 #
304803
+# sss_master_map_wait - When sssd is starting up it can sometimes return
304803
+#			"no such entry" for a short time until it has read
304803
+# 			in the LDAP map information. Internal default is 0
304803
+# 			seconds, don't wait but if there is a problem with
304803
+# 			autofs not finding the master map at startup (when
304803
+# 			it should) then try setting this to 10 to work
304803
+# 			around it.
304803
+#
304803
+#sss_master_map_wait = 0
304803
+#
304803
 # Otions for the amd parser within autofs.
304803
 #
304803
 # amd configuration options that are aren't used, haven't been