>From 3ec4b7d858621b0840f1929cb9fe5c9f1c408b06 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 26 May 2015 12:47:08 +0200 Subject: [PATCH 21/29] NOSUBMIT: Fake trust direction --- src/providers/ipa/ipa_subdomains_server.c | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/providers/ipa/ipa_subdomains_server.c b/src/providers/ipa/ipa_subdomains_server.c index eb4867c2665084ac17472b3370ef3007a9140607..83a3018dec29a847478c163d4cce2ce623d60c0f 100644 --- a/src/providers/ipa/ipa_subdomains_server.c +++ b/src/providers/ipa/ipa_subdomains_server.c @@ -50,6 +50,39 @@ static char *subdomain_trust_princ(TALLOC_CTX *mem_ctx, return talloc_asprintf(mem_ctx, "%s$@%s", sd->parent->flat_name, forest); } +struct fake_trust_dir { + const char *name; + uint32_t direction; +}; + +struct fake_trust_dir fakedirs[] = { + { .name = "AD.EXAMPLE.COM", .direction = LSA_TRUST_DIRECTION_OUTBOUND }, + { .name = NULL, .direction = 0 }, +}; + +static errno_t NOSUBMIT_fake_trust_direction(struct sysdb_attrs *sd, + errno_t orig_ret, + uint32_t direction, + uint32_t *direction_out) +{ + errno_t ret; + const char *name; + size_t c; + + ret = sysdb_attrs_get_string(sd, "cn", &name); + if (ret == EOK) { + for (c = 0; fakedirs[c].name != NULL; c++) { + if (strcasecmp(name, fakedirs[c].name) == 0) { + *direction_out = fakedirs[c].direction; + return ret; + } + } + } + + *direction_out = direction; + return orig_ret; +} + static enum trust_direction default_direction(TALLOC_CTX *mem_ctx, struct ldb_context *ldb_ctx, struct sysdb_attrs *attrs) @@ -89,6 +122,9 @@ errno_t ipa_server_get_trust_direction(struct sysdb_attrs *sd, &ipa_trust_direction); DEBUG(SSSDBG_TRACE_INTERNAL, "Raw %s value: %d\n", IPA_TRUST_DIRECTION, ipa_trust_direction); + ret = NOSUBMIT_fake_trust_direction(sd, ret, ipa_trust_direction, &ipa_trust_direction); + DEBUG(SSSDBG_TRACE_INTERNAL, + "Faked %s value: %d\n", IPA_TRUST_DIRECTION, ipa_trust_direction); if (ret == ENOENT) { direction = default_direction(sd, ldb_ctx, sd); } else if (ret == EOK) { -- 2.1.0