|
|
63b9c2 |
autofs-5.1.6 - improve sss setautomntent() error handling
|
|
|
63b9c2 |
|
|
|
63b9c2 |
From: Ian Kent <raven@themaw.net>
|
|
|
63b9c2 |
|
|
|
63b9c2 |
Recent versions of the sss autofs access library will return EHOSTDOWN
|
|
|
63b9c2 |
if the backend server is down.
|
|
|
63b9c2 |
|
|
|
63b9c2 |
The presence of this improvement in error handling is determined by an
|
|
|
63b9c2 |
added function to get the sss autofs protocol version.
|
|
|
63b9c2 |
|
|
|
63b9c2 |
Update the setautomntent() function to use this.
|
|
|
63b9c2 |
|
|
|
63b9c2 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
63b9c2 |
---
|
|
|
63b9c2 |
CHANGELOG | 1 +
|
|
|
63b9c2 |
modules/lookup_sss.c | 72 ++++++++++++++++++++++++++++++++++++++------------
|
|
|
63b9c2 |
2 files changed, 55 insertions(+), 18 deletions(-)
|
|
|
63b9c2 |
|
|
|
63b9c2 |
diff --git a/CHANGELOG b/CHANGELOG
|
|
|
63b9c2 |
index 141658d..5ccd787 100644
|
|
|
63b9c2 |
--- a/CHANGELOG
|
|
|
63b9c2 |
+++ b/CHANGELOG
|
|
|
63b9c2 |
@@ -99,6 +99,7 @@ xx/xx/2018 autofs-5.1.5
|
|
|
63b9c2 |
- add support for new sss autofs proto version call.
|
|
|
63b9c2 |
- fix retries check in setautomntent_wait().
|
|
|
63b9c2 |
- refactor sss setautomntent().
|
|
|
63b9c2 |
+- improve sss setautomntent() error handling.
|
|
|
63b9c2 |
|
|
|
63b9c2 |
19/12/2017 autofs-5.1.4
|
|
|
63b9c2 |
- fix spec file url.
|
|
|
63b9c2 |
diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c
|
|
|
63b9c2 |
index 011b232..e1ed83c 100644
|
|
|
63b9c2 |
--- a/modules/lookup_sss.c
|
|
|
63b9c2 |
+++ b/modules/lookup_sss.c
|
|
|
63b9c2 |
@@ -259,16 +259,37 @@ static int setautomntent_wait(unsigned int logopt,
|
|
|
63b9c2 |
*sss_ctxt = NULL;
|
|
|
63b9c2 |
|
|
|
63b9c2 |
retries = defaults_get_sss_master_map_wait();
|
|
|
63b9c2 |
- if (retries <= 0)
|
|
|
63b9c2 |
- return ENOENT;
|
|
|
63b9c2 |
+
|
|
|
63b9c2 |
+ /* If sss_master_map_wait is not set in the autofs
|
|
|
63b9c2 |
+ * configuration give it a sensible value since we
|
|
|
63b9c2 |
+ * want to wait for a host that's down in case it
|
|
|
63b9c2 |
+ * comes back up.
|
|
|
63b9c2 |
+ */
|
|
|
63b9c2 |
+ if (retries <= 0) {
|
|
|
63b9c2 |
+ /* Protocol version 0 cant't tell us about
|
|
|
63b9c2 |
+ * a host being down, return not found.
|
|
|
63b9c2 |
+ */
|
|
|
63b9c2 |
+ if (proto_version(ctxt) == 0)
|
|
|
63b9c2 |
+ return ENOENT;
|
|
|
63b9c2 |
+ retries = 10;
|
|
|
63b9c2 |
+ }
|
|
|
63b9c2 |
+
|
|
|
63b9c2 |
+ warn(logopt,
|
|
|
63b9c2 |
+ "can't connect to sssd, retry for %d seconds",
|
|
|
63b9c2 |
+ retries);
|
|
|
63b9c2 |
|
|
|
63b9c2 |
while (++retry <= retries) {
|
|
|
63b9c2 |
struct timespec t = { SSS_WAIT_INTERVAL, 0 };
|
|
|
63b9c2 |
struct timespec r;
|
|
|
63b9c2 |
|
|
|
63b9c2 |
ret = ctxt->setautomntent(ctxt->mapname, sss_ctxt);
|
|
|
63b9c2 |
- if (ret != ENOENT)
|
|
|
63b9c2 |
- break;
|
|
|
63b9c2 |
+ if (proto_version(ctxt) == 0) {
|
|
|
63b9c2 |
+ if (ret != ENOENT)
|
|
|
63b9c2 |
+ break;
|
|
|
63b9c2 |
+ } else {
|
|
|
63b9c2 |
+ if (ret != EHOSTDOWN)
|
|
|
63b9c2 |
+ break;
|
|
|
63b9c2 |
+ }
|
|
|
63b9c2 |
|
|
|
63b9c2 |
if (*sss_ctxt) {
|
|
|
63b9c2 |
free(*sss_ctxt);
|
|
|
63b9c2 |
@@ -279,17 +300,17 @@ static int setautomntent_wait(unsigned int logopt,
|
|
|
63b9c2 |
memcpy(&t, &r, sizeof(struct timespec));
|
|
|
63b9c2 |
}
|
|
|
63b9c2 |
|
|
|
63b9c2 |
-
|
|
|
63b9c2 |
- if (ret) {
|
|
|
63b9c2 |
+ if (!ret)
|
|
|
63b9c2 |
+ info(logopt, "successfully connected to sssd");
|
|
|
63b9c2 |
+ else {
|
|
|
63b9c2 |
if (*sss_ctxt) {
|
|
|
63b9c2 |
free(*sss_ctxt);
|
|
|
63b9c2 |
*sss_ctxt = NULL;
|
|
|
63b9c2 |
}
|
|
|
63b9c2 |
|
|
|
63b9c2 |
- if (retry > retries)
|
|
|
63b9c2 |
+ if (proto_version(ctxt) == 0 && retry > retries)
|
|
|
63b9c2 |
ret = ETIMEDOUT;
|
|
|
63b9c2 |
}
|
|
|
63b9c2 |
-
|
|
|
63b9c2 |
return ret;
|
|
|
63b9c2 |
}
|
|
|
63b9c2 |
|
|
|
63b9c2 |
@@ -298,35 +319,50 @@ static int setautomntent(unsigned int logopt,
|
|
|
63b9c2 |
{
|
|
|
63b9c2 |
char buf[MAX_ERR_BUF];
|
|
|
63b9c2 |
char *estr;
|
|
|
63b9c2 |
+ int err = NSS_STATUS_UNAVAIL;
|
|
|
63b9c2 |
int ret;
|
|
|
63b9c2 |
|
|
|
63b9c2 |
ret = ctxt->setautomntent(ctxt->mapname, sss_ctxt);
|
|
|
63b9c2 |
if (ret) {
|
|
|
63b9c2 |
- if (ret == ECONNREFUSED)
|
|
|
63b9c2 |
- return NSS_STATUS_UNKNOWN;
|
|
|
63b9c2 |
-
|
|
|
63b9c2 |
- if (ret != ENOENT)
|
|
|
63b9c2 |
+ if (ret == ECONNREFUSED) {
|
|
|
63b9c2 |
+ err = NSS_STATUS_UNKNOWN;
|
|
|
63b9c2 |
goto error;
|
|
|
63b9c2 |
+ }
|
|
|
63b9c2 |
+
|
|
|
63b9c2 |
+ if (proto_version(ctxt) == 0) {
|
|
|
63b9c2 |
+ if (ret != ENOENT)
|
|
|
63b9c2 |
+ goto error;
|
|
|
63b9c2 |
+ } else {
|
|
|
63b9c2 |
+ if (ret != ENOENT && ret != EHOSTDOWN)
|
|
|
63b9c2 |
+ goto error;
|
|
|
63b9c2 |
+ }
|
|
|
63b9c2 |
|
|
|
63b9c2 |
ret = setautomntent_wait(logopt, ctxt, sss_ctxt);
|
|
|
63b9c2 |
if (ret) {
|
|
|
63b9c2 |
- if (ret == ECONNREFUSED)
|
|
|
63b9c2 |
- return NSS_STATUS_UNKNOWN;
|
|
|
63b9c2 |
- if (ret == ENOENT)
|
|
|
63b9c2 |
- return NSS_STATUS_NOTFOUND;
|
|
|
63b9c2 |
+ if (ret == ECONNREFUSED) {
|
|
|
63b9c2 |
+ err = NSS_STATUS_UNKNOWN;
|
|
|
63b9c2 |
+ goto error;
|
|
|
63b9c2 |
+ }
|
|
|
63b9c2 |
+ if (ret == ETIMEDOUT)
|
|
|
63b9c2 |
+ goto error;
|
|
|
63b9c2 |
+ if (ret == ENOENT) {
|
|
|
63b9c2 |
+ err = NSS_STATUS_NOTFOUND;
|
|
|
63b9c2 |
+ goto free;
|
|
|
63b9c2 |
+ }
|
|
|
63b9c2 |
goto error;
|
|
|
63b9c2 |
}
|
|
|
63b9c2 |
}
|
|
|
63b9c2 |
- return ret;
|
|
|
63b9c2 |
+ return NSS_STATUS_SUCCESS;
|
|
|
63b9c2 |
|
|
|
63b9c2 |
error:
|
|
|
63b9c2 |
estr = strerror_r(ret, buf, MAX_ERR_BUF);
|
|
|
63b9c2 |
error(logopt, MODPREFIX "setautomntent: %s", estr);
|
|
|
63b9c2 |
+free:
|
|
|
63b9c2 |
if (*sss_ctxt) {
|
|
|
63b9c2 |
free(*sss_ctxt);
|
|
|
63b9c2 |
*sss_ctxt = NULL;
|
|
|
63b9c2 |
}
|
|
|
63b9c2 |
- return NSS_STATUS_UNAVAIL;
|
|
|
63b9c2 |
+ return err;
|
|
|
63b9c2 |
}
|
|
|
63b9c2 |
|
|
|
63b9c2 |
static int endautomntent(unsigned int logopt,
|