ldap_init.c revision 1abdf56dcda5f6bed7b144e544c00dbdd501b3fc
842ae4bd224140319ae7feec1872b93dfd491143fielding LDAP Provider Initialization functions
2d2eda71267231c2526be701fe655db125852c1ffielding Simo Sorce <ssorce@redhat.com>
2d2eda71267231c2526be701fe655db125852c1ffielding Copyright (C) 2009 Red Hat
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd This program is free software; you can redistribute it and/or modify
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd it under the terms of the GNU General Public License as published by
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd the Free Software Foundation; either version 3 of the License, or
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd (at your option) any later version.
2d2eda71267231c2526be701fe655db125852c1ffielding This program is distributed in the hope that it will be useful,
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben but WITHOUT ANY WARRANTY; without even the implied warranty of
0432a26b69eedfb9ca5f34fba590236378a24851ben MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0432a26b69eedfb9ca5f34fba590236378a24851ben GNU General Public License for more details.
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh You should have received a copy of the GNU General Public License
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh along with this program. If not, see <http://www.gnu.org/licenses/>.
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh/* Id Handler */
30c289e6bc6d28d210b21edd800ab2cfc78a8381wrowe/* Auth Handler */
b627048681b27fe30f979ba471b523be3a6a22adrbb/* Chpass Handler */
d9039a9aaeaa1359c1147af66c09aeac56ae3ee0pquerna/* Access Handler */
7c7372abe2484e7fcf81937b93496d1246e5b816gstein/* Please use this only for short lists */
2d2eda71267231c2526be701fe655db125852c1ffielding if (cmp == 0) {
2d2eda71267231c2526be701fe655db125852c1ffielding DEBUG(1, ("Duplicate string [%s] found.\n", list[c]));
2d2eda71267231c2526be701fe655db125852c1ffielding const char *urls;
b0f20a4a26bcfa85724b1c2e5ec6a077f12ef44crbb const char *sasl_mech;
72a4ef8eac1adef882246c5bfb9b8bbd82d613c4coar /* If we're already set up, just return that */
b0f20a4a26bcfa85724b1c2e5ec6a077f12ef44crbb strcmp("ldap", bectx->bet_info[BET_ID].mod_name) == 0) {
2d2eda71267231c2526be701fe655db125852c1ffielding DEBUG(7, ("Service name for discovery set to %s\n", dns_service_name));
2d2eda71267231c2526be701fe655db125852c1ffielding urls = dp_opt_get_string(ctx->opts->basic, SDAP_URI);
2d2eda71267231c2526be701fe655db125852c1ffielding backup_urls = dp_opt_get_string(ctx->opts->basic, SDAP_BACKUP_URI);
2d2eda71267231c2526be701fe655db125852c1ffielding DEBUG(1, ("Failed to initialize failover service!\n"));
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh sasl_mech = dp_opt_get_string(ctx->opts->basic, SDAP_SASL_MECH);
2d2eda71267231c2526be701fe655db125852c1ffielding if (sasl_mech && strcasecmp(sasl_mech, "GSSAPI") == 0) {
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh if (dp_opt_get_bool(ctx->opts->basic, SDAP_KRB5_KINIT)) {
2d2eda71267231c2526be701fe655db125852c1ffielding ret = sdap_id_conn_cache_create(ctx, ctx, &ctx->conn_cache);
2d2eda71267231c2526be701fe655db125852c1ffielding if (dp_opt_get_bool(ctx->opts->basic, SDAP_ID_MAPPING)) {
e44e11f9fece12c783f18d033923bfc0d6b4289aake /* Set up the ID mapping object */
2d2eda71267231c2526be701fe655db125852c1ffielding ret = sdap_idmap_init(ctx, ctx, &ctx->opts->idmap_ctx);
2d2eda71267231c2526be701fe655db125852c1ffielding /* setup SRV lookup plugin */
2d2eda71267231c2526be701fe655db125852c1ffielding ret = be_fo_set_dns_srv_lookup_plugin(bectx, NULL);
2d2eda71267231c2526be701fe655db125852c1ffielding DEBUG(SSSDBG_CRIT_FAILURE, ("Unable to set SRV lookup plugin "
b0f20a4a26bcfa85724b1c2e5ec6a077f12ef44crbb const char *urls;
3d0bdf16bc410722e6c42aa2ceb0677b0ae29b90ianh const char *backup_urls;
b0f20a4a26bcfa85724b1c2e5ec6a077f12ef44crbb DEBUG(7, ("Service name for chpass discovery set to %s\n",
99d6d3207e24ba1f8eba77ef903948d738886cf5nd urls = dp_opt_get_string(ctx->opts->basic, SDAP_CHPASS_URI);
99d6d3207e24ba1f8eba77ef903948d738886cf5nd backup_urls = dp_opt_get_string(ctx->opts->basic, SDAP_CHPASS_BACKUP_URI);
99d6d3207e24ba1f8eba77ef903948d738886cf5nd DEBUG(9, ("ldap_chpass_uri and ldap_chpass_dns_service_name not set, "
99d6d3207e24ba1f8eba77ef903948d738886cf5nd "using ldap_uri.\n"));
99d6d3207e24ba1f8eba77ef903948d738886cf5nd ret = sdap_service_init(ctx, ctx->be, "LDAP_CHPASS", dns_service_name,
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben const char *filter;
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben const char *order;
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben const char *dummy;
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben access_ctx = talloc_zero(bectx, struct sdap_access_ctx);
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh ret = sssm_ldap_id_init(bectx, ops, (void **)&access_ctx->id_ctx);
b0f20a4a26bcfa85724b1c2e5ec6a077f12ef44crbb order = dp_opt_get_cstring(access_ctx->id_ctx->opts->basic,
bbe046d7cbb950ab3e372e4119ae001a5fe52ed4striker DEBUG(1, ("ldap_access_order not given, using 'filter'.\n"));
c8aa00ee0cfc17b5fa08fb8a2b08d30dc9e4f1b1wrowe ret = split_on_separator(access_ctx, order, ',', true, true,
b0f20a4a26bcfa85724b1c2e5ec6a077f12ef44crbb ret = check_order_list_for_duplicates(order_list, false);
b0f20a4a26bcfa85724b1c2e5ec6a077f12ef44crbb DEBUG(1, ("check_order_list_for_duplicates failed.\n"));
3d0bdf16bc410722e6c42aa2ceb0677b0ae29b90ianh DEBUG(1, ("Currently only [%d] different access rules are supported.\n"));
6d74c65f131583f6832b04424c1a9e1e7cc72c8egregames if (strcasecmp(order_list[c], LDAP_ACCESS_FILTER_NAME) == 0) {
3d0bdf16bc410722e6c42aa2ceb0677b0ae29b90ianh filter = dp_opt_get_cstring(access_ctx->id_ctx->opts->basic,
3d0bdf16bc410722e6c42aa2ceb0677b0ae29b90ianh /* It's okay if this is NULL. In that case we will simply act
b0f20a4a26bcfa85724b1c2e5ec6a077f12ef44crbb * like the 'deny' provider.
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben "but no ldap_access_filter configured. "
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben "All domain users will be denied access.\n"));
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben /* This filter is wrapped in parentheses.
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben * Pass it as-is to the openldap libraries.
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben /* Add parentheses around the filter */
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben access_ctx->filter = talloc_asprintf(access_ctx, "(%s)", filter);
64b9fa4bc3e79b0eefb2d93fb56eae40d88e0f06wrowe } else if (strcasecmp(order_list[c], LDAP_ACCESS_EXPIRE_NAME) == 0) {
64b9fa4bc3e79b0eefb2d93fb56eae40d88e0f06wrowe dummy = dp_opt_get_cstring(access_ctx->id_ctx->opts->basic,
64b9fa4bc3e79b0eefb2d93fb56eae40d88e0f06wrowe DEBUG(0, ("Warning: LDAP access rule 'expire' is set, "
64b9fa4bc3e79b0eefb2d93fb56eae40d88e0f06wrowe "but no ldap_account_expire_policy configured. "
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben "All domain users will be denied access.\n"));
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben if (strcasecmp(dummy, LDAP_ACCOUNT_EXPIRE_SHADOW) != 0 &&
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben DEBUG(1, ("Unsupported LDAP account expire policy [%s].\n",
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh } else if (strcasecmp(order_list[c], LDAP_ACCESS_SERVICE_NAME) == 0) {
3d0bdf16bc410722e6c42aa2ceb0677b0ae29b90ianh } else if (strcasecmp(order_list[c], LDAP_ACCESS_HOST_NAME) == 0) {
759f4a24d09e28c4eaca9f97311b497fc15cb5c7ben DEBUG(1, ("Unexpected access rule name [%s].\n", order_list[c]));
d11bf78168abbb07d8ed9f54d7ea0953d46aad83nd if (c == 0) {
d11bf78168abbb07d8ed9f54d7ea0953d46aad83nd "but ldap_access_order is empty. "
d11bf78168abbb07d8ed9f54d7ea0953d46aad83nd "All domain users will be denied access.\n"));
1ce78cf71b5baaf2c1ab48e818cb1f2397df5010trawick DEBUG(SSSDBG_CRIT_FAILURE, ("Cannot init LDAP ID provider [%d]: %s\n",
a520b923984f45daeaf0741d5c7e3de1f2d24509rbb DEBUG(SSSDBG_MINOR_FAILURE, ("Sudo init handler called but SSSD is "
3d96ee83babeec32482c9082c9426340cee8c44dwrowe "built without sudo support, ignoring\n"));
ceb14f8ba57a8086c9a68ad264efbe2433134382covener DEBUG(SSSDBG_CRIT_FAILURE, ("Cannot init LDAP ID provider [%d]: %s\n",
3d0bdf16bc410722e6c42aa2ceb0677b0ae29b90ianh return sdap_autofs_init(be_ctx, id_ctx, ops, pvt_data);
2d2eda71267231c2526be701fe655db125852c1ffielding DEBUG(SSSDBG_MINOR_FAILURE, ("Autofs init handler called but SSSD is "
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm "built without autofs support, ignoring\n"));
2d2eda71267231c2526be701fe655db125852c1ffielding /* TODO: Clean up any internal data */