From e0b3434fa61802610e7649596ea35463018258bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Thu, 3 Jul 2014 12:45:43 +0200
Subject: [PATCH 1/2] ad: continue on ENOENT when id mapping is disabled

When ID mapping is disabled and tokengroups are used we need to
resolve SIDs and store group objects first. However, tokengroups
may contain also built-in non posix groups. This may cause the
process to fail if search base is set and the built-in groups
are not found because of the search base.

This patch simply ignores groups that were not found.
---
 src/providers/ldap/sdap_async_initgroups_ad.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/providers/ldap/sdap_async_initgroups_ad.c b/src/providers/ldap/sdap_async_initgroups_ad.c
index 80e4f29ad8556944c42669350339f62cfb28b36e..4c5f40bdf2c6235fdeb1cb88261ec17dd06226a1 100644
--- a/src/providers/ldap/sdap_async_initgroups_ad.c
+++ b/src/providers/ldap/sdap_async_initgroups_ad.c
@@ -644,7 +644,13 @@ static void sdap_ad_resolve_sids_done(struct tevent_req *subreq)
 
     ret = groups_get_recv(subreq, &dp_error, &sdap_error);
     talloc_zfree(subreq);
-    if (ret != EOK || sdap_error != EOK || dp_error != DP_ERR_OK) {
+    if (ret == EOK && dp_error == DP_ERR_OK && sdap_error == ENOENT) {
+        /* Group was not found, we will ignore the error and continue with
+         * next group. This may happen for example if the group is built-in,
+         * but a custom search base is provided. */
+        DEBUG(SSSDBG_MINOR_FAILURE, "SID %s was not found\n",
+              state->current_sid);
+    } else if (ret != EOK || sdap_error != EOK || dp_error != DP_ERR_OK) {
         DEBUG(SSSDBG_CRIT_FAILURE, "Unable to resolve SID %s [dp_error: %d, "
               "sdap_error: %d, ret: %d]: %s\n", state->current_sid, dp_error,
               sdap_error, ret, strerror(ret));
-- 
1.7.11.7

