1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose Kerberos 5 Backend Module - access control
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose Sumit Bose <sbose@redhat.com>
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose Copyright (C) 2010 Red Hat
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose This program is free software; you can redistribute it and/or modify
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose it under the terms of the GNU General Public License as published by
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose the Free Software Foundation; either version 3 of the License, or
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose (at your option) any later version.
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose This program is distributed in the hope that it will be useful,
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose but WITHOUT ANY WARRANTY; without even the implied warranty of
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose GNU General Public License for more details.
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose You should have received a copy of the GNU General Public License
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose along with this program. If not, see <http://www.gnu.org/licenses/>.
7baccb545ac9829b7e1990f45ff6f70e2de55c2aSimo Sorcestatic void krb5_access_done(struct tevent_req *subreq);
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bosestruct tevent_req *krb5_access_send(TALLOC_CTX *mem_ctx,
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Bose req = tevent_req_create(mem_ctx, &state, struct krb5_access_state);
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create failed.\n");
fedfb7c62b4efa89d18d0d3a7895a2a34ec4ce42Jakub Hrozek ret = get_domain_or_subdomain(be_ctx, pd->domain, &dom);
fedfb7c62b4efa89d18d0d3a7895a2a34ec4ce42Jakub Hrozek DEBUG(SSSDBG_OP_FAILURE, "get_domain_or_subdomain failed.\n");
fedfb7c62b4efa89d18d0d3a7895a2a34ec4ce42Jakub Hrozek ret = krb5_setup(state, pd, dom, krb5_ctx, &state->kr);
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "krb5_setup failed.\n");
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "Unexpected pam task.\n");
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "talloc_array failed.\n");
b3292840ebaa747a9fd596ff47cc5d18198361d0Michal Zidek ret = sysdb_get_user_attr(state, be_ctx->domain, state->pd->user, attrs,
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov "sysdb search for upn of user [%s] failed.\n", pd->user);
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov "No attributes for user [%s] found.\n", pd->user);
aa8a8318aaa3270e9d9957d0c22dec6342360a37Pavel Reichl ret = find_or_guess_upn(state, res->msgs[0], krb5_ctx, be_ctx->domain,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "find_or_guess_upn failed.\n");
e7a4ea98c6751a8c3d8405ca31481006f29b901eSumit Bose state->kr->uid = ldb_msg_find_attr_as_uint64(res->msgs[0], SYSDB_UIDNUM,
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov "UID for user [%s] not known.\n", pd->user);
e7a4ea98c6751a8c3d8405ca31481006f29b901eSumit Bose state->kr->gid = ldb_msg_find_attr_as_uint64(res->msgs[0], SYSDB_GIDNUM,
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov "GID for user [%s] not known.\n", pd->user);
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov "User search for [%s] returned > 1 results!\n", pd->user);
e7a4ea98c6751a8c3d8405ca31481006f29b901eSumit Bose subreq = handle_child_send(state, state->ev, state->kr);
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "handle_child_send failed.\n");
7baccb545ac9829b7e1990f45ff6f70e2de55c2aSimo Sorce tevent_req_set_callback(subreq, krb5_access_done, req);
7baccb545ac9829b7e1990f45ff6f70e2de55c2aSimo Sorcestatic void krb5_access_done(struct tevent_req *subreq)
e7a4ea98c6751a8c3d8405ca31481006f29b901eSumit Bose struct tevent_req *req = tevent_req_callback_data(subreq, struct tevent_req);
e7a4ea98c6751a8c3d8405ca31481006f29b901eSumit Bose struct krb5_access_state *state = tevent_req_data(req,
e7a4ea98c6751a8c3d8405ca31481006f29b901eSumit Bose ret = handle_child_recv(subreq, state, &buf, &len);
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov "child failed [%d][%s].\n", ret, strerror(ret));
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "message has the wrong size.\n");
1e29e68388c2e9c5da9cb0afe997bc1b4e6933beSumit Boseint krb5_access_recv(struct tevent_req *req, bool *access_allowed)