Line data Source code
1 : /*
2 : Authors:
3 : Pavel Březina <pbrezina@redhat.com>
4 :
5 : Copyright (C) 2016 Red Hat
6 :
7 : This program is free software; you can redistribute it and/or modify
8 : it under the terms of the GNU General Public License as published by
9 : the Free Software Foundation; either version 3 of the License, or
10 : (at your option) any later version.
11 :
12 : This program is distributed in the hope that it will be useful,
13 : but WITHOUT ANY WARRANTY; without even the implied warranty of
14 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 : GNU General Public License for more details.
16 :
17 : You should have received a copy of the GNU General Public License
18 : along with this program. If not, see <http://www.gnu.org/licenses/>.
19 : */
20 :
21 : #include <security/pam_modules.h>
22 : #include <talloc.h>
23 : #include "config.h"
24 : #include "providers/data_provider/dp.h"
25 : #include "providers/backend.h"
26 : #include "util/util.h"
27 :
28 : struct dp_access_permit_handler_state {
29 : struct pam_data *pd;
30 : };
31 :
32 : struct tevent_req *
33 1 : dp_access_permit_handler_send(TALLOC_CTX *mem_ctx,
34 : void *data,
35 : struct pam_data *pd,
36 : struct dp_req_params *params)
37 : {
38 : struct dp_access_permit_handler_state *state;
39 : struct tevent_req *req;
40 :
41 1 : req = tevent_req_create(mem_ctx, &state,
42 : struct dp_access_permit_handler_state);
43 1 : if (req == NULL) {
44 0 : DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
45 0 : return NULL;
46 : }
47 :
48 1 : state->pd = pd;
49 1 : DEBUG(SSSDBG_TRACE_ALL, "Access permit, returning PAM_SUCCESS.\n");
50 1 : state->pd->pam_status = PAM_SUCCESS;
51 :
52 1 : tevent_req_done(req);
53 1 : tevent_req_post(req, params->ev);
54 :
55 1 : return req;
56 : }
57 :
58 : errno_t
59 1 : dp_access_permit_handler_recv(TALLOC_CTX *mem_ctx,
60 : struct tevent_req *req,
61 : struct pam_data **_data)
62 : {
63 1 : struct dp_access_permit_handler_state *state = NULL;
64 :
65 1 : state = tevent_req_data(req, struct dp_access_permit_handler_state);
66 :
67 1 : TEVENT_REQ_RETURN_ON_ERROR(req);
68 :
69 1 : *_data = talloc_steal(mem_ctx, state->pd);
70 :
71 1 : return EOK;
72 : }
73 :
74 : struct dp_access_deny_handler_state {
75 : struct pam_data *pd;
76 : };
77 :
78 : struct tevent_req *
79 1 : dp_access_deny_handler_send(TALLOC_CTX *mem_ctx,
80 : void *data,
81 : struct pam_data *pd,
82 : struct dp_req_params *params)
83 : {
84 : struct dp_access_deny_handler_state *state;
85 : struct tevent_req *req;
86 :
87 1 : req = tevent_req_create(mem_ctx, &state,
88 : struct dp_access_deny_handler_state);
89 1 : if (req == NULL) {
90 0 : DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
91 0 : return NULL;
92 : }
93 :
94 1 : state->pd = pd;
95 1 : DEBUG(SSSDBG_TRACE_ALL, "Access deny, returning PAM_PERM_DENIED.\n");
96 1 : state->pd->pam_status = PAM_PERM_DENIED;
97 :
98 1 : tevent_req_done(req);
99 1 : tevent_req_post(req, params->ev);
100 :
101 1 : return req;
102 : }
103 :
104 : errno_t
105 1 : dp_access_deny_handler_recv(TALLOC_CTX *mem_ctx,
106 : struct tevent_req *req,
107 : struct pam_data **_data)
108 : {
109 1 : struct dp_access_deny_handler_state *state = NULL;
110 :
111 1 : state = tevent_req_data(req, struct dp_access_deny_handler_state);
112 :
113 1 : TEVENT_REQ_RETURN_ON_ERROR(req);
114 :
115 1 : *_data = talloc_steal(mem_ctx, state->pd);
116 :
117 1 : return EOK;
118 : }
|