summaryrefslogtreecommitdiff
path: root/src/providers/ldap
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-01-11 17:26:19 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-01-21 22:17:34 +0100
commit03abdaa21ecf562b714f204ca42379ff08626f75 (patch)
tree0b6a9d40fc90292d4cadd4c738b8cda8a5dacd06 /src/providers/ldap
parent99151f2217ddaa179543b89b49f836f29f7dcd2a (diff)
downloadsssd-03abdaa21ecf562b714f204ca42379ff08626f75.tar.gz
sssd-03abdaa21ecf562b714f204ca42379ff08626f75.tar.bz2
sssd-03abdaa21ecf562b714f204ca42379ff08626f75.zip
Add be_req_get_be_ctx() helper.
In preparation for making be_req opaque
Diffstat (limited to 'src/providers/ldap')
-rw-r--r--src/providers/ldap/ldap_access.c11
-rw-r--r--src/providers/ldap/ldap_auth.c37
-rw-r--r--src/providers/ldap/ldap_id.c26
-rw-r--r--src/providers/ldap/sdap_autofs.c5
-rw-r--r--src/providers/ldap/sdap_sudo.c3
5 files changed, 43 insertions, 39 deletions
diff --git a/src/providers/ldap/ldap_access.c b/src/providers/ldap/ldap_access.c
index cc1127c2..5ab17abd 100644
--- a/src/providers/ldap/ldap_access.c
+++ b/src/providers/ldap/ldap_access.c
@@ -44,6 +44,7 @@ static void sdap_access_reply(struct be_req *be_req, int pam_status)
static void sdap_access_done(struct tevent_req *req);
void sdap_pam_access_handler(struct be_req *breq)
{
+ struct be_ctx *be_ctx = be_req_get_be_ctx(breq);
struct pam_data *pd;
struct tevent_req *req;
struct sdap_access_ctx *access_ctx;
@@ -51,15 +52,11 @@ void sdap_pam_access_handler(struct be_req *breq)
pd = talloc_get_type(breq->req_data, struct pam_data);
access_ctx =
- talloc_get_type(breq->be_ctx->bet_info[BET_ACCESS].pvt_bet_data,
+ talloc_get_type(be_ctx->bet_info[BET_ACCESS].pvt_bet_data,
struct sdap_access_ctx);
- req = sdap_access_send(breq,
- breq->be_ctx->ev,
- breq->be_ctx,
- breq->be_ctx->domain,
- access_ctx,
- pd);
+ req = sdap_access_send(breq, be_ctx->ev, be_ctx,
+ be_ctx->domain, access_ctx, pd);
if (req == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, ("Unable to start sdap_access request\n"));
sdap_access_reply(breq, PAM_SYSTEM_ERR);
diff --git a/src/providers/ldap/ldap_auth.c b/src/providers/ldap/ldap_auth.c
index b24f7f39..76c23e15 100644
--- a/src/providers/ldap/ldap_auth.c
+++ b/src/providers/ldap/ldap_auth.c
@@ -732,13 +732,14 @@ static void sdap_pam_chpass_done(struct tevent_req *req);
void sdap_pam_chpass_handler(struct be_req *breq)
{
+ struct be_ctx *be_ctx = be_req_get_be_ctx(breq);
struct sdap_pam_chpass_state *state;
struct sdap_auth_ctx *ctx;
struct tevent_req *subreq;
struct pam_data *pd;
int dp_err = DP_ERR_FATAL;
- ctx = talloc_get_type(breq->be_ctx->bet_info[BET_CHPASS].pvt_bet_data,
+ ctx = talloc_get_type(be_ctx->bet_info[BET_CHPASS].pvt_bet_data,
struct sdap_auth_ctx);
pd = talloc_get_type(breq->req_data, struct pam_data);
@@ -774,7 +775,7 @@ void sdap_pam_chpass_handler(struct be_req *breq)
state->username = pd->user;
state->ctx = ctx;
- subreq = auth_send(breq, breq->be_ctx->ev, ctx,
+ subreq = auth_send(breq, be_ctx->ev, ctx,
state->username, &pd->authtok, true);
if (!subreq) goto done;
@@ -790,6 +791,7 @@ static void sdap_auth4chpass_done(struct tevent_req *req)
{
struct sdap_pam_chpass_state *state =
tevent_req_callback_data(req, struct sdap_pam_chpass_state);
+ struct be_ctx *be_ctx = be_req_get_be_ctx(state->breq);
struct tevent_req *subreq;
enum sdap_result result;
enum pwexpire pw_expire_type;
@@ -828,7 +830,7 @@ static void sdap_auth4chpass_done(struct tevent_req *req)
break;
case PWEXPIRE_KERBEROS:
ret = check_pwexpire_kerberos(pw_expire_data, time(NULL), NULL, &result,
- state->breq->be_ctx->domain->pwd_expiration_warning);
+ be_ctx->domain->pwd_expiration_warning);
if (ret != EOK) {
DEBUG(1, ("check_pwexpire_kerberos failed.\n"));
state->pd->pam_status = PAM_SYSTEM_ERR;
@@ -878,8 +880,7 @@ static void sdap_auth4chpass_done(struct tevent_req *req)
goto done;
}
- subreq = sdap_exop_modify_passwd_send(state,
- state->breq->be_ctx->ev,
+ subreq = sdap_exop_modify_passwd_send(state, be_ctx->ev,
state->sh, state->dn,
password, new_password);
if (!subreq) {
@@ -895,7 +896,7 @@ static void sdap_auth4chpass_done(struct tevent_req *req)
break;
case SDAP_UNAVAIL:
state->pd->pam_status = PAM_AUTHINFO_UNAVAIL;
- be_mark_offline(state->breq->be_ctx);
+ be_mark_offline(be_ctx);
dp_err = DP_ERR_OFFLINE;
break;
default:
@@ -910,6 +911,7 @@ static void sdap_pam_chpass_done(struct tevent_req *req)
{
struct sdap_pam_chpass_state *state =
tevent_req_callback_data(req, struct sdap_pam_chpass_state);
+ struct be_ctx *be_ctx = be_req_get_be_ctx(state->breq);
enum sdap_result result;
int dp_err = DP_ERR_FATAL;
int ret;
@@ -957,11 +959,9 @@ static void sdap_pam_chpass_done(struct tevent_req *req)
SDAP_CHPASS_UPDATE_LAST_CHANGE)) {
lastchanged_name = state->ctx->opts->user_map[SDAP_AT_SP_LSTCHG].name;
- subreq = sdap_modify_shadow_lastchange_send(state,
- state->breq->be_ctx->ev,
- state->sh,
- state->dn,
- lastchanged_name);
+ subreq = sdap_modify_shadow_lastchange_send(state, be_ctx->ev,
+ state->sh, state->dn,
+ lastchanged_name);
if (subreq == NULL) {
state->pd->pam_status = PAM_SYSTEM_ERR;
goto done;
@@ -1006,13 +1006,14 @@ static void sdap_pam_auth_done(struct tevent_req *req);
void sdap_pam_auth_handler(struct be_req *breq)
{
+ struct be_ctx *be_ctx = be_req_get_be_ctx(breq);
struct sdap_pam_auth_state *state;
struct sdap_auth_ctx *ctx;
struct tevent_req *subreq;
struct pam_data *pd;
int dp_err = DP_ERR_FATAL;
- ctx = talloc_get_type(breq->be_ctx->bet_info[BET_AUTH].pvt_bet_data,
+ ctx = talloc_get_type(be_ctx->bet_info[BET_AUTH].pvt_bet_data,
struct sdap_auth_ctx);
pd = talloc_get_type(breq->req_data, struct pam_data);
@@ -1035,7 +1036,7 @@ void sdap_pam_auth_handler(struct be_req *breq)
state->breq = breq;
state->pd = pd;
- subreq = auth_send(breq, breq->be_ctx->ev, ctx,
+ subreq = auth_send(breq, be_ctx->ev, ctx,
pd->user, &pd->authtok,
pd->cmd == SSS_PAM_CHAUTHTOK_PRELIM ? true : false);
if (!subreq) goto done;
@@ -1066,9 +1067,9 @@ static void sdap_pam_auth_done(struct tevent_req *req)
{
struct sdap_pam_auth_state *state =
tevent_req_callback_data(req, struct sdap_pam_auth_state);
+ struct be_ctx *be_ctx = be_req_get_be_ctx(state->breq);
enum sdap_result result;
enum pwexpire pw_expire_type;
- struct be_ctx *be_ctx = state->breq->be_ctx;
void *pw_expire_data;
const char *password;
int dp_err = DP_ERR_OK;
@@ -1145,18 +1146,16 @@ static void sdap_pam_auth_done(struct tevent_req *req)
}
if (result == SDAP_UNAVAIL) {
- be_mark_offline(state->breq->be_ctx);
+ be_mark_offline(be_ctx);
dp_err = DP_ERR_OFFLINE;
goto done;
}
- if (result == SDAP_AUTH_SUCCESS &&
- state->breq->be_ctx->domain->cache_credentials) {
+ if (result == SDAP_AUTH_SUCCESS && be_ctx->domain->cache_credentials) {
ret = sss_authtok_get_password(&state->pd->authtok, &password, NULL);
if (ret == EOK) {
- ret = sysdb_cache_password(state->breq->be_ctx->domain->sysdb,
- state->breq->be_ctx->domain,
+ ret = sysdb_cache_password(be_ctx->domain->sysdb, be_ctx->domain,
state->pd->user, password);
}
diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c
index 5b5edec4..efa1769b 100644
--- a/src/providers/ldap/ldap_id.c
+++ b/src/providers/ldap/ldap_id.c
@@ -764,9 +764,10 @@ int groups_by_user_recv(struct tevent_req *req, int *dp_error_out)
static void sdap_check_online_done(struct tevent_req *req);
void sdap_check_online(struct be_req *be_req)
{
+ struct be_ctx *be_ctx = be_req_get_be_ctx(be_req);
struct sdap_id_ctx *ctx;
- ctx = talloc_get_type(be_req->be_ctx->bet_info[BET_ID].pvt_bet_data,
+ ctx = talloc_get_type(be_ctx->bet_info[BET_ID].pvt_bet_data,
struct sdap_id_ctx);
return sdap_do_online_check(be_req, ctx);
@@ -779,6 +780,7 @@ struct sdap_online_check_ctx {
void sdap_do_online_check(struct be_req *be_req, struct sdap_id_ctx *ctx)
{
+ struct be_ctx *be_ctx = be_req_get_be_ctx(be_req);
struct tevent_req *req;
struct sdap_online_check_ctx *check_ctx;
errno_t ret;
@@ -792,8 +794,8 @@ void sdap_do_online_check(struct be_req *be_req, struct sdap_id_ctx *ctx)
check_ctx->id_ctx = ctx;
check_ctx->be_req = be_req;
- req = sdap_cli_connect_send(be_req, be_req->be_ctx->ev, ctx->opts,
- be_req->be_ctx, ctx->service, false,
+ req = sdap_cli_connect_send(be_req, be_ctx->ev, ctx->opts,
+ be_ctx, ctx->service, false,
CON_TLS_DFL, false);
if (req == NULL) {
DEBUG(1, ("sdap_cli_connect_send failed.\n"));
@@ -821,6 +823,7 @@ static void sdap_check_online_done(struct tevent_req *req)
struct sdap_id_ctx *id_ctx;
struct tevent_req *reinit_req = NULL;
bool reinit = false;
+ struct be_ctx *be_ctx;
ret = sdap_cli_connect_recv(req, NULL, &can_retry, NULL, &srv_opts);
talloc_zfree(req);
@@ -853,13 +856,14 @@ static void sdap_check_online_done(struct tevent_req *req)
}
be_req = check_ctx->be_req;
+ be_ctx = be_req_get_be_ctx(be_req);
id_ctx = check_ctx->id_ctx;
talloc_free(check_ctx);
if (reinit) {
DEBUG(SSSDBG_TRACE_FUNC, ("Server reinitialization detected. "
"Cleaning cache.\n"));
- reinit_req = sdap_reinit_cleanup_send(be_req, be_req->be_ctx, id_ctx);
+ reinit_req = sdap_reinit_cleanup_send(be_req, be_ctx, id_ctx);
if (reinit_req == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, ("Unable to perform reinitialization "
"clean up.\n"));
@@ -909,9 +913,10 @@ void sdap_handle_account_info(struct be_req *breq, struct sdap_id_ctx *ctx);
void sdap_account_info_handler(struct be_req *breq)
{
+ struct be_ctx *be_ctx = be_req_get_be_ctx(breq);
struct sdap_id_ctx *ctx;
- ctx = talloc_get_type(breq->be_ctx->bet_info[BET_ID].pvt_bet_data, struct sdap_id_ctx);
+ ctx = talloc_get_type(be_ctx->bet_info[BET_ID].pvt_bet_data, struct sdap_id_ctx);
if (!ctx) {
DEBUG(SSSDBG_CRIT_FAILURE, ("Could not get sdap ctx\n"));
return sdap_handler_done(breq, DP_ERR_FATAL,
@@ -922,6 +927,7 @@ void sdap_account_info_handler(struct be_req *breq)
void sdap_handle_account_info(struct be_req *breq, struct sdap_id_ctx *ctx)
{
+ struct be_ctx *be_ctx = be_req_get_be_ctx(breq);
struct be_acct_req *ar;
struct tevent_req *req;
const char *err = "Unknown Error";
@@ -941,7 +947,7 @@ void sdap_handle_account_info(struct be_req *breq, struct sdap_id_ctx *ctx)
return sdap_handler_done(breq, DP_ERR_OK, EOK, "Success");
}
- req = users_get_send(breq, breq->be_ctx->ev, ctx,
+ req = users_get_send(breq, be_ctx->ev, ctx,
ar->filter_value,
ar->filter_type,
ar->attr_type);
@@ -960,7 +966,7 @@ void sdap_handle_account_info(struct be_req *breq, struct sdap_id_ctx *ctx)
return sdap_handler_done(breq, DP_ERR_OK, EOK, "Success");
}
- req = groups_get_send(breq, breq->be_ctx->ev, ctx,
+ req = groups_get_send(breq, be_ctx->ev, ctx,
ar->filter_value,
ar->filter_type,
ar->attr_type);
@@ -983,7 +989,7 @@ void sdap_handle_account_info(struct be_req *breq, struct sdap_id_ctx *ctx)
err = "Invalid attr type";
break;
}
- req = groups_by_user_send(breq, breq->be_ctx->ev, ctx,
+ req = groups_by_user_send(breq, be_ctx->ev, ctx,
ar->filter_value);
if (!req) ret = ENOMEM;
/* tevent_req_set_callback(req, groups_by_user_done, breq); */
@@ -999,7 +1005,7 @@ void sdap_handle_account_info(struct be_req *breq, struct sdap_id_ctx *ctx)
break;
}
- req = ldap_netgroup_get_send(breq, breq->be_ctx->ev, ctx, ar->filter_value);
+ req = ldap_netgroup_get_send(breq, be_ctx->ev, ctx, ar->filter_value);
if (!req) {
return sdap_handler_done(breq, DP_ERR_FATAL, ENOMEM, "Out of memory");
}
@@ -1013,7 +1019,7 @@ void sdap_handle_account_info(struct be_req *breq, struct sdap_id_ctx *ctx)
return sdap_handler_done(breq, DP_ERR_OK, EOK, "Success");
}
- req = services_get_send(breq, breq->be_ctx->ev, ctx,
+ req = services_get_send(breq, be_ctx->ev, ctx,
ar->filter_value,
ar->extra_value,
ar->filter_type);
diff --git a/src/providers/ldap/sdap_autofs.c b/src/providers/ldap/sdap_autofs.c
index 6fb64099..2c8a238a 100644
--- a/src/providers/ldap/sdap_autofs.c
+++ b/src/providers/ldap/sdap_autofs.c
@@ -78,6 +78,7 @@ static void sdap_autofs_handler_done(struct tevent_req *req);
void sdap_autofs_handler(struct be_req *be_req)
{
+ struct be_ctx *be_ctx = be_req_get_be_ctx(be_req);
struct sdap_id_ctx *id_ctx;
struct be_autofs_req *autofs_req;
struct tevent_req *req;
@@ -85,7 +86,7 @@ void sdap_autofs_handler(struct be_req *be_req)
DEBUG(SSSDBG_TRACE_INTERNAL, ("sdap autofs handler called\n"));
- id_ctx = talloc_get_type(be_req->be_ctx->bet_info[BET_AUTOFS].pvt_bet_data,
+ id_ctx = talloc_get_type(be_ctx->bet_info[BET_AUTOFS].pvt_bet_data,
struct sdap_id_ctx);
if (be_is_offline(id_ctx->be)) {
@@ -106,7 +107,7 @@ void sdap_autofs_handler(struct be_req *be_req)
}
}
- req = sdap_autofs_get_map_send(be_req, be_req->be_ctx->ev,
+ req = sdap_autofs_get_map_send(be_req, be_ctx->ev,
id_ctx, autofs_req->mapname);
if (!req) {
ret = ENOMEM;
diff --git a/src/providers/ldap/sdap_sudo.c b/src/providers/ldap/sdap_sudo.c
index 9c818366..e42560a2 100644
--- a/src/providers/ldap/sdap_sudo.c
+++ b/src/providers/ldap/sdap_sudo.c
@@ -487,13 +487,14 @@ static void sdap_sudo_reply(struct tevent_req *req)
void sdap_sudo_handler(struct be_req *be_req)
{
+ struct be_ctx *be_ctx = be_req_get_be_ctx(be_req);
struct tevent_req *req = NULL;
struct be_sudo_req *sudo_req = NULL;
struct sdap_sudo_ctx *sudo_ctx = NULL;
struct sdap_id_ctx *id_ctx = NULL;
int ret = EOK;
- sudo_ctx = talloc_get_type(be_req->be_ctx->bet_info[BET_SUDO].pvt_bet_data,
+ sudo_ctx = talloc_get_type(be_ctx->bet_info[BET_SUDO].pvt_bet_data,
struct sdap_sudo_ctx);
id_ctx = sudo_ctx->id_ctx;