The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
base.c
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: 01175f0b117b27a07d985d507f4e31ba72db9f73 $
19 * @file src/process/ldap_sync/base.c
20 * @brief LDAP sync process module
21 *
22 * @copyright 2022 NetworkRADIUS SARL (legal@networkradius.com)
23 */
24#define LOG_PREFIX "process_ldap_sync"
25
26#include <freeradius-devel/unlang/interpret.h>
27#include <freeradius-devel/util/debug.h>
28#include <freeradius-devel/ldap/sync.h>
29
31
37
39
46
57
61
62#define PROCESS_PACKET_TYPE fr_ldap_sync_packet_code_t
63#define PROCESS_CODE_MAX FR_LDAP_SYNC_CODE_MAX
64#define PROCESS_PACKET_CODE_VALID FR_LDAP_SYNC_PACKET_CODE_VALID
65#define PROCESS_INST process_ldap_sync_t
66#include <freeradius-devel/server/process.h>
67
68
69static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
70{
71 fr_process_state_t const *state;
72
74
76
77 fr_assert(FR_LDAP_SYNC_PACKET_CODE_VALID(request->packet->code));
78
79 request->component = "ldap_sync";
80 request->module = NULL;
81 fr_assert(request->proto_dict == dict_ldap_sync);
82
83 UPDATE_STATE(packet);
84
85 return state->recv(p_result, mctx, request);
86}
87
88static fr_process_state_t const process_state[] = {
90 .default_reply = FR_LDAP_SYNC_CODE_ENTRY_RESPONSE,
91 .default_rcode = RLM_MODULE_NOOP,
92 .recv = recv_generic,
93 .resume = resume_recv_generic,
94 .section_offset = offsetof(process_ldap_sync_sections_t, recv_present),
95 },
97 .default_reply = FR_LDAP_SYNC_CODE_ENTRY_RESPONSE,
98 .default_rcode = RLM_MODULE_NOOP,
99 .recv = recv_generic,
100 .resume = resume_recv_generic,
101 .section_offset = offsetof(process_ldap_sync_sections_t, recv_add)
102 },
104 .default_reply = FR_LDAP_SYNC_CODE_ENTRY_RESPONSE,
105 .default_rcode = RLM_MODULE_NOOP,
106 .recv = recv_generic,
107 .resume = resume_recv_generic,
108 .section_offset = offsetof(process_ldap_sync_sections_t, recv_delete),
109 },
111 .default_reply = FR_LDAP_SYNC_CODE_ENTRY_RESPONSE,
112 .default_rcode = RLM_MODULE_NOOP,
113 .recv = recv_generic,
114 .resume = resume_recv_generic,
115 .section_offset = offsetof(process_ldap_sync_sections_t, recv_modify),
116 },
118 .default_rcode = RLM_MODULE_NOOP,
119 .send = send_generic,
120 .resume = resume_send_generic,
121 },
123 .packet_type = {
129 },
131 .default_rcode = RLM_MODULE_NOOP,
132 .recv = recv_generic,
133 .resume = resume_recv_generic,
134 .section_offset = offsetof(process_ldap_sync_sections_t, load_cookie),
135 },
137 .default_rcode = RLM_MODULE_NOOP,
138 .send = send_generic,
139 .resume = resume_send_generic,
140 },
142 .default_rcode = RLM_MODULE_NOOP,
143 .send = send_generic,
144 .resume = resume_send_generic
145 },
148 .default_rcode = RLM_MODULE_NOOP,
149 .recv = recv_generic,
150 .resume = resume_recv_generic,
151 .section_offset = offsetof(process_ldap_sync_sections_t, store_cookie),
152 },
154 .default_rcode = RLM_MODULE_NOOP,
155 .send = send_generic,
156 .resume = resume_send_generic,
157 }
158};
159
161 {
162 .section = SECTION_NAME("load", "Cookie"),
163 .actions = &mod_actions_authorize,
164 .offset = PROCESS_CONF_OFFSET(load_cookie)
165 },
166 {
167 .section = SECTION_NAME("store", "Cookie"),
169 .offset = PROCESS_CONF_OFFSET(store_cookie)
170 },
171 {
172 .section = SECTION_NAME("recv", "Add"),
174 .offset = PROCESS_CONF_OFFSET(recv_add)
175 },
176 {
177 .section = SECTION_NAME("recv", "Present"),
179 .offset = PROCESS_CONF_OFFSET(recv_present)
180 },
181 {
182 .section = SECTION_NAME("recv", "Delete"),
184 .offset = PROCESS_CONF_OFFSET(recv_delete)
185 },
186 {
187 .section = SECTION_NAME("recv", "Modify"),
189 .offset = PROCESS_CONF_OFFSET(recv_modify)
190 },
191
193};
194
197 .common = {
198 .magic = MODULE_MAGIC_INIT,
199 .name = "process_ldap_sync",
201 MODULE_RCTX(process_rctx_t)
202 },
203
204 .process = mod_process,
205 .compile_list = compile_list,
206 .dict = &dict_ldap_sync,
207 .packet_type = &attr_packet_type
208};
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:106
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
Definition dict.h:292
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Definition dict.h:305
#define DICT_AUTOLOAD_TERMINATOR
Definition dict.h:311
Specifies an attribute which must be present for the module to function.
Definition dict.h:291
Specifies a dictionary which must be loaded/loadable for the module to function.
Definition dict.h:304
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
fr_dict_attr_t const * attr_packet_type
Definition base.c:91
@ FR_TYPE_UINT32
32 Bit unsigned integer.
unlang_mod_actions_t const mod_actions_authorize
Definition mod_action.c:45
unlang_mod_action_t actions[RLM_MODULE_NUMCODES]
Definition mod_action.h:69
module_instance_t const * mi
Instance of the module being instantiated.
Definition module_ctx.h:42
Temporary structure to hold arguments for module calls.
Definition module_ctx.h:41
static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition base.c:168
static const virtual_server_compile_t compile_list[]
Definition base.c:192
static fr_process_state_t const process_state[]
Definition base.c:68
CONF_SECTION * recv_delete
Definition base.c:54
fr_dict_autoload_t process_ldap_sync_dict[]
Definition base.c:33
static fr_dict_t const * dict_ldap_sync
Definition base.c:30
CONF_SECTION * recv_modify
Definition base.c:55
process_ldap_sync_sections_t sections
Definition base.c:59
fr_dict_attr_autoload_t process_ldap_sync_dict_attr[]
Definition base.c:41
CONF_SECTION * recv_add
Definition base.c:52
CONF_SECTION * store_cookie
Definition base.c:51
fr_process_module_t process_ldap_sync
Definition base.c:196
CONF_SECTION * recv_present
Definition base.c:53
CONF_SECTION * load_cookie
Definition base.c:50
#define PROCESS_TRACE
Trace each state function as it's entered.
Definition process.h:55
#define PROCESS_CONF_OFFSET(_x)
Definition process.h:79
module_t common
Common fields for all loadable modules.
Common public symbol definition for all process modules.
#define fr_assert(_expr)
Definition rad_assert.h:37
@ RLM_MODULE_INVALID
The module considers the request invalid.
Definition rcode.h:51
@ RLM_MODULE_FAIL
Module failed, don't reply.
Definition rcode.h:48
@ RLM_MODULE_DISALLOW
Reject the request (user is locked out).
Definition rcode.h:52
@ RLM_MODULE_REJECT
Immediately reject the request.
Definition rcode.h:47
@ RLM_MODULE_TIMEOUT
Module (or section) timed out.
Definition rcode.h:56
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
Definition rcode.h:54
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
Definition section.h:39
void * data
Module's instance data.
Definition module.h:293
#define MODULE_RCTX(_ctype)
Definition module.h:259
#define MODULE_INST(_ctype)
Definition module.h:257
#define FR_LDAP_SYNC_PACKET_CODE_VALID(_code)
Definition sync.h:58
@ FR_LDAP_SYNC_CODE_PRESENT
LDAP server indicates a particular object is present and unchanged.
Definition sync.h:33
@ FR_LDAP_SYNC_CODE_COOKIE_STORE_RESPONSE
Response to storing the new cookie.
Definition sync.h:52
@ FR_LDAP_SYNC_CODE_ENTRY_RESPONSE
Response packet to present / add / modify / delete.
Definition sync.h:42
@ FR_LDAP_SYNC_CODE_COOKIE_LOAD_FAIL
Response when coolie load fails.
Definition sync.h:48
@ FR_LDAP_SYNC_CODE_ADD
Object has been added to the LDAP directory.
Definition sync.h:36
@ FR_LDAP_SYNC_CODE_COOKIE_STORE
The server has sent a new cookie.
Definition sync.h:50
@ FR_LDAP_SYNC_CODE_COOKIE_LOAD_RESPONSE
Response with the returned cookie.
Definition sync.h:46
@ FR_LDAP_SYNC_CODE_DELETE
Object has been deleted.
Definition sync.h:40
@ FR_LDAP_SYNC_CODE_COOKIE_LOAD
Before the sync starts, request any previously stored cookie.
Definition sync.h:44
@ FR_LDAP_SYNC_CODE_MODIFY
Object has been modified.
Definition sync.h:38
#define talloc_get_type_abort_const
Definition talloc.h:117
section_name_t const * section
Identifier for the section.
#define COMPILE_TERMINATOR
Processing sections which are allowed in this virtual server.