156 serverconfig->host_vs = ucx_map_new_a(serverconfig->a, 16); |
156 serverconfig->host_vs = ucx_map_new_a(serverconfig->a, 16); |
157 serverconfig->authdbs = ucx_map_new_a(serverconfig->a, 16); |
157 serverconfig->authdbs = ucx_map_new_a(serverconfig->a, 16); |
158 serverconfig->resources = ucx_map_new_a(serverconfig->a, 16); |
158 serverconfig->resources = ucx_map_new_a(serverconfig->a, 16); |
159 serverconfig->dav = ucx_map_new_a(serverconfig->a, 16); |
159 serverconfig->dav = ucx_map_new_a(serverconfig->a, 16); |
160 |
160 |
|
161 // STAGE 1 load_server_conf: |
|
162 // At stage 1 we load the file and get the Runtime infos for changing |
|
163 // the uid, which must be done before most steps. |
|
164 // Before the uid can be changed, we also need to bind listeners, |
|
165 // therefore we need to get the listener config and all dependencies. |
|
166 // |
|
167 // Runtime |
|
168 // Listener (dependencies: Threadpool, EventHandler) |
|
169 |
|
170 // load Runtime config |
|
171 UcxList *list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("Runtime")); |
|
172 UCX_FOREACH(elm, list) { |
|
173 ConfigNode *runtimeobj = elm->data; |
|
174 if(cfg_handle_runtime(serverconfig, runtimeobj)) { |
|
175 // error |
|
176 return NULL; |
|
177 } |
|
178 } |
|
179 ucx_list_free(list); |
|
180 |
|
181 // load threadpool config |
|
182 log_ereport(LOG_DEBUG, "apply config: Threadpool"); |
|
183 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("Threadpool")); |
|
184 UCX_FOREACH(elm, list) { |
|
185 if(cfg_handle_threadpool(serverconfig, elm->data)) { |
|
186 return NULL; |
|
187 } |
|
188 } |
|
189 ucx_list_free(list); |
|
190 // check thread pool config |
|
191 if(check_thread_pool_cfg() != 0) { |
|
192 /* critical error */ |
|
193 return NULL; |
|
194 } |
|
195 |
|
196 // load eventhandler config |
|
197 log_ereport(LOG_DEBUG, "apply config: EventHandler"); |
|
198 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("EventHandler")); |
|
199 UCX_FOREACH(elm, list) { |
|
200 if(cfg_handle_eventhandler(serverconfig, elm->data)) { |
|
201 // error |
|
202 return NULL; |
|
203 } |
|
204 } |
|
205 // check event handler config |
|
206 if(check_event_handler_cfg() != 0) { |
|
207 /* critical error */ |
|
208 return NULL; |
|
209 } |
|
210 ucx_list_free(list); |
|
211 |
|
212 // load Listener config |
|
213 log_ereport(LOG_DEBUG, "apply config: Listener"); |
|
214 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("Listener")); |
|
215 UCX_FOREACH(elm, list) { |
|
216 ConfigNode *scfgobj = elm->data; |
|
217 if(cfg_handle_listener(serverconfig, scfgobj)) { |
|
218 return NULL; |
|
219 } |
|
220 } |
|
221 ucx_list_free(list); |
|
222 |
|
223 // we return here, to let the webserver use the runtime info to |
|
224 // change the uid if needed |
|
225 return serverconfig; |
|
226 } |
|
227 |
|
228 ServerConfiguration* apply_server_conf(CfgManager *mgr) { |
|
229 ServerConfig *serverconf = mgr->serverconf; |
|
230 ServerConfiguration *serverconfig = mgr->cfg; |
|
231 |
161 /* |
232 /* |
162 * convert ServerConfig to ServerConfiguration |
233 * convert ServerConfig to ServerConfiguration |
163 * |
234 * |
164 * its important to do this in the correct order: |
235 * its important to do this in the correct order: |
165 * LogFile (open log file first to log possible errors) |
236 * LogFile (open log file first to log possible errors) |
166 * Runtime |
|
167 * Threadpool |
237 * Threadpool |
168 * EventHandler |
238 * EventHandler |
169 * AuthDB |
239 * AuthDB |
170 * Listener (we set the VirtualServer later) |
240 * Listener (we set the VirtualServer later) |
171 * VirtualServer (dependencies: Listener) |
241 * VirtualServer (dependencies: Listener) |
172 */ |
242 */ |
173 |
|
174 // load Runtime infos first, because we need that to change the uid |
|
175 // and the server should do that as soon as possible |
|
176 UcxList *list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("Runtime")); |
|
177 UCX_FOREACH(elm, list) { |
|
178 ConfigNode *runtimeobj = elm->data; |
|
179 if(cfg_handle_runtime(serverconfig, runtimeobj)) { |
|
180 // error |
|
181 return NULL; |
|
182 } |
|
183 } |
|
184 ucx_list_free(list); |
|
185 |
|
186 // we return here, to let the webserver use the runtime info to |
|
187 // change the uid if needed |
|
188 return serverconfig; |
|
189 } |
|
190 |
|
191 ServerConfiguration* apply_server_conf(CfgManager *mgr) { |
|
192 ServerConfig *serverconf = mgr->serverconf; |
|
193 ServerConfiguration *serverconfig = mgr->cfg; |
|
194 |
243 |
195 // init logfile first |
244 // init logfile first |
196 UcxList *list; |
245 UcxList *list; |
197 |
246 |
198 log_ereport(LOG_DEBUG, "apply config: LogFile"); |
247 log_ereport(LOG_DEBUG, "apply config: LogFile"); |
212 } else { |
261 } else { |
213 // horrible error |
262 // horrible error |
214 return NULL; |
263 return NULL; |
215 } |
264 } |
216 ucx_list_free(list); |
265 ucx_list_free(list); |
217 |
|
218 |
|
219 log_ereport(LOG_DEBUG, "apply config: Threadpool"); |
|
220 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("Threadpool")); |
|
221 UCX_FOREACH(elm, list) { |
|
222 if(cfg_handle_threadpool(serverconfig, elm->data)) { |
|
223 return NULL; |
|
224 } |
|
225 } |
|
226 ucx_list_free(list); |
|
227 // check thread pool config |
|
228 if(check_thread_pool_cfg() != 0) { |
|
229 /* critical error */ |
|
230 return NULL; |
|
231 } |
|
232 |
|
233 log_ereport(LOG_DEBUG, "apply config: EventHandler"); |
|
234 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("EventHandler")); |
|
235 UCX_FOREACH(elm, list) { |
|
236 if(cfg_handle_eventhandler( |
|
237 serverconfig, elm->data)) { |
|
238 // error |
|
239 return NULL; |
|
240 } |
|
241 } |
|
242 // check event handler config |
|
243 if(check_event_handler_cfg() != 0) { |
|
244 /* critical error */ |
|
245 return NULL; |
|
246 } |
|
247 ucx_list_free(list); |
|
248 |
266 |
249 log_ereport(LOG_DEBUG, "apply config: AccessLog"); |
267 log_ereport(LOG_DEBUG, "apply config: AccessLog"); |
250 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("AccessLog")); |
268 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("AccessLog")); |
251 UCX_FOREACH(elm, list) { |
269 UCX_FOREACH(elm, list) { |
252 ConfigNode *scfgobj = elm->data; |
270 ConfigNode *scfgobj = elm->data; |
259 log_ereport(LOG_DEBUG, "apply config: AuthDB"); |
277 log_ereport(LOG_DEBUG, "apply config: AuthDB"); |
260 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("AuthDB")); |
278 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("AuthDB")); |
261 UCX_FOREACH(elm, list) { |
279 UCX_FOREACH(elm, list) { |
262 ConfigNode *scfgobj = elm->data; |
280 ConfigNode *scfgobj = elm->data; |
263 if(cfg_handle_authdb(serverconfig, scfgobj)) { |
281 if(cfg_handle_authdb(serverconfig, scfgobj)) { |
264 return NULL; |
|
265 } |
|
266 } |
|
267 ucx_list_free(list); |
|
268 |
|
269 log_ereport(LOG_DEBUG, "apply config: Listener"); |
|
270 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("Listener")); |
|
271 UCX_FOREACH(elm, list) { |
|
272 ConfigNode *scfgobj = elm->data; |
|
273 if(cfg_handle_listener(serverconfig, scfgobj)) { |
|
274 return NULL; |
282 return NULL; |
275 } |
283 } |
276 } |
284 } |
277 ucx_list_free(list); |
285 ucx_list_free(list); |
278 |
286 |