diff options
author | Sumit Bose <sbose@redhat.com> | 2010-12-20 13:02:05 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-12-20 09:39:55 -0500 |
commit | cc1e7b31fdb64025aa9c29a1426651df0b332769 (patch) | |
tree | 1842b1d9bc6d0b516a26aad944a6fe827188801e | |
parent | 84bb9ec1bba8e60d1d87febd48749edd18e16787 (diff) | |
download | sssd-cc1e7b31fdb64025aa9c29a1426651df0b332769.tar.gz sssd-cc1e7b31fdb64025aa9c29a1426651df0b332769.tar.xz sssd-cc1e7b31fdb64025aa9c29a1426651df0b332769.zip |
Avoid multiple initializations in LDAP provider
Currently in a domain where LDAP was used for id and auth the LDAP UIR
was added multiple times to the failover code which may cause unwanted
delays.
-rw-r--r-- | src/providers/ldap/ldap_init.c | 69 |
1 files changed, 30 insertions, 39 deletions
diff --git a/src/providers/ldap/ldap_init.c b/src/providers/ldap/ldap_init.c index 9b96d87eb..a1d8f05d7 100644 --- a/src/providers/ldap/ldap_init.c +++ b/src/providers/ldap/ldap_init.c @@ -178,38 +178,48 @@ int sssm_ldap_auth_init(struct be_ctx *bectx, struct bet_ops **ops, void **pvt_data) { + void *data; + struct sdap_id_ctx *id_ctx; struct sdap_auth_ctx *ctx; - const char *urls; - const char *dns_service_name; int ret; - ctx = talloc(bectx, struct sdap_auth_ctx); - if (!ctx) return ENOMEM; + ret = sssm_ldap_id_init(bectx, ops, &data); + if (ret == EOK) { + id_ctx = talloc_get_type(data, struct sdap_id_ctx); - ctx->be = bectx; + ctx = talloc(bectx, struct sdap_auth_ctx); + if (!ctx) return ENOMEM; - ret = ldap_get_options(ctx, bectx->cdb, - bectx->conf_path, &ctx->opts); - if (ret != EOK) { - goto done; + ctx->be = bectx; + ctx->opts = id_ctx->opts; + ctx->service = id_ctx->service; + ctx->chpass_service = NULL; + + *ops = &sdap_auth_ops; + *pvt_data = ctx; } - dns_service_name = dp_opt_get_string(ctx->opts->basic, - SDAP_DNS_SERVICE_NAME); - DEBUG(7, ("Service name for discovery set to %s\n", dns_service_name)); + return ret; +} - urls = dp_opt_get_string(ctx->opts->basic, SDAP_URI); - if (!urls) { - DEBUG(1, ("Missing ldap_uri, will use service discovery\n")); - } +int sssm_ldap_chpass_init(struct be_ctx *bectx, + struct bet_ops **ops, + void **pvt_data) +{ + int ret; + void *data; + struct sdap_auth_ctx *ctx = NULL; + const char *urls; + const char *dns_service_name; - ret = sdap_service_init(ctx, ctx->be, "LDAP", dns_service_name, - urls, &ctx->service); + ret = sssm_ldap_auth_init(bectx, ops, &data); if (ret != EOK) { - DEBUG(1, ("Failed to initialize failover service!\n")); + DEBUG(1, ("sssm_ldap_auth_init failed.\n")); goto done; } + ctx = talloc_get_type(data, struct sdap_auth_ctx); + dns_service_name = dp_opt_get_string(ctx->opts->basic, SDAP_CHPASS_DNS_SERVICE_NAME); if (dns_service_name) { @@ -231,14 +241,8 @@ int sssm_ldap_auth_init(struct be_ctx *bectx, } } - ret = setup_tls_config(ctx->opts->basic); - if (ret != EOK) { - DEBUG(1, ("setup_tls_config failed [%d][%s].\n", - ret, strerror(ret))); - goto done; - } - *ops = &sdap_auth_ops; + *ops = &sdap_chpass_ops; *pvt_data = ctx; ret = EOK; @@ -249,19 +253,6 @@ done: return ret; } -int sssm_ldap_chpass_init(struct be_ctx *bectx, - struct bet_ops **ops, - void **pvt_data) -{ - int ret; - - ret = sssm_ldap_auth_init(bectx, ops, pvt_data); - - *ops = &sdap_chpass_ops; - - return ret; -} - int sssm_ldap_access_init(struct be_ctx *bectx, struct bet_ops **ops, void **pvt_data) |