diff options
author | Simo Sorce <simo@redhat.com> | 2012-07-19 19:35:43 -0400 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-08-01 22:24:44 +0200 |
commit | 87ed72b47859e673b636c85f35b85f1546c7ed3d (patch) | |
tree | 7feadb7a4316ad4148924b5424132e793c1c7c5c | |
parent | 204cfc89a076fd32bf34f2abb3f809304aaa88ab (diff) | |
download | sssd-87ed72b47859e673b636c85f35b85f1546c7ed3d.tar.gz sssd-87ed72b47859e673b636c85f35b85f1546c7ed3d.tar.xz sssd-87ed72b47859e673b636c85f35b85f1546c7ed3d.zip |
Expose an initializer function from subdomain
Instead of exporting internal structures, expose an initilizer function
like the autofs code and initialize everything inside the
ipa_subdomains.c file.
-rw-r--r-- | src/providers/ipa/ipa_init.c | 28 | ||||
-rw-r--r-- | src/providers/ipa/ipa_subdomains.c | 35 | ||||
-rw-r--r-- | src/providers/ipa/ipa_subdomains.h | 15 |
3 files changed, 46 insertions, 32 deletions
diff --git a/src/providers/ipa/ipa_init.c b/src/providers/ipa/ipa_init.c index d3d865e04..a6c32be2a 100644 --- a/src/providers/ipa/ipa_init.c +++ b/src/providers/ipa/ipa_init.c @@ -76,11 +76,6 @@ struct bet_ops ipa_hostid_ops = { }; #endif -struct bet_ops ipa_subdomains_ops = { - .handler = ipa_subdomains_handler, - .finalize = NULL -}; - int common_ipa_init(struct be_ctx *bectx) { const char *ipa_servers; @@ -486,30 +481,19 @@ int sssm_ipa_subdomains_init(struct be_ctx *bectx, void **pvt_data) { int ret; - struct ipa_subdomains_ctx *subdomains_ctx; struct ipa_id_ctx *id_ctx; - subdomains_ctx = talloc_zero(bectx, struct ipa_subdomains_ctx); - if (subdomains_ctx == NULL) { - DEBUG(SSSDBG_CRIT_FAILURE, ("talloc_zero failed.\n")); - return ENOMEM; - } - ret = sssm_ipa_id_init(bectx, ops, (void **) &id_ctx); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("sssm_ipa_id_init failed.\n")); - goto done; + return ret; } - subdomains_ctx->sdap_id_ctx = id_ctx->sdap_id_ctx; - subdomains_ctx->search_bases = id_ctx->ipa_options->subdomains_search_bases; - subdomains_ctx->master_search_bases = id_ctx->ipa_options->master_domain_search_bases; - subdomains_ctx->ranges_search_bases = id_ctx->ipa_options->ranges_search_bases; - *ops = &ipa_subdomains_ops; - *pvt_data = subdomains_ctx; -done: + ret = ipa_subdom_init(bectx, id_ctx, ops, pvt_data); if (ret != EOK) { - talloc_free(subdomains_ctx); + DEBUG(SSSDBG_CRIT_FAILURE, ("ipa_subdom_init failed.\n")); + return ret; } - return ret; + + return EOK; } diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c index 8a49c6343..a8c05c2a7 100644 --- a/src/providers/ipa/ipa_subdomains.c +++ b/src/providers/ipa/ipa_subdomains.c @@ -56,6 +56,13 @@ struct ipa_subdomains_req_params { const char *attrs[8]; }; +struct ipa_subdomains_ctx { + struct sdap_id_ctx *sdap_id_ctx; + struct sdap_search_base **search_bases; + struct sdap_search_base **master_search_bases; + struct sdap_search_base **ranges_search_bases; +}; + static void ipa_subdomains_reply(struct be_req *be_req, int dp_err, int result) { be_req->fn(be_req, dp_err, result, NULL); @@ -651,3 +658,31 @@ done: } ipa_subdomains_reply(be_req, dp_error, ret); } + +struct bet_ops ipa_subdomains_ops = { + .handler = ipa_subdomains_handler, + .finalize = NULL +}; + +int ipa_subdom_init(struct be_ctx *be_ctx, + struct ipa_id_ctx *id_ctx, + struct bet_ops **ops, + void **pvt_data) +{ + struct ipa_subdomains_ctx *ctx; + + ctx = talloc_zero(id_ctx, struct ipa_subdomains_ctx); + if (ctx == NULL) { + DEBUG(SSSDBG_CRIT_FAILURE, ("talloc_zero failed.\n")); + return ENOMEM; + } + + ctx->sdap_id_ctx = id_ctx->sdap_id_ctx; + ctx->search_bases = id_ctx->ipa_options->subdomains_search_bases; + ctx->master_search_bases = id_ctx->ipa_options->master_domain_search_bases; + ctx->ranges_search_bases = id_ctx->ipa_options->ranges_search_bases; + *ops = &ipa_subdomains_ops; + *pvt_data = ctx; + + return EOK; +} diff --git a/src/providers/ipa/ipa_subdomains.h b/src/providers/ipa/ipa_subdomains.h index 895ba29f5..9d24bccf2 100644 --- a/src/providers/ipa/ipa_subdomains.h +++ b/src/providers/ipa/ipa_subdomains.h @@ -26,16 +26,11 @@ #define _IPA_SUBDOMAINS_H_ #include "providers/dp_backend.h" -#include "providers/ldap/ldap_common.h" +#include "providers/ipa/ipa_common.h" -struct ipa_subdomains_ctx { - struct sdap_id_ctx *sdap_id_ctx; - struct sdap_search_base **search_bases; - struct sdap_search_base **master_search_bases; - struct sdap_search_base **ranges_search_bases; -}; - - -void ipa_subdomains_handler(struct be_req *be_req); +int ipa_subdom_init(struct be_ctx *be_ctx, + struct ipa_id_ctx *id_ctx, + struct bet_ops **ops, + void **pvt_data); #endif /* _IPA_SUBDOMAINS_H_ */ |