summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorFabiano Fidêncio <fidencio@redhat.com>2017-03-24 17:46:04 +0100
committerJakub Hrozek <jhrozek@redhat.com>2017-03-29 14:00:17 +0200
commitfb81f337b68c85471c3f5140850dccf549a2d0ac (patch)
treeff78340243e571d997badc4dc0dee617286d8023 /src/db
parent17ab121a6c69d74acf1d40f2bbcbe90d77bb6b8a (diff)
downloadsssd-fb81f337b68c85471c3f5140850dccf549a2d0ac.tar.gz
sssd-fb81f337b68c85471c3f5140850dccf549a2d0ac.tar.xz
sssd-fb81f337b68c85471c3f5140850dccf549a2d0ac.zip
IPA: Get ipaDomainsResolutionOrder from IPA ID View
ipaDomainsResolutionOrder provides a list of domains that have to be looked up firstly during cache_req searches. This commit only fetches this list from the server and stores its value at sysdb so we can make use of it later on this patch series. There are no tests for newly introduced sysdb methods are those are basically only calling sysdb_update_domain_resolution_order(), sysdb_get_domain_resolution_order() and sysdb_get_use_domain_resolution_order() which are have tests written for. Related: https://pagure.io/SSSD/sssd/issue/3001 Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Sumit Bose <sbose@redhat.com> Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.h9
-rw-r--r--src/db/sysdb_views.c66
2 files changed, 75 insertions, 0 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 75a07d4d2..62c561be9 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -533,6 +533,15 @@ errno_t sysdb_update_view_name(struct sysdb_ctx *sysdb, const char *view_name);
errno_t sysdb_get_view_name(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb,
char **view_name);
+errno_t sysdb_update_view_domain_resolution_order(
+ struct sysdb_ctx *sysdb,
+ const char *domain_resolution_order);
+
+errno_t sysdb_get_view_domain_resolution_order(
+ TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *sysdb,
+ const char **_domain_resolution_order);
+
static inline bool is_default_view(const char *view_name)
{
/* NULL is treated as default */
diff --git a/src/db/sysdb_views.c b/src/db/sysdb_views.c
index 1c416dd14..20db9b061 100644
--- a/src/db/sysdb_views.c
+++ b/src/db/sysdb_views.c
@@ -22,6 +22,9 @@
#include "util/util.h"
#include "util/cert.h"
#include "db/sysdb_private.h"
+#include "db/sysdb_domain_resolution_order.h"
+
+#define SYSDB_VIEWS_BASE "cn=views,cn=sysdb"
/* In general is should not be possible that there is a view container without
* a view name set. But to be on the safe side we return both information
@@ -179,6 +182,69 @@ done:
return ret;
}
+errno_t
+sysdb_get_view_domain_resolution_order(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *sysdb,
+ const char **_domain_resolution_order)
+{
+ TALLOC_CTX *tmp_ctx;
+ struct ldb_dn *dn;
+ errno_t ret;
+
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ return ENOMEM;
+ }
+
+ dn = ldb_dn_new(tmp_ctx, sysdb->ldb, SYSDB_VIEWS_BASE);
+ if (dn == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ ret = sysdb_get_domain_resolution_order(mem_ctx, sysdb, dn,
+ _domain_resolution_order);
+
+done:
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
+errno_t
+sysdb_update_view_domain_resolution_order(struct sysdb_ctx *sysdb,
+ const char *domain_resolution_order)
+{
+ TALLOC_CTX *tmp_ctx;
+ struct ldb_dn *dn;
+ errno_t ret;
+
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ return ENOMEM;
+ }
+
+ dn = ldb_dn_new(tmp_ctx, sysdb->ldb, SYSDB_VIEWS_BASE);
+ if (dn == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ ret = sysdb_update_domain_resolution_order(sysdb, dn,
+ domain_resolution_order);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE,
+ "sysdb_update_domain_resolution_order() failed [%d]: [%s].\n",
+ ret, sss_strerror(ret));
+ goto done;
+ }
+
+ ret = EOK;
+
+done:
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
errno_t sysdb_delete_view_tree(struct sysdb_ctx *sysdb, const char *view_name)
{
struct ldb_dn *dn;