summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorFabiano Fidêncio <fidencio@redhat.com>2017-03-22 13:40:20 +0100
committerJakub Hrozek <jhrozek@redhat.com>2017-03-29 14:00:17 +0200
commit3cbf0e7b63e8e6888917e9215bbdc5674c2fa852 (patch)
tree32676a3251ab0c770bbeb6b53abea700a4e67b67 /src/db
parent723d514f641e2b5a5cbfe1c6c7bdd2a6f3c5070e (diff)
downloadsssd-3cbf0e7b63e8e6888917e9215bbdc5674c2fa852.tar.gz
sssd-3cbf0e7b63e8e6888917e9215bbdc5674c2fa852.tar.xz
sssd-3cbf0e7b63e8e6888917e9215bbdc5674c2fa852.zip
IPA: Get ipaDomainsResolutionOrder from ipaConfig
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.h11
-rw-r--r--src/db/sysdb_subdomains.c67
2 files changed, 78 insertions, 0 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 42d2857ed..75a07d4d2 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -489,6 +489,17 @@ int sysdb_transaction_cancel(struct sysdb_ctx *sysdb);
/* functions related to subdomains */
errno_t sysdb_domain_create(struct sysdb_ctx *sysdb, const char *domain_name);
+errno_t sysdb_domain_get_domain_resolution_order(
+ TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *sysdb,
+ const char *domain_name,
+ const char **_domain_resolution_order);
+
+errno_t sysdb_domain_update_domain_resolution_order(
+ struct sysdb_ctx *sysdb,
+ const char *domain_name,
+ const char *domain_resolution_order);
+
errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb,
const char *name, const char *realm,
const char *flat_name, const char *domain_id,
diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c
index 916dbba15..e2a4f7bb1 100644
--- a/src/db/sysdb_subdomains.c
+++ b/src/db/sysdb_subdomains.c
@@ -22,6 +22,7 @@
#include "util/util.h"
#include "db/sysdb_private.h"
+#include "db/sysdb_domain_resolution_order.h"
static errno_t
check_subdom_config_file(struct confdb_ctx *confdb,
@@ -1210,3 +1211,69 @@ done:
talloc_free(tmp_ctx);
return ret;
}
+
+errno_t
+sysdb_domain_get_domain_resolution_order(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *sysdb,
+ const char *domain_name,
+ 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_fmt(tmp_ctx, sysdb->ldb, SYSDB_DOM_BASE, domain_name);
+ 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_domain_update_domain_resolution_order(struct sysdb_ctx *sysdb,
+ const char *domain_name,
+ 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_fmt(tmp_ctx, sysdb->ldb, SYSDB_DOM_BASE, domain_name);
+ 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;
+}