ad_init.c revision 9a6ff0851fc707f21165818f66ae926fa14d7226
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina Stephen Gallagher <sgallagh@redhat.com>
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina Copyright (C) 2012 Red Hat
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina This program is free software; you can redistribute it and/or modify
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina it under the terms of the GNU General Public License as published by
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina the Free Software Foundation; either version 3 of the License, or
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina (at your option) any later version.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina This program is distributed in the hope that it will be useful,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina GNU General Public License for more details.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina You should have received a copy of the GNU General Public License
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
586fa3571753ab4a607d40fc31503fc0e8effd70Pavel Březinastatic int ad_sasl_getopt(void *context, const char *plugin_name,
586fa3571753ab4a607d40fc31503fc0e8effd70Pavel Březinatypedef int (*sss_sasl_gen_cb_fn)(void);
586fa3571753ab4a607d40fc31503fc0e8effd70Pavel Březinastatic int map_sasl2sssd_log_level(int sasl_level)
bf83a0faacf16196ab9bd37dcf6190b4209ccaf7Pavel Březina case SASL_LOG_ERR: /* log unusual errors (default) */
bf83a0faacf16196ab9bd37dcf6190b4209ccaf7Pavel Březina case SASL_LOG_FAIL: /* log all authentication failures */
bf83a0faacf16196ab9bd37dcf6190b4209ccaf7Pavel Březina case SASL_LOG_WARN: /* log non-fatal warnings */
bf83a0faacf16196ab9bd37dcf6190b4209ccaf7Pavel Březina case SASL_LOG_NOTE: /* more verbose than LOG_WARN */
bf83a0faacf16196ab9bd37dcf6190b4209ccaf7Pavel Březina case SASL_LOG_DEBUG: /* more verbose than LOG_NOTE */
bf83a0faacf16196ab9bd37dcf6190b4209ccaf7Pavel Březina case SASL_LOG_TRACE: /* traces of internal protocols */
bf83a0faacf16196ab9bd37dcf6190b4209ccaf7Pavel Březina case SASL_LOG_PASS: /* traces of internal protocols, including */
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březinaint ad_sasl_log(void *context, int level, const char *message)
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina if (level == SASL_LOG_ERR || level == SASL_LOG_FAIL) {
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březinastatic const sasl_callback_t ad_sasl_callbacks[] = {
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina { SASL_CB_GETOPT, (sss_sasl_gen_cb_fn)ad_sasl_getopt, NULL },
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina { SASL_CB_LOG, (sss_sasl_gen_cb_fn)ad_sasl_log, NULL },
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina/* This is quite a hack, we *try* to fool openldap libraries by initializing
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina * sasl first so we can pass in the SASL_CB_GETOPT callback we need to set some
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina * options. Should be removed as soon as openldap exposes a way to do that */
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březinastatic void ad_sasl_initialize(void)
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina /* NOTE: this may fail if soe other library in the system happens to
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina * initialize and use openldap libraries or directly the cyrus-sasl
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina * library as this initialization function can be called only once per
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina /* Get AD-specific options */
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina ret = ad_get_common_options(bectx, bectx->cdb,
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina "Could not parse common options: [%s]\n",
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina ad_servers = dp_opt_get_string(ad_options->basic, AD_SERVER);
bf83a0faacf16196ab9bd37dcf6190b4209ccaf7Pavel Březina ad_backup_servers = dp_opt_get_string(ad_options->basic, AD_BACKUP_SERVER);
bf83a0faacf16196ab9bd37dcf6190b4209ccaf7Pavel Březina ad_realm = dp_opt_get_string(ad_options->basic, AD_KRB5_REALM);
bf83a0faacf16196ab9bd37dcf6190b4209ccaf7Pavel Březina /* Set up the failover service */
bf83a0faacf16196ab9bd37dcf6190b4209ccaf7Pavel Březina ret = ad_failover_init(ad_options, bectx, ad_servers, ad_backup_servers, ad_realm,
bf83a0faacf16196ab9bd37dcf6190b4209ccaf7Pavel Březina dp_opt_get_string(ad_options->basic, AD_DOMAIN),
bf83a0faacf16196ab9bd37dcf6190b4209ccaf7Pavel Březina "Failed to init AD failover service: [%s]\n",
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* already initialized */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina ret = ad_dyndns_init(ad_ctx->sdap_id_ctx->be, ad_options);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina "Failure setting up automatic DNS update\n");
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Continue without DNS updates */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina "setup_child failed [%d][%s].\n",
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Set up various SDAP options */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina ret = ad_get_id_options(ad_options, bectx->cdb,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina ad_ctx->sdap_id_ctx->opts->sdom->pvt = ad_ctx;
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Set up the ID mapping object */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina ret = sdap_idmap_init(ad_ctx->sdap_id_ctx, ad_ctx->sdap_id_ctx,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina ret = setup_tls_config(ad_ctx->sdap_id_ctx->opts->basic);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina "setup_tls_config failed [%s]\n", strerror(ret));
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* setup SRV lookup plugin */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina hostname = dp_opt_get_string(ad_options->basic, AD_HOSTNAME);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina if (dp_opt_get_bool(ad_options->basic, AD_ENABLE_DNS_SITES)) {
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* use AD plugin */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina ad_domain = dp_opt_get_string(ad_options->basic, AD_DOMAIN);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina ad_site_override = dp_opt_get_string(ad_options->basic, AD_SITE);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina srv_ctx = ad_srv_plugin_ctx_init(bectx, bectx->be_res,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina DEBUG(SSSDBG_FATAL_FAILURE, "Out of memory?\n");
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina be_fo_set_srv_lookup_plugin(bectx, ad_srv_plugin_send,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* fall back to standard plugin */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina ret = be_fo_set_dns_srv_lookup_plugin(bectx, hostname);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to set SRV lookup plugin "
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* setup periodical refresh of expired records */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina ret = sdap_refresh_init(bectx->refresh_ctx, ad_ctx->sdap_id_ctx);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh "
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina "will not work [%d]: %s\n", ret, strerror(ret));
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina ret = ad_machine_account_password_renewal_init(bectx, ad_options);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Cannot setup task for machine account "
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina "password renewal.\n");
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Already initialized */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina krb5_auth_ctx = talloc_zero(NULL, struct krb5_ctx);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina krb5_auth_ctx->service = ad_options->service->krb5_service;
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina ret = ad_get_auth_options(krb5_auth_ctx, ad_options, bectx,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina "Could not determine Kerberos options\n");
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina "Could not initialize krb5_child settings: [%s]\n",
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina ad_options->auth_ctx = talloc_steal(ad_options, krb5_auth_ctx);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Already initialized */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina ret = sssm_ad_auth_init(bectx, ops, pvt_data);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* GPO parsing of PAM service names to Windows Logon Rights*/
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinaerrno_t ad_gpo_parse_map_options(struct ad_access_ctx *access_ctx);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina access_ctx = talloc_zero(bectx, struct ad_access_ctx);
goto fail;
goto fail;
goto fail;
filter);
goto fail;
goto fail;
goto fail;
goto fail;
return EOK;
fail:
return ret;
void **pvt_data)
int ret;
const char *ad_domain;
return ret;
return EINVAL;
return ret;
return EOK;
void **pvt_data)
#ifdef BUILD_SUDO
int ret;
return ret;
return EOK;
void **pvt_data)
#ifdef BUILD_AUTOFS
int ret;
return ret;
return EOK;