|
|
d702dc |
autofs-5.1.6 - sss introduce a flag to indicate map being read
|
|
|
d702dc |
|
|
|
d702dc |
From: Ian Kent <raven@themaw.net>
|
|
|
d702dc |
|
|
|
d702dc |
When the master map is being read for the first time a retry loop is
|
|
|
d702dc |
used by the caller to try harder to read the master map because it
|
|
|
d702dc |
is required for autofs to start up.
|
|
|
d702dc |
|
|
|
d702dc |
But when re-reading the master map, reading dependent maps, or doing
|
|
|
d702dc |
key lookups that loop isn't used so a longer retry is needed for those
|
|
|
d702dc |
cases.
|
|
|
d702dc |
|
|
|
d702dc |
Introduce a flag to indicate which map is being read, or if the master
|
|
|
d702dc |
map is being re-read, or if a key lookup is being done so the number
|
|
|
d702dc |
of retries can be adjusted accordingly.
|
|
|
d702dc |
|
|
|
d702dc |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
d702dc |
---
|
|
|
d702dc |
CHANGELOG | 1 +
|
|
|
d702dc |
modules/lookup_sss.c | 87 +++++++++++++++++++++++++++++++++++++++++---------
|
|
|
d702dc |
2 files changed, 72 insertions(+), 16 deletions(-)
|
|
|
d702dc |
|
|
|
d702dc |
diff --git a/CHANGELOG b/CHANGELOG
|
|
|
d702dc |
index 4a6c042..2d98a3a 100644
|
|
|
d702dc |
--- a/CHANGELOG
|
|
|
d702dc |
+++ b/CHANGELOG
|
|
|
d702dc |
@@ -104,6 +104,7 @@ xx/xx/2018 autofs-5.1.5
|
|
|
d702dc |
- improve sss getautomntent() error handling.
|
|
|
d702dc |
- sss introduce calculate_retry_count() function.
|
|
|
d702dc |
- move readall into struct master.
|
|
|
d702dc |
+- sss introduce a flag to indicate map being read.
|
|
|
d702dc |
|
|
|
d702dc |
19/12/2017 autofs-5.1.4
|
|
|
d702dc |
- fix spec file url.
|
|
|
d702dc |
diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c
|
|
|
d702dc |
index 29666a3..3c0ffde 100644
|
|
|
d702dc |
--- a/modules/lookup_sss.c
|
|
|
d702dc |
+++ b/modules/lookup_sss.c
|
|
|
d702dc |
@@ -53,6 +53,24 @@
|
|
|
d702dc |
*/
|
|
|
d702dc |
#define SSS_PROTO_VERSION 1
|
|
|
d702dc |
|
|
|
d702dc |
+#define SSS_DEFAULT_WAIT 10
|
|
|
d702dc |
+
|
|
|
d702dc |
+/* When the master map is being read a retry loop is used by the
|
|
|
d702dc |
+ * caller to try harder to read the master map because it is required
|
|
|
d702dc |
+ * for autofs to start up.
|
|
|
d702dc |
+ *
|
|
|
d702dc |
+ * But when reading dependent maps or looking up a key that loop isn't
|
|
|
d702dc |
+ * used so a longer retry is needed for those cases.
|
|
|
d702dc |
+ *
|
|
|
d702dc |
+ * Introduce a flag to indicate which map is being read or if a lookup
|
|
|
d702dc |
+ * is being done so the number of retries can be adjusted accordingly.
|
|
|
d702dc |
+ */
|
|
|
d702dc |
+#define SSS_READ_NONE 0x00
|
|
|
d702dc |
+#define SSS_READ_MASTER_MAP 0x01
|
|
|
d702dc |
+#define SSS_REREAD_MASTER_MAP 0x02
|
|
|
d702dc |
+#define SSS_READ_DEPENDENT_MAP 0x04
|
|
|
d702dc |
+#define SSS_LOOKUP_KEY 0x08
|
|
|
d702dc |
+
|
|
|
d702dc |
unsigned int _sss_auto_protocol_version(unsigned int);
|
|
|
d702dc |
int _sss_setautomntent(const char *, void **);
|
|
|
d702dc |
int _sss_getautomntent_r(char **, char **, void *);
|
|
|
d702dc |
@@ -249,7 +267,7 @@ static unsigned int proto_version(struct lookup_context *ctxt)
|
|
|
d702dc |
return proto_version;
|
|
|
d702dc |
}
|
|
|
d702dc |
|
|
|
d702dc |
-static unsigned int calculate_retry_count(struct lookup_context *ctxt)
|
|
|
d702dc |
+static unsigned int calculate_retry_count(struct lookup_context *ctxt, unsigned int flags)
|
|
|
d702dc |
{
|
|
|
d702dc |
int retries;
|
|
|
d702dc |
|
|
|
d702dc |
@@ -269,15 +287,39 @@ static unsigned int calculate_retry_count(struct lookup_context *ctxt)
|
|
|
d702dc |
* a host being down, return 0 for retries.
|
|
|
d702dc |
*/
|
|
|
d702dc |
if (proto_version(ctxt) == 0)
|
|
|
d702dc |
- retries = 0;
|
|
|
d702dc |
+ return 0;
|
|
|
d702dc |
else
|
|
|
d702dc |
- retries = 10;
|
|
|
d702dc |
+ retries = SSS_DEFAULT_WAIT;
|
|
|
d702dc |
}
|
|
|
d702dc |
+
|
|
|
d702dc |
+ if (proto_version(ctxt) == 0)
|
|
|
d702dc |
+ return retries;
|
|
|
d702dc |
+
|
|
|
d702dc |
+ /* When the master map is being read there's an additional
|
|
|
d702dc |
+ * outer wait loop.
|
|
|
d702dc |
+ *
|
|
|
d702dc |
+ * If master map wait is set in the configuration there
|
|
|
d702dc |
+ * will be an outer loop interating master_map_wait / 2
|
|
|
d702dc |
+ * times so adjust the number of retries here to account
|
|
|
d702dc |
+ * for this for the cases where the master map isn't being
|
|
|
d702dc |
+ * read.
|
|
|
d702dc |
+ */
|
|
|
d702dc |
+
|
|
|
d702dc |
+ if (!(flags & SSS_READ_MASTER_MAP) ||
|
|
|
d702dc |
+ (flags & SSS_REREAD_MASTER_MAP)) {
|
|
|
d702dc |
+ unsigned int master_map_wait = defaults_get_master_wait();
|
|
|
d702dc |
+ unsigned int m_wait;
|
|
|
d702dc |
+
|
|
|
d702dc |
+ m_wait = master_map_wait ? master_map_wait : SSS_DEFAULT_WAIT;
|
|
|
d702dc |
+ retries *= (m_wait / 2);
|
|
|
d702dc |
+ }
|
|
|
d702dc |
+
|
|
|
d702dc |
return retries;
|
|
|
d702dc |
}
|
|
|
d702dc |
|
|
|
d702dc |
static int setautomntent_wait(unsigned int logopt,
|
|
|
d702dc |
- struct lookup_context *ctxt, void **sss_ctxt)
|
|
|
d702dc |
+ struct lookup_context *ctxt, void **sss_ctxt,
|
|
|
d702dc |
+ unsigned int flags)
|
|
|
d702dc |
{
|
|
|
d702dc |
unsigned int retries;
|
|
|
d702dc |
unsigned int retry = 0;
|
|
|
d702dc |
@@ -285,7 +327,7 @@ static int setautomntent_wait(unsigned int logopt,
|
|
|
d702dc |
|
|
|
d702dc |
*sss_ctxt = NULL;
|
|
|
d702dc |
|
|
|
d702dc |
- retries = calculate_retry_count(ctxt);
|
|
|
d702dc |
+ retries = calculate_retry_count(ctxt, flags);
|
|
|
d702dc |
if (retries == 0) {
|
|
|
d702dc |
if (proto_version(ctxt) == 0)
|
|
|
d702dc |
return EINVAL;
|
|
|
d702dc |
@@ -333,7 +375,8 @@ static int setautomntent_wait(unsigned int logopt,
|
|
|
d702dc |
}
|
|
|
d702dc |
|
|
|
d702dc |
static int setautomntent(unsigned int logopt,
|
|
|
d702dc |
- struct lookup_context *ctxt, void **sss_ctxt)
|
|
|
d702dc |
+ struct lookup_context *ctxt, void **sss_ctxt,
|
|
|
d702dc |
+ unsigned int flags)
|
|
|
d702dc |
{
|
|
|
d702dc |
char buf[MAX_ERR_BUF];
|
|
|
d702dc |
char *estr;
|
|
|
d702dc |
@@ -355,7 +398,7 @@ static int setautomntent(unsigned int logopt,
|
|
|
d702dc |
goto error;
|
|
|
d702dc |
}
|
|
|
d702dc |
|
|
|
d702dc |
- ret = setautomntent_wait(logopt, ctxt, sss_ctxt);
|
|
|
d702dc |
+ ret = setautomntent_wait(logopt, ctxt, sss_ctxt, flags);
|
|
|
d702dc |
if (ret) {
|
|
|
d702dc |
if (ret == ECONNREFUSED) {
|
|
|
d702dc |
err = NSS_STATUS_UNKNOWN;
|
|
|
d702dc |
@@ -400,13 +443,14 @@ static int endautomntent(unsigned int logopt,
|
|
|
d702dc |
|
|
|
d702dc |
static int getautomntent_wait(unsigned int logopt,
|
|
|
d702dc |
struct lookup_context *ctxt,
|
|
|
d702dc |
- char **key, char **value, void *sss_ctxt)
|
|
|
d702dc |
+ char **key, char **value, void *sss_ctxt,
|
|
|
d702dc |
+ unsigned int flags)
|
|
|
d702dc |
{
|
|
|
d702dc |
unsigned int retries;
|
|
|
d702dc |
unsigned int retry = 0;
|
|
|
d702dc |
int ret = 0;
|
|
|
d702dc |
|
|
|
d702dc |
- retries = calculate_retry_count(ctxt);
|
|
|
d702dc |
+ retries = calculate_retry_count(ctxt, flags);
|
|
|
d702dc |
if (retries == 0) {
|
|
|
d702dc |
if (proto_version(ctxt) == 0)
|
|
|
d702dc |
return EINVAL;
|
|
|
d702dc |
@@ -446,7 +490,8 @@ static int getautomntent_wait(unsigned int logopt,
|
|
|
d702dc |
|
|
|
d702dc |
static int getautomntent(unsigned int logopt,
|
|
|
d702dc |
struct lookup_context *ctxt,
|
|
|
d702dc |
- char **key, char **value, int count, void *sss_ctxt)
|
|
|
d702dc |
+ char **key, char **value, int count,
|
|
|
d702dc |
+ void *sss_ctxt, unsigned int flags)
|
|
|
d702dc |
{
|
|
|
d702dc |
char buf[MAX_ERR_BUF];
|
|
|
d702dc |
char *estr;
|
|
|
d702dc |
@@ -486,7 +531,7 @@ static int getautomntent(unsigned int logopt,
|
|
|
d702dc |
}
|
|
|
d702dc |
|
|
|
d702dc |
ret = getautomntent_wait(logopt, ctxt,
|
|
|
d702dc |
- key, value, sss_ctxt);
|
|
|
d702dc |
+ key, value, sss_ctxt, flags);
|
|
|
d702dc |
if (ret) {
|
|
|
d702dc |
if (ret == ECONNREFUSED) {
|
|
|
d702dc |
err = NSS_STATUS_UNKNOWN;
|
|
|
d702dc |
@@ -534,8 +579,13 @@ int lookup_read_master(struct master *master, time_t age, void *context)
|
|
|
d702dc |
char *key;
|
|
|
d702dc |
char *value = NULL;
|
|
|
d702dc |
int count, ret;
|
|
|
d702dc |
+ unsigned int flags;
|
|
|
d702dc |
+
|
|
|
d702dc |
+ flags = SSS_READ_MASTER_MAP;
|
|
|
d702dc |
+ if (master->readall)
|
|
|
d702dc |
+ flags |= SSS_REREAD_MASTER_MAP;
|
|
|
d702dc |
|
|
|
d702dc |
- ret = setautomntent(logopt, ctxt, &sss_ctxt);
|
|
|
d702dc |
+ ret = setautomntent(logopt, ctxt, &sss_ctxt, flags);
|
|
|
d702dc |
if (ret)
|
|
|
d702dc |
return ret;
|
|
|
d702dc |
|
|
|
d702dc |
@@ -543,7 +593,9 @@ int lookup_read_master(struct master *master, time_t age, void *context)
|
|
|
d702dc |
while (1) {
|
|
|
d702dc |
key = NULL;
|
|
|
d702dc |
value = NULL;
|
|
|
d702dc |
- ret = getautomntent(logopt, ctxt, &key, &value, count, sss_ctxt);
|
|
|
d702dc |
+ ret = getautomntent(logopt, ctxt,
|
|
|
d702dc |
+ &key, &value, count,
|
|
|
d702dc |
+ sss_ctxt, SSS_READ_MASTER_MAP);
|
|
|
d702dc |
if (ret) {
|
|
|
d702dc |
endautomntent(logopt, ctxt, &sss_ctxt);
|
|
|
d702dc |
return ret;
|
|
|
d702dc |
@@ -622,7 +674,8 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
|
|
|
d702dc |
return NSS_STATUS_SUCCESS;
|
|
|
d702dc |
}
|
|
|
d702dc |
|
|
|
d702dc |
- ret = setautomntent(ap->logopt, ctxt, &sss_ctxt);
|
|
|
d702dc |
+ ret = setautomntent(ap->logopt, ctxt,
|
|
|
d702dc |
+ &sss_ctxt, SSS_READ_DEPENDENT_MAP);
|
|
|
d702dc |
if (ret)
|
|
|
d702dc |
return ret;
|
|
|
d702dc |
|
|
|
d702dc |
@@ -630,7 +683,9 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
|
|
|
d702dc |
while (1) {
|
|
|
d702dc |
key = NULL;
|
|
|
d702dc |
value = NULL;
|
|
|
d702dc |
- ret = getautomntent(ap->logopt, ctxt, &key, &value, count, sss_ctxt);
|
|
|
d702dc |
+ ret = getautomntent(ap->logopt, ctxt,
|
|
|
d702dc |
+ &key, &value, count,
|
|
|
d702dc |
+ sss_ctxt, SSS_READ_DEPENDENT_MAP);
|
|
|
d702dc |
if (ret) {
|
|
|
d702dc |
endautomntent(ap->logopt, ctxt, &sss_ctxt);
|
|
|
d702dc |
return ret;
|
|
|
d702dc |
@@ -711,7 +766,7 @@ static int lookup_one(struct autofs_point *ap,
|
|
|
d702dc |
|
|
|
d702dc |
mc = source->mc;
|
|
|
d702dc |
|
|
|
d702dc |
- ret = setautomntent(ap->logopt, ctxt, &sss_ctxt);
|
|
|
d702dc |
+ ret = setautomntent(ap->logopt, ctxt, &sss_ctxt, SSS_LOOKUP_KEY);
|
|
|
d702dc |
if (ret)
|
|
|
d702dc |
return ret;
|
|
|
d702dc |
|