Blame SOURCES/0034-cache_req-ignore-autofs-not-configured-error.patch

bac598
From 2499bd145f566bfd73b8c7e284b910dd2b36c6d1 Mon Sep 17 00:00:00 2001
bac598
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
bac598
Date: Fri, 15 Jan 2021 12:04:38 +0100
bac598
Subject: [PATCH] cache_req: ignore autofs not configured error
bac598
bac598
Otherwise we return ERR_OFFLINE for domains where autofs provider is not
bac598
set (such as implicit files domain) which is undesirable.
bac598
bac598
Steps to reproduce:
bac598
1. Enable implicit files domains and LDAP domain with autofs configured
bac598
2. Setup NFS server to export `/exports` with `/exports/home/test`
bac598
3. Add autofs mount points:
bac598
```
bac598
dn: ou=mount,dc=ldap,dc=vm
bac598
ou: mount
bac598
objectClass: organizationalUnit
bac598
objectClass: top
bac598
bac598
dn: nisMapName=auto.master,ou=mount,dc=ldap,dc=vm
bac598
objectClass: nisMap
bac598
objectClass: top
bac598
nisMapName: auto.master
bac598
bac598
dn: cn=/export/home,nisMapName=auto.master,ou=mount,dc=ldap,dc=vm
bac598
objectClass: nisObject
bac598
objectClass: top
bac598
cn: /export/home
bac598
nisMapEntry: auto.home
bac598
nisMapName: auto.master
bac598
bac598
dn: nisMapName=auto.home,ou=mount,dc=ldap,dc=vm
bac598
objectClass: nisMap
bac598
objectClass: top
bac598
nisMapName: auto.home
bac598
bac598
dn: cn=/,nisMapName=auto.home,ou=mount,dc=ldap,dc=vm
bac598
objectClass: nisObject
bac598
objectClass: top
bac598
cn: /
bac598
nisMapEntry: -fstype=nfs,rw master.ldap.vm:/export/home/&
bac598
nisMapName: auto.home
bac598
```
bac598
4. Run SSSD and autofs
bac598
5. cd to /exports/home/test
bac598
bac598
The directory will not be mounted with the new autofs protocol. It
bac598
will succeed with the old protocol. In both versions, you'll see
bac598
that SSSD returned ERR_OFFLINE:
bac598
bac598
```
bac598
(2021-01-15 11:44:48): [be[implicit_files]] [sbus_issue_request_done] (0x0040): sssd.DataProvider.Autofs.GetEntry: Error [1432158215]: DP target is not configured
bac598
...
bac598
(2021-01-15 11:44:49): [autofs] [cache_req_search_cache] (0x0400): CR #3: Looking up [auto.home:test] in cache
bac598
(2021-01-15 11:44:49): [autofs] [cache_req_search_cache] (0x0400): CR #3: Object [auto.home:test] was not found in cache
bac598
(2021-01-15 11:44:49): [autofs] [cache_req_search_ncache_add_to_domain] (0x2000): CR #3: This request type does not support negative cache
bac598
(2021-01-15 11:44:49): [autofs] [cache_req_process_result] (0x0400): CR #3: Finished: Error 1432158212: SSSD is offline
bac598
```
bac598
bac598
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
bac598
---
bac598
 .../cache_req/plugins/cache_req_autofs_entry_by_name.c | 10 +++++++++-
bac598
 .../cache_req/plugins/cache_req_autofs_map_by_name.c   | 10 +++++++++-
bac598
 .../cache_req/plugins/cache_req_autofs_map_entries.c   | 10 +++++++++-
bac598
 3 files changed, 27 insertions(+), 3 deletions(-)
bac598
bac598
diff --git a/src/responder/common/cache_req/plugins/cache_req_autofs_entry_by_name.c b/src/responder/common/cache_req/plugins/cache_req_autofs_entry_by_name.c
bac598
index cd2085187..f411fd351 100644
bac598
--- a/src/responder/common/cache_req/plugins/cache_req_autofs_entry_by_name.c
bac598
+++ b/src/responder/common/cache_req/plugins/cache_req_autofs_entry_by_name.c
bac598
@@ -92,7 +92,15 @@ bool
bac598
 cache_req_autofs_entry_by_name_dp_recv(struct tevent_req *subreq,
bac598
                                        struct cache_req *cr)
bac598
 {
bac598
-    return sbus_call_dp_autofs_GetEntry_recv(subreq) == EOK;
bac598
+    errno_t ret;
bac598
+
bac598
+    ret = sbus_call_dp_autofs_GetEntry_recv(subreq);
bac598
+
bac598
+    if (ret == ERR_MISSING_DP_TARGET) {
bac598
+        ret = EOK;
bac598
+    }
bac598
+
bac598
+    return ret == EOK;
bac598
 }
bac598
 
bac598
 const struct cache_req_plugin cache_req_autofs_entry_by_name = {
bac598
diff --git a/src/responder/common/cache_req/plugins/cache_req_autofs_map_by_name.c b/src/responder/common/cache_req/plugins/cache_req_autofs_map_by_name.c
bac598
index 9d9bc3a97..c22cf0c8e 100644
bac598
--- a/src/responder/common/cache_req/plugins/cache_req_autofs_map_by_name.c
bac598
+++ b/src/responder/common/cache_req/plugins/cache_req_autofs_map_by_name.c
bac598
@@ -88,7 +88,15 @@ bool
bac598
 cache_req_autofs_map_by_name_dp_recv(struct tevent_req *subreq,
bac598
                                      struct cache_req *cr)
bac598
 {
bac598
-    return sbus_call_dp_autofs_GetMap_recv(subreq) == EOK;
bac598
+    errno_t ret;
bac598
+
bac598
+    ret = sbus_call_dp_autofs_GetMap_recv(subreq);
bac598
+
bac598
+    if (ret == ERR_MISSING_DP_TARGET) {
bac598
+        ret = EOK;
bac598
+    }
bac598
+
bac598
+    return ret == EOK;
bac598
 }
bac598
 
bac598
 const struct cache_req_plugin cache_req_autofs_map_by_name = {
bac598
diff --git a/src/responder/common/cache_req/plugins/cache_req_autofs_map_entries.c b/src/responder/common/cache_req/plugins/cache_req_autofs_map_entries.c
bac598
index ee0156b6a..4d9db6595 100644
bac598
--- a/src/responder/common/cache_req/plugins/cache_req_autofs_map_entries.c
bac598
+++ b/src/responder/common/cache_req/plugins/cache_req_autofs_map_entries.c
bac598
@@ -120,7 +120,15 @@ bool
bac598
 cache_req_autofs_map_entries_dp_recv(struct tevent_req *subreq,
bac598
                                      struct cache_req *cr)
bac598
 {
bac598
-    return sbus_call_dp_autofs_Enumerate_recv(subreq) == EOK;
bac598
+    errno_t ret;
bac598
+
bac598
+    ret = sbus_call_dp_autofs_Enumerate_recv(subreq);
bac598
+
bac598
+    if (ret == ERR_MISSING_DP_TARGET) {
bac598
+        ret = EOK;
bac598
+    }
bac598
+
bac598
+    return ret == EOK;
bac598
 }
bac598
 
bac598
 const struct cache_req_plugin cache_req_autofs_map_entries = {
bac598
-- 
bac598
2.21.3
bac598