autofs-5.1.9 - handle sss special case getautomntbyname() error

From: Ian Kent <raven@themaw.net>

The sss key lookup (via getautomntbyname()) returns EHOSTDOWN when the
entry is invalid, such as when the location is empty. But setatomntent()
has already been called successfully so we know the host is up and the
map exists hence this probably should be EINVAL.

In both these cases the better return is NSS_STATUS_UNAVAIL.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG            |    1 +
 modules/lookup_sss.c |    6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index ce1e82ae4..f3363d5a7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -27,6 +27,7 @@
 - log when setting amd per-mount timeout.
 - update per-mount expire timeout on readmap.
 - clear per-mount timeout if not set.
+- handle sss special case getautomntbyname() error.
 
 02/11/2023 autofs-5.1.9
 - fix kernel mount status notification.
diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c
index 19e840a54..4eaa4b3e3 100644
--- a/modules/lookup_sss.c
+++ b/modules/lookup_sss.c
@@ -658,8 +658,8 @@ static int getautomntbyname(unsigned int logopt,
 				err = NSS_STATUS_NOTFOUND;
 				goto free;
 			}
-			if (ret != EHOSTDOWN)
-				goto error;
+			if (ret == EINVAL || ret == EHOSTDOWN)
+				goto free;
 		}
 
 		ret = getautomntbyname_wait(logopt, ctxt,
@@ -670,7 +670,7 @@ static int getautomntbyname(unsigned int logopt,
 			if (ret == ETIMEDOUT)
 				goto error;
 			/* sss proto version 0 and sss timeout not set */
-			if (ret == EINVAL)
+			if (ret == EINVAL || ret == EHOSTDOWN)
 				goto free;
 			if (ret == ENOENT) {
 				err = NSS_STATUS_NOTFOUND;
