129 free_init_config(cfg); |
129 free_init_config(cfg); |
130 |
130 |
131 return 0; |
131 return 0; |
132 } |
132 } |
133 |
133 |
134 ServerConfiguration* load_server_conf(char *file) { |
134 ServerConfiguration* load_server_conf(CfgManager *mgr, char *file) { |
135 log_ereport(LOG_VERBOSE, "load_server_conf"); |
135 log_ereport(LOG_VERBOSE, "load_server_conf"); |
136 |
136 |
137 ServerConfig *serverconf = serverconfig_load(file); |
137 ServerConfig *serverconf = serverconfig_load(file); |
138 if(!serverconf) { |
138 if(!serverconf) { |
139 log_ereport(LOG_FAILURE, "Cannot load server.conf"); |
139 log_ereport(LOG_FAILURE, "Cannot load server.conf"); |
140 return NULL; |
140 return NULL; |
141 } |
141 } |
|
142 mgr->serverconf = serverconf; |
142 |
143 |
143 pool_handle_t *pool = pool_create(); |
144 pool_handle_t *pool = pool_create(); |
144 |
145 |
145 |
146 |
146 ServerConfiguration *serverconfig = pool_calloc(pool, 1, sizeof(ServerConfiguration)); |
147 ServerConfiguration *serverconfig = pool_calloc(pool, 1, sizeof(ServerConfiguration)); |
150 UcxAllocator allocator = util_pool_allocator(serverconfig->pool); |
151 UcxAllocator allocator = util_pool_allocator(serverconfig->pool); |
151 serverconfig->a = pool_malloc(pool, sizeof(UcxAllocator)); |
152 serverconfig->a = pool_malloc(pool, sizeof(UcxAllocator)); |
152 *serverconfig->a = allocator; |
153 *serverconfig->a = allocator; |
153 |
154 |
154 serverconfig->listeners = NULL; |
155 serverconfig->listeners = NULL; |
155 serverconfig->host_vs = ucx_map_new_a(&allocator, 16); |
156 serverconfig->host_vs = ucx_map_new_a(serverconfig->a, 16); |
156 serverconfig->authdbs = ucx_map_new_a(&allocator, 16); |
157 serverconfig->authdbs = ucx_map_new_a(serverconfig->a, 16); |
157 serverconfig->resources = ucx_map_new_a(&allocator, 16); |
158 serverconfig->resources = ucx_map_new_a(serverconfig->a, 16); |
158 serverconfig->dav = ucx_map_new_a(&allocator, 16); |
159 serverconfig->dav = ucx_map_new_a(serverconfig->a, 16); |
159 |
|
160 |
|
161 |
|
162 // TODO: init serverconfig stuff |
|
163 |
|
164 |
160 |
165 /* |
161 /* |
166 * convert ServerConfig to ServerConfiguration |
162 * convert ServerConfig to ServerConfiguration |
167 * |
163 * |
168 * its important to do this in the correct order: |
164 * its important to do this in the correct order: |
173 * AuthDB |
169 * AuthDB |
174 * Listener (we set the VirtualServer later) |
170 * Listener (we set the VirtualServer later) |
175 * VirtualServer (dependencies: Listener) |
171 * VirtualServer (dependencies: Listener) |
176 */ |
172 */ |
177 |
173 |
178 /* |
174 // load Runtime infos first, because we need that to change the uid |
179 * free stuff on error |
175 // and the server should do that as soon as possible |
180 */ |
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; |
181 |
194 |
182 // init logfile first |
195 // init logfile first |
183 UcxList *list = NULL; |
196 UcxList *list; |
184 |
197 |
185 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("LogFile")); |
198 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("LogFile")); |
186 if(list) { |
199 if(list) { |
187 ConfigNode *logobj = list->data; |
200 ConfigNode *logobj = list->data; |
188 if(!logobj) { |
201 if(!logobj) { |
199 // horrible error |
212 // horrible error |
200 return NULL; |
213 return NULL; |
201 } |
214 } |
202 ucx_list_free(list); |
215 ucx_list_free(list); |
203 |
216 |
204 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("Runtime")); |
217 |
205 UCX_FOREACH(elm, list) { |
|
206 ConfigNode *runtimeobj = elm->data; |
|
207 if(cfg_handle_runtime(serverconfig, runtimeobj)) { |
|
208 // error |
|
209 return NULL; |
|
210 } |
|
211 } |
|
212 ucx_list_free(list); |
|
213 |
218 |
214 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("Threadpool")); |
219 list = serverconfig_get_node_list(serverconf->root, CONFIG_NODE_OBJECT, SC("Threadpool")); |
215 UCX_FOREACH(elm, list) { |
220 UCX_FOREACH(elm, list) { |
216 if(cfg_handle_threadpool(serverconfig, elm->data)) { |
221 if(cfg_handle_threadpool(serverconfig, elm->data)) { |
217 return NULL; |
222 return NULL; |