dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

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

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