ad_init.c revision 008e1ee835602023891ac45408483d87f41e4d5c
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian Maeder Stephen Gallagher <sgallagh@redhat.com>
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian Maeder Copyright (C) 2012 Red Hat
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian Maeder This program is free software; you can redistribute it and/or modify
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian Maeder it under the terms of the GNU General Public License as published by
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian Maeder the Free Software Foundation; either version 3 of the License, or
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian Maeder (at your option) any later version.
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian Maeder This program is distributed in the hope that it will be useful,
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder but WITHOUT ANY WARRANTY; without even the implied warranty of
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder GNU General Public License for more details.
23f8d286586ff38a9e73052b2c7c04c62c5c638fChristian Maeder You should have received a copy of the GNU General Public License
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder along with this program. If not, see <http://www.gnu.org/licenses/>.
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder#include "providers/krb5/krb5_init_shared.h"
18b709ce961d68328da768318dcc70067f066d86Christian Maederstatic int ad_sasl_getopt(void *context, const char *plugin_name,
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian Maedertypedef int (*sss_sasl_gen_cb_fn)(void);
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maederstatic const sasl_callback_t ad_sasl_callbacks[] = {
797f811e57952d59e73b8cd03b667eef276db972Christian Maeder { SASL_CB_GETOPT, (sss_sasl_gen_cb_fn)ad_sasl_getopt, NULL },
18b709ce961d68328da768318dcc70067f066d86Christian Maeder/* This is quite a hack, we *try* to fool openldap libraries by initializing
797f811e57952d59e73b8cd03b667eef276db972Christian Maeder * sasl first so we can pass in the SASL_CB_GETOPT callback we need to set some
369454f9b2dbea113cbb40544a9b0f31425b2c69Christian Maeder * options. Should be removed as soon as openldap exposes a way to do that */
18b709ce961d68328da768318dcc70067f066d86Christian Maeder /* NOTE: this may fail if soe other library in the system happens to
369454f9b2dbea113cbb40544a9b0f31425b2c69Christian Maeder * initialize and use openldap libraries or directly the cyrus-sasl
369454f9b2dbea113cbb40544a9b0f31425b2c69Christian Maeder * library as this initialization function can be called only once per
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder /* Get AD-specific options */
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder ret = ad_get_common_options(bectx, bectx->cdb,
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder ("Could not parse common options: [%s]\n",
9c5b1136299d9052e4e995614a3a36a051a2682fChristian Maeder ad_servers = dp_opt_get_string(ad_options->basic, AD_SERVER);
9c5b1136299d9052e4e995614a3a36a051a2682fChristian Maeder ad_backup_servers = dp_opt_get_string(ad_options->basic, AD_BACKUP_SERVER);
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder ad_realm = dp_opt_get_string(ad_options->basic, AD_KRB5_REALM);
369454f9b2dbea113cbb40544a9b0f31425b2c69Christian Maeder /* Set up the failover service */
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder ret = ad_failover_init(ad_options, bectx, ad_servers, ad_backup_servers, ad_realm,
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder dp_opt_get_string(ad_options->basic, AD_DOMAIN),
f8f78a2c8796a387a4348cc672ae08e8d9f69315Christian Maeder ("Failed to init AD failover service: [%s]\n",
f8a03685d9184046e88e1d76aabdab4f714db440Christian Maeder /* already initialized */
return ENOMEM;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
done:
return ret;
void **pvt_data)
if (!ad_options) {
return ret;
return EOK;
if (!krb5_auth_ctx) {
goto done;
goto done;
goto done;
done:
return ret;
void **pvt_data)
if (!ad_options) {
return ret;
return EOK;
return ret;
void **pvt_data)
const char *filter;
goto fail;
goto fail;
goto fail;
filter);
goto fail;
return EOK;
fail:
return ret;
void **pvt_data)
int ret;
const char *ad_domain;
return ret;
return EINVAL;
return ret;
return EOK;