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

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