ad_subdomains.c revision 49f38702e62bbd1728757063ba407444e6270952
a78048ccbdb6256da15e6b0e7e95355e480c2301nd AD Subdomains Module
a78048ccbdb6256da15e6b0e7e95355e480c2301nd Sumit Bose <sbose@redhat.com>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd Copyright (C) 2013 Red Hat
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen This program is free software; you can redistribute it and/or modify
2e545ce2450a9953665f701bb05350f0d3f26275nd it under the terms of the GNU General Public License as published by
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen the Free Software Foundation; either version 3 of the License, or
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen (at your option) any later version.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd This program is distributed in the hope that it will be useful,
a78048ccbdb6256da15e6b0e7e95355e480c2301nd but WITHOUT ANY WARRANTY; without even the implied warranty of
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3f08db06526d6901aa08c110b5bc7dde6bc39905nd GNU General Public License for more details.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd You should have received a copy of the GNU General Public License
a78048ccbdb6256da15e6b0e7e95355e480c2301nd along with this program. If not, see <http://www.gnu.org/licenses/>.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd/* Attributes of AD trusted domains */
a78048ccbdb6256da15e6b0e7e95355e480c2301nd/* trustType=2 denotes uplevel (NT5 and later) trusted domains. See
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * http://msdn.microsoft.com/en-us/library/windows/desktop/ms680342%28v=vs.85%29.aspx
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * for example.
aa2ff7f8e8477e2b9d20dc2e72737d6bd5145465sf * The absence of msDS-TrustForestTrustInfo attribute denotes a domain from
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * the same forest. See http://msdn.microsoft.com/en-us/library/cc223786.aspx
acf65805923cf80834c39689cc0e2a8e7201c186sf * for more information.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#define SLAVE_DOMAIN_FILTER_BASE "(objectclass=trustedDomain)(trustType=2)(!(msDS-TrustForestTrustInfo=*))"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#define SLAVE_DOMAIN_FILTER "(&"SLAVE_DOMAIN_FILTER_BASE")"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#define FOREST_ROOT_FILTER_FMT "(&"SLAVE_DOMAIN_FILTER_BASE"(cn=%s))"
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh/* do not refresh more often than every 5 seconds for now */
a78048ccbdb6256da15e6b0e7e95355e480c2301ndstatic errno_t ad_get_enabled_domains(TALLOC_CTX *mem_ctx,
a78048ccbdb6256da15e6b0e7e95355e480c2301nd const char *ad_domain,
a78048ccbdb6256da15e6b0e7e95355e480c2301nd const char ***_ad_enabled_domains)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd const char *str;
a78048ccbdb6256da15e6b0e7e95355e480c2301nd const char *option_name;
a78048ccbdb6256da15e6b0e7e95355e480c2301nd str = dp_opt_get_cstring(ad_id_ctx->ad_options->basic, AD_ENABLED_DOMAINS);
a78048ccbdb6256da15e6b0e7e95355e480c2301nd option_name = ad_id_ctx->ad_options->basic[AD_ENABLED_DOMAINS].opt_name;
a78048ccbdb6256da15e6b0e7e95355e480c2301nd DEBUG(SSSDBG_CRIT_FAILURE, "Failed to parse option [%s], [%i] [%s]!\n",
aa2ff7f8e8477e2b9d20dc2e72737d6bd5145465sf for (int i = 0; i < count; i++) {
aa2ff7f8e8477e2b9d20dc2e72737d6bd5145465sf is_ad_in_domains += strcmp(ad_domain, domains[i]) == 0 ? true : false;
aa2ff7f8e8477e2b9d20dc2e72737d6bd5145465sf if (is_ad_in_domains == false) {
bb7915b2b753442f98a887bec18d0267c9ce92bdsf domains = talloc_realloc(tmp_ctx, domains, const char*, count + 2);
a78048ccbdb6256da15e6b0e7e95355e480c2301nd domains = talloc_realloc(tmp_ctx, domains, const char*, count + 1);
a78048ccbdb6256da15e6b0e7e95355e480c2301nd const char *service_name;
acf65805923cf80834c39689cc0e2a8e7201c186sf const char *realm;
acf65805923cf80834c39689cc0e2a8e7201c186sf const char *hostname;
acf65805923cf80834c39689cc0e2a8e7201c186sf const char *keytab;
acf65805923cf80834c39689cc0e2a8e7201c186sf realm = dp_opt_get_cstring(id_ctx->ad_options->basic, AD_KRB5_REALM);
acf65805923cf80834c39689cc0e2a8e7201c186sf hostname = dp_opt_get_cstring(id_ctx->ad_options->basic, AD_HOSTNAME);
acf65805923cf80834c39689cc0e2a8e7201c186sf keytab = dp_opt_get_cstring(id_ctx->ad_options->basic, AD_KEYTAB);
acf65805923cf80834c39689cc0e2a8e7201c186sf if (realm == NULL || hostname == NULL || ad_domain == NULL) {
acf65805923cf80834c39689cc0e2a8e7201c186sf DEBUG(SSSDBG_CONF_SETTINGS, "Missing realm or hostname.\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ad_options = ad_create_2way_trust_options(id_ctx, realm, ad_domain,
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung DEBUG(SSSDBG_OP_FAILURE, "Cannot initialize AD options\n");
0d0ba3a410038e179b695446bb149cce6264e0abnd ad_site_override = dp_opt_get_string(ad_options->basic, AD_SITE);
727872d18412fc021f03969b8641810d8896820bhumbedooh gc_service_name = talloc_asprintf(ad_options, "sd_gc_%s", subdom->name);
0d0ba3a410038e179b695446bb149cce6264e0abnd service_name = talloc_asprintf(ad_options, "sd_%s", subdom->name);
205f749042ed530040a4f0080dbcb47ceae8a374rjung ret = ad_failover_init(ad_options, be_ctx, NULL, NULL, realm,
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd DEBUG(SSSDBG_OP_FAILURE, "Cannot initialize AD failover\n");
return ENOMEM;
return ENOMEM;
return ret;
return EFAULT;
return EOK;
struct ad_subdomains_ctx {
char *domain_name;
const char **ad_enabled_domains;
bool *_enumerates)
const char *name;
return ret;
return EOK;
static errno_t
bool enumerate)
const char *name;
char *realm;
const char *flat;
bool mpg;
goto done;
&trust_type);
goto done;
goto done;
if (!realm) {
goto done;
if (ret) {
name);
goto done;
goto done;
goto done;
goto done;
done:
return ret;
bool root_domain,
bool *_changes)
const char *value;
size_t c, h;
int ret;
bool enumerate;
if (root_domain) {
&root_name);
goto done;
for (c = 0; c < num_subdomains; c++) {
if (handled[c]) {
&value);
goto done;
if (c >= num_subdomains) {
goto done;
goto done;
if (ret) {
handled[c] = true;
if (num_subdomains == h) {
*_changes = false;
goto done;
*_changes = true;
for (c = 0; c < num_subdomains; c++) {
if (handled[c]) {
goto done;
if (ret) {
done:
*_last_refreshed = 0;
return ret;
const char *sd_name;
return EOK;
return ENOMEM;
sdi = 0;
for (i = 0; i < nsd; i++) {
goto fail;
sdi++;
return EOK;
fail:
return ret;
static errno_t
int ret;
return ret;
return EOK;
const char *path;
bool canonicalize;
return ret;
return ret;
return EOK;
struct ad_get_slave_domain_state {
static struct tevent_req *
struct ad_get_slave_domain_state);
return NULL;
goto immediately;
return req;
return req;
int ret;
return ret;
return EAGAIN;
int dp_error;
NULL, false, 0,
bool has_changes;
int dp_error;
goto done;
goto done;
goto done;
&has_changes);
goto done;
if (has_changes) {
goto done;
done:
return EOK;
static struct sss_domain_info *
const char *name;
return NULL;
return root;
static struct ad_id_ctx *
return NULL;
&root_id_ctx);
return NULL;
return root_id_ctx;
struct ad_get_root_domain_state {
static struct tevent_req *
const char *forest,
const char *filter;
return NULL;
goto immediately;
goto immediately;
goto immediately;
return req;
return req;
bool has_changes;
&reply);
goto done;
if (reply_count == 0) {
goto done;
goto done;
&has_changes);
goto done;
if (has_changes) {
goto done;
goto done;
goto done;
done:
return EOK;
struct ad_subdomains_refresh_state {
static struct tevent_req *
struct ad_subdomains_refresh_state);
return NULL;
goto immediately;
return req;
return req;
int ret;
return ret;
return EAGAIN;
int dp_error;
const char *realm;
char *master_sid;
char *flat_name;
char *forest;
goto done;
goto done;
goto done;
goto done;
goto done;
done:
int dp_error;
return EOK;
struct ad_subdomains_handler_state {
static struct tevent_req *
struct ad_subdomains_handler_state);
return NULL;
goto immediately;
goto immediately;
return req;
return req;
return EOK;
static struct tevent_req *
void *pvt)
static errno_t
const char *ad_domain;
return ENOMEM;
return EINVAL;
return ENOMEM;
return EOK;