From b9e155da725e711ab306ca8a96e3ba6fbda41a3a Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Sep 21 2016 08:12:47 +0000 Subject: AUTOFS: Fix offline resolution of autofs maps If talking to the Data Provider failed, we never re-tried looking into the cache. We should consult the cache on DP failures and return cached results, if possible. Resolves: https://fedorahosted.org/sssd/ticket/3080 Reviewed-by: Pavel Březina --- diff --git a/src/responder/autofs/autofssrv_cmd.c b/src/responder/autofs/autofssrv_cmd.c index 9666ab2..f5aa25a 100644 --- a/src/responder/autofs/autofssrv_cmd.c +++ b/src/responder/autofs/autofssrv_cmd.c @@ -871,17 +871,25 @@ static void lookup_automntmap_cache_updated(uint16_t err_maj, uint32_t err_min, if (err_maj) { DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get information from Data Provider\n" - "Error: %u, %u, %s\n" - "Will try to return what we have in cache\n", + "Error: %u, %u, %s\n" + "Will try to return what we have in cache\n", (unsigned int)err_maj, (unsigned int)err_min, err_msg); - /* Loop to the next domain if possible */ + + /* Try to fall back to cache */ + ret = lookup_automntmap_step(lookup_ctx); + if (ret == EOK) { + /* We have cached results to return */ + autofs_setent_notify(lookup_ctx->map, ret); + return; + } + + /* Otherwise try the next domain */ if (dctx->cmd_ctx->check_next && (dctx->domain = get_next_domain(dctx->domain, 0))) { dctx->check_provider = NEED_CHECK_PROVIDER(dctx->domain->provider); } } - /* ok the backend returned, search to see if we have updated results */ ret = lookup_automntmap_step(lookup_ctx); if (ret != EOK) { if (ret == EAGAIN) {