Please see the simple attached patch. To reproduce, start sssd in
offline mode and attempt to authenticate as subdomain user.
>From bb5bee72aa6a8c6f47af74a6786b5c6d3e77dac6 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhro...@redhat.com>
Date: Thu, 28 Nov 2013 15:26:21 +0100
Subject: [PATCH] SUBDOMAINS: Reuse cached results if DP is offline

If Data Provider was unable to refresh the subdomain list, the
sss_domain_info->subdomains list was NULL. Which meant that no DP
request matched any known domain and hence offline authentication was
not working correctly.
---
 src/providers/ad/ad_subdomains.c   | 10 ++++++++--
 src/providers/ipa/ipa_subdomains.c | 10 +++++++---
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c
index 
73190faa1e7e995123f12e2200ab00fb40f3b256..2b96a3f08e7d6ae0ff4ba6be76c1c1fd8a6cdd77
 100644
--- a/src/providers/ad/ad_subdomains.c
+++ b/src/providers/ad/ad_subdomains.c
@@ -349,8 +349,14 @@ static void ad_subdomains_get_conn_done(struct tevent_req 
*req)
     if (ret) {
         if (dp_error == DP_ERR_OFFLINE) {
             DEBUG(SSSDBG_MINOR_FAILURE,
-                  ("No AD server is available, cannot get the "
-                   "subdomain list while offline\n"));
+                  ("No AD server is available, cannot get the subdomain "
+                   "list while offline. Will reuse cached subdomains.\n"));
+
+            ret = sysdb_update_subdomains(ctx->sd_ctx->be_ctx->domain);
+            if (ret != EOK) {
+                DEBUG(SSSDBG_OP_FAILURE, ("sysdb_update_subdomains 
failed.\n"));
+                goto fail;
+            }
         } else {
             DEBUG(SSSDBG_OP_FAILURE,
                   ("Failed to connect to AD server: [%d](%s)\n",
diff --git a/src/providers/ipa/ipa_subdomains.c 
b/src/providers/ipa/ipa_subdomains.c
index 
4f7627eddb9c54d68e45be876157057f3c30b422..ea7fb0fa0232028e130bbff53f1d839620c44719
 100644
--- a/src/providers/ipa/ipa_subdomains.c
+++ b/src/providers/ipa/ipa_subdomains.c
@@ -807,10 +807,14 @@ static void ipa_subdomains_get_conn_done(struct 
tevent_req *req)
     if (ret) {
         if (dp_error == DP_ERR_OFFLINE) {
             DEBUG(SSSDBG_MINOR_FAILURE,
-                  ("No IPA server is available, cannot get the "
-                   "subdomain list while offline\n"));
+                  ("No IPA server is available, cannot get the subdomain "
+                   "list while offline. Will reuse cached subdomains.\n"));
 
-/* FIXME: return saved results ?? */
+            ret = sysdb_update_subdomains(ctx->sd_ctx->be_ctx->domain);
+            if (ret != EOK) {
+                DEBUG(SSSDBG_OP_FAILURE, ("sysdb_update_subdomains 
failed.\n"));
+                goto fail;
+            }
         } else {
             DEBUG(SSSDBG_OP_FAILURE,
                   ("Failed to connect to IPA server: [%d](%s)\n",
-- 
1.8.4.2

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to