summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Reichl <preichl@redhat.com>2014-10-30 11:54:54 +0000
committerJakub Hrozek <jhrozek@redhat.com>2014-11-19 23:44:52 +0100
commita5b55bdfcda8bfce8cb2ced981773998093d7857 (patch)
tree0787a4fc02735026a604e9f00166a6a70cc93764
parent02011187307ce97d1f41810288b617682a1f311a (diff)
downloadsssd-a5b55bdfcda8bfce8cb2ced981773998093d7857.zip
sssd-a5b55bdfcda8bfce8cb2ced981773998093d7857.tar.gz
sssd-a5b55bdfcda8bfce8cb2ced981773998093d7857.tar.xz
SYSDB: sysdb_idmap_get_mappings returns ENOENT
sysdb_idmap_get_mappings returns ENOENT if no results were found. Part od solution for: https://fedorahosted.org/sssd/ticket/1991 Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
-rw-r--r--src/db/sysdb_idmap.c11
-rw-r--r--src/providers/ldap/sdap_idmap.c2
-rw-r--r--src/tests/sysdb-tests.c6
3 files changed, 12 insertions, 7 deletions
diff --git a/src/db/sysdb_idmap.c b/src/db/sysdb_idmap.c
index 7d34267..2c3634d 100644
--- a/src/db/sysdb_idmap.c
+++ b/src/db/sysdb_idmap.c
@@ -280,7 +280,6 @@ sysdb_idmap_get_mappings(TALLOC_CTX *mem_ctx,
struct ldb_result **_result)
{
errno_t ret;
- int lret;
struct ldb_dn *base_dn;
TALLOC_CTX *tmp_ctx;
struct ldb_result *res;
@@ -298,19 +297,19 @@ sysdb_idmap_get_mappings(TALLOC_CTX *mem_ctx,
goto done;
}
- lret = ldb_search(domain->sysdb->ldb, tmp_ctx, &res, base_dn,
- LDB_SCOPE_SUBTREE, attrs, SYSDB_IDMAP_FILTER);
- if (lret) {
+ SSS_LDB_SEARCH(ret, domain->sysdb->ldb, tmp_ctx, &res, base_dn,
+ LDB_SCOPE_SUBTREE, attrs, SYSDB_IDMAP_FILTER);
+ if (ret != EOK) {
DEBUG(SSSDBG_MINOR_FAILURE,
"Could not locate ID mappings: [%s]\n",
- ldb_strerror(lret));
- ret = sysdb_error_to_errno(lret);
+ sss_strerror(ret));
goto done;
}
*_result = talloc_steal(mem_ctx, res);
ret = EOK;
+
done:
talloc_free(tmp_ctx);
return ret;
diff --git a/src/providers/ldap/sdap_idmap.c b/src/providers/ldap/sdap_idmap.c
index 3826035..0a82e61 100644
--- a/src/providers/ldap/sdap_idmap.c
+++ b/src/providers/ldap/sdap_idmap.c
@@ -230,7 +230,7 @@ sdap_idmap_init(TALLOC_CTX *mem_ctx,
goto done;
}
- if (ret == EOK && res->count > 0) {
+ if (ret == EOK) {
DEBUG(SSSDBG_CONF_SETTINGS,
"Initializing [%d] domains for ID-mapping\n", res->count);
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index e01ddf4..d603a7a 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -4746,6 +4746,12 @@ START_TEST (test_sysdb_search_return_ENOENT)
fail_if(ret != EOK, "Could not set up the test");
check_leaks_push(test_ctx);
+ /* id mapping */
+ ret = sysdb_idmap_get_mappings(test_ctx, test_ctx->domain, &res);
+ fail_unless(ret == ENOENT, "sysdb_idmap_get_mappings error [%d][%s].",
+ ret, strerror(ret));
+ talloc_zfree(res);
+
/* Search user */
ret = sysdb_search_user_by_name(test_ctx, test_ctx->domain,
"nonexisting_user", NULL, &msg);