summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2014-11-23 21:07:58 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-11-25 18:48:34 +0100
commitff7481ff6f75d92470cff56632ad06ff7f10e895 (patch)
treea809fd1c0c2312c6c537f4f96eeb15b8c24402d1
parentfb106682e0277955e203ad074a368ddeb121fed3 (diff)
downloadsssd-ff7481ff6f75d92470cff56632ad06ff7f10e895.zip
sssd-ff7481ff6f75d92470cff56632ad06ff7f10e895.tar.gz
sssd-ff7481ff6f75d92470cff56632ad06ff7f10e895.tar.xz
PAM: Move is_uid_trusted from pam_ctx to preq
Keeping a per-request flag in a global structure is really dangerous. Reviewed-by: Sumit Bose <sbose@redhat.com>
-rw-r--r--src/responder/pam/pamsrv.h2
-rw-r--r--src/responder/pam/pamsrv_cmd.c23
2 files changed, 13 insertions, 12 deletions
diff --git a/src/responder/pam/pamsrv.h b/src/responder/pam/pamsrv.h
index f92e7f7..066f35a 100644
--- a/src/responder/pam/pamsrv.h
+++ b/src/responder/pam/pamsrv.h
@@ -39,7 +39,6 @@ struct pam_ctx {
hash_table_t *id_table;
size_t trusted_uids_count;
uid_t *trusted_uids;
- bool is_uid_trusted;
/* List of domains that are accessible even for untrusted users. */
char **public_domains;
@@ -58,6 +57,7 @@ struct pam_auth_req {
pam_dp_callback_t *callback;
+ bool is_uid_trusted;
bool check_provider;
void *data;
diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c
index ea084d5..a924c4d 100644
--- a/src/responder/pam/pamsrv_cmd.c
+++ b/src/responder/pam/pamsrv_cmd.c
@@ -849,15 +849,6 @@ static int pam_forwarder(struct cli_ctx *cctx, int pam_cmd)
talloc_get_type(cctx->rctx->pvt_ctx, struct pam_ctx);
struct tevent_req *req;
- pctx->is_uid_trusted = is_uid_trusted(cctx->client_euid,
- pctx->trusted_uids_count,
- pctx->trusted_uids);
-
- if (!pctx->is_uid_trusted) {
- DEBUG(SSSDBG_MINOR_FAILURE, "uid %"PRIu32" is not trusted.\n",
- cctx->client_euid);
- }
-
preq = talloc_zero(cctx, struct pam_auth_req);
if (!preq) {
return ENOMEM;
@@ -872,6 +863,16 @@ static int pam_forwarder(struct cli_ctx *cctx, int pam_cmd)
}
pd = preq->pd;
+ preq->is_uid_trusted = is_uid_trusted(cctx->client_euid,
+ pctx->trusted_uids_count,
+ pctx->trusted_uids);
+
+ if (!preq->is_uid_trusted) {
+ DEBUG(SSSDBG_MINOR_FAILURE, "uid %"PRIu32" is not trusted.\n",
+ cctx->client_euid);
+ }
+
+
pd->cmd = pam_cmd;
pd->priv = cctx->priv;
@@ -1304,7 +1305,7 @@ static void pam_dom_forwarder(struct pam_auth_req *preq)
}
/* Untrusted users can access only public domains. */
- if (!pctx->is_uid_trusted &&
+ if (!preq->is_uid_trusted &&
!is_domain_public(preq->pd->domain, pctx->public_domains,
pctx->public_domains_count)) {
DEBUG(SSSDBG_MINOR_FAILURE,
@@ -1317,7 +1318,7 @@ static void pam_dom_forwarder(struct pam_auth_req *preq)
/* skip this domain if not requested and the user is trusted
* as untrusted users can't request a domain */
- if (pctx->is_uid_trusted &&
+ if (preq->is_uid_trusted &&
!is_domain_requested(preq->pd, preq->pd->domain)) {
preq->pd->pam_status = PAM_USER_UNKNOWN;
pam_reply(preq);