6 #include "configparser.h"
7 #include "configfile.h"
23 static int config_insert(server
*srv
) {
26 buffer
*stat_cache_string
;
28 config_values_t cv
[] = {
29 { "server.bind", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 0 */
30 { "server.errorlog", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 1 */
31 { "server.errorfile-prefix", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 2 */
32 { "server.chroot", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 3 */
33 { "server.username", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 4 */
34 { "server.groupname", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 5 */
35 { "server.port", NULL
, T_CONFIG_SHORT
, T_CONFIG_SCOPE_SERVER
}, /* 6 */
36 { "server.tag", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_CONNECTION
}, /* 7 */
37 { "server.use-ipv6", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_CONNECTION
}, /* 8 */
38 { "server.modules", NULL
, T_CONFIG_ARRAY
, T_CONFIG_SCOPE_SERVER
}, /* 9 */
40 { "server.event-handler", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 10 */
41 { "server.pid-file", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 11 */
42 { "server.max-request-size", NULL
, T_CONFIG_INT
, T_CONFIG_SCOPE_CONNECTION
}, /* 12 */
43 { "server.max-worker", NULL
, T_CONFIG_SHORT
, T_CONFIG_SCOPE_SERVER
}, /* 13 */
44 { "server.document-root", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_CONNECTION
}, /* 14 */
45 { "server.force-lowercase-filenames", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
},/* 15 */
46 { "debug.log-condition-handling", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 16 */
47 { "server.max-keep-alive-requests", NULL
, T_CONFIG_SHORT
, T_CONFIG_SCOPE_CONNECTION
},/* 17 */
48 { "server.name", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_CONNECTION
}, /* 18 */
49 { "server.max-keep-alive-idle", NULL
, T_CONFIG_SHORT
, T_CONFIG_SCOPE_CONNECTION
}, /* 19 */
51 { "server.max-read-idle", NULL
, T_CONFIG_SHORT
, T_CONFIG_SCOPE_CONNECTION
}, /* 20 */
52 { "server.max-write-idle", NULL
, T_CONFIG_SHORT
, T_CONFIG_SCOPE_CONNECTION
}, /* 21 */
53 { "server.error-handler-404", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_CONNECTION
}, /* 22 */
54 { "server.max-fds", NULL
, T_CONFIG_SHORT
, T_CONFIG_SCOPE_SERVER
}, /* 23 */
56 { "server.follow-symlink", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_CONNECTION
}, /* 24 */
58 { "server.follow-symlink",
59 "Your system lacks lstat(). We can not differ symlinks from files."
60 "Please remove server.follow-symlinks from your config.",
61 T_CONFIG_UNSUPPORTED
, T_CONFIG_SCOPE_UNSET
}, /* 24 */
63 { "server.kbytes-per-second", NULL
, T_CONFIG_SHORT
, T_CONFIG_SCOPE_CONNECTION
}, /* 25 */
64 { "connection.kbytes-per-second", NULL
, T_CONFIG_SHORT
, T_CONFIG_SCOPE_CONNECTION
}, /* 26 */
65 { "mimetype.use-xattr", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_CONNECTION
}, /* 27 */
66 { "mimetype.assign", NULL
, T_CONFIG_ARRAY
, T_CONFIG_SCOPE_CONNECTION
}, /* 28 */
67 { "ssl.pemfile", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 29 */
69 { "ssl.engine", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 30 */
71 { "debug.log-file-not-found", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 31 */
72 { "debug.log-request-handling", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 32 */
73 { "debug.log-response-header", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 33 */
74 { "debug.log-request-header", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 34 */
75 { "debug.log-ssl-noise", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 35 */
77 { "server.protocol-http11", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 36 */
78 { "debug.log-request-header-on-error", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 37 */
79 { "debug.log-state-handling", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 38 */
80 { "ssl.ca-file", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 39 */
82 { "server.errorlog-use-syslog", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 40 */
83 { "server.range-requests", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_CONNECTION
}, /* 41 */
84 { "server.stat-cache-engine", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_CONNECTION
}, /* 42 */
85 { "server.max-connections", NULL
, T_CONFIG_SHORT
, T_CONFIG_SCOPE_SERVER
}, /* 43 */
86 { "server.network-backend", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_CONNECTION
}, /* 44 */
87 { "server.upload-dirs", NULL
, T_CONFIG_ARRAY
, T_CONFIG_SCOPE_CONNECTION
}, /* 45 */
88 { "server.core-files", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_CONNECTION
}, /* 46 */
89 { "ssl.cipher-list", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 47 */
90 { "ssl.use-sslv2", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_CONNECTION
}, /* 48 */
91 { "etag.use-inode", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 49 */
92 { "etag.use-mtime", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 50 */
93 { "etag.use-size", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 51 */
94 { "server.reject-expect-100-with-417", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 52 */
95 { "debug.log-timeouts", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_CONNECTION
}, /* 53 */
96 { "server.defer-accept", NULL
, T_CONFIG_SHORT
, T_CONFIG_SCOPE_CONNECTION
}, /* 54 */
97 { "server.breakagelog", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 55 */
98 { "ssl.verifyclient.activate", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 56 */
99 { "ssl.verifyclient.enforce", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 57 */
100 { "ssl.verifyclient.depth", NULL
, T_CONFIG_SHORT
, T_CONFIG_SCOPE_SERVER
}, /* 58 */
101 { "ssl.verifyclient.username", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 59 */
102 { "ssl.verifyclient.exportcert", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 60 */
104 { "server.set-v6only", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_CONNECTION
}, /* 61 */
105 { "ssl.use-sslv3", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 62 */
106 { "ssl.dh-file", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 63 */
107 { "ssl.ec-curve", NULL
, T_CONFIG_STRING
, T_CONFIG_SCOPE_SERVER
}, /* 64 */
108 { "ssl.disable-client-renegotiation", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
},/* 65 */
109 { "ssl.honor-cipher-order", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 66 */
110 { "ssl.empty-fragments", NULL
, T_CONFIG_BOOLEAN
, T_CONFIG_SCOPE_SERVER
}, /* 67 */
112 { "server.host", "use server.bind instead", T_CONFIG_DEPRECATED
, T_CONFIG_SCOPE_UNSET
},
113 { "server.docroot", "use server.document-root instead", T_CONFIG_DEPRECATED
, T_CONFIG_SCOPE_UNSET
},
114 { "server.virtual-root", "load mod_simple_vhost and use simple-vhost.server-root instead", T_CONFIG_DEPRECATED
, T_CONFIG_SCOPE_UNSET
},
115 { "server.virtual-default-host", "load mod_simple_vhost and use simple-vhost.default-host instead", T_CONFIG_DEPRECATED
, T_CONFIG_SCOPE_UNSET
},
116 { "server.virtual-docroot", "load mod_simple_vhost and use simple-vhost.document-root instead", T_CONFIG_DEPRECATED
, T_CONFIG_SCOPE_UNSET
},
117 { "server.userid", "use server.username instead", T_CONFIG_DEPRECATED
, T_CONFIG_SCOPE_UNSET
},
118 { "server.groupid", "use server.groupname instead", T_CONFIG_DEPRECATED
, T_CONFIG_SCOPE_UNSET
},
119 { "server.use-keep-alive", "use server.max-keep-alive-requests = 0 instead", T_CONFIG_DEPRECATED
, T_CONFIG_SCOPE_UNSET
},
120 { "server.force-lower-case-files", "use server.force-lowercase-filenames instead", T_CONFIG_DEPRECATED
, T_CONFIG_SCOPE_UNSET
},
122 { NULL
, NULL
, T_CONFIG_UNSET
, T_CONFIG_SCOPE_UNSET
}
127 cv
[0].destination
= srv
->srvconf
.bindhost
;
128 cv
[1].destination
= srv
->srvconf
.errorlog_file
;
129 cv
[3].destination
= srv
->srvconf
.changeroot
;
130 cv
[4].destination
= srv
->srvconf
.username
;
131 cv
[5].destination
= srv
->srvconf
.groupname
;
132 cv
[6].destination
= &(srv
->srvconf
.port
);
134 cv
[9].destination
= srv
->srvconf
.modules
;
135 cv
[10].destination
= srv
->srvconf
.event_handler
;
136 cv
[11].destination
= srv
->srvconf
.pid_file
;
138 cv
[13].destination
= &(srv
->srvconf
.max_worker
);
139 cv
[23].destination
= &(srv
->srvconf
.max_fds
);
140 cv
[37].destination
= &(srv
->srvconf
.log_request_header_on_error
);
141 cv
[38].destination
= &(srv
->srvconf
.log_state_handling
);
143 cv
[40].destination
= &(srv
->srvconf
.errorlog_use_syslog
);
145 stat_cache_string
= buffer_init();
146 cv
[42].destination
= stat_cache_string
;
147 cv
[44].destination
= srv
->srvconf
.network_backend
;
148 cv
[45].destination
= srv
->srvconf
.upload_tempdirs
;
149 cv
[46].destination
= &(srv
->srvconf
.enable_cores
);
151 cv
[43].destination
= &(srv
->srvconf
.max_conns
);
152 cv
[12].destination
= &(srv
->srvconf
.max_request_size
);
153 cv
[52].destination
= &(srv
->srvconf
.reject_expect_100_with_417
);
154 cv
[55].destination
= srv
->srvconf
.breakagelog_file
;
156 srv
->config_storage
= calloc(1, srv
->config_context
->used
* sizeof(specific_config
*));
158 force_assert(srv
->config_storage
);
160 for (i
= 0; i
< srv
->config_context
->used
; i
++) {
163 s
= calloc(1, sizeof(specific_config
));
165 s
->document_root
= buffer_init();
166 s
->mimetypes
= array_init();
167 s
->server_name
= buffer_init();
168 s
->ssl_pemfile
= buffer_init();
169 s
->ssl_ca_file
= buffer_init();
170 s
->error_handler
= buffer_init();
171 s
->server_tag
= buffer_init();
172 s
->ssl_cipher_list
= buffer_init();
173 s
->ssl_dh_file
= buffer_init();
174 s
->ssl_ec_curve
= buffer_init();
175 s
->errorfile_prefix
= buffer_init();
176 s
->max_keep_alive_requests
= 16;
177 s
->max_keep_alive_idle
= 5;
178 s
->max_read_idle
= 60;
179 s
->max_write_idle
= 360;
182 s
->ssl_honor_cipher_order
= 1;
183 s
->ssl_empty_fragments
= 0;
184 s
->ssl_use_sslv2
= 0;
185 s
->ssl_use_sslv3
= 0;
190 s
->follow_symlink
= 1;
192 s
->kbytes_per_second
= 0;
194 s
->etag_use_inode
= 1;
195 s
->etag_use_mtime
= 1;
196 s
->etag_use_size
= 1;
197 s
->range_requests
= 1;
198 s
->force_lowercase_filenames
= (i
== 0) ? 2 : 0; /* we wan't to detect later if user changed this for global section */
199 s
->global_kbytes_per_second
= 0;
200 s
->global_bytes_per_second_cnt
= 0;
201 s
->global_bytes_per_second_cnt_ptr
= &s
->global_bytes_per_second_cnt
;
202 s
->ssl_verifyclient
= 0;
203 s
->ssl_verifyclient_enforce
= 1;
204 s
->ssl_verifyclient_username
= buffer_init();
205 s
->ssl_verifyclient_depth
= 9;
206 s
->ssl_verifyclient_export_cert
= 0;
207 s
->ssl_disable_client_renegotiation
= 1;
209 cv
[2].destination
= s
->errorfile_prefix
;
211 cv
[7].destination
= s
->server_tag
;
212 cv
[8].destination
= &(s
->use_ipv6
);
213 cv
[61].destination
= &(s
->set_v6only
);
214 cv
[54].destination
= &(s
->defer_accept
);
218 cv
[14].destination
= s
->document_root
;
219 cv
[15].destination
= &(s
->force_lowercase_filenames
);
220 cv
[16].destination
= &(s
->log_condition_handling
);
221 cv
[17].destination
= &(s
->max_keep_alive_requests
);
222 cv
[18].destination
= s
->server_name
;
223 cv
[19].destination
= &(s
->max_keep_alive_idle
);
224 cv
[20].destination
= &(s
->max_read_idle
);
225 cv
[21].destination
= &(s
->max_write_idle
);
226 cv
[22].destination
= s
->error_handler
;
228 cv
[24].destination
= &(s
->follow_symlink
);
231 cv
[25].destination
= &(s
->global_kbytes_per_second
);
232 cv
[26].destination
= &(s
->kbytes_per_second
);
233 cv
[27].destination
= &(s
->use_xattr
);
234 cv
[28].destination
= s
->mimetypes
;
235 cv
[29].destination
= s
->ssl_pemfile
;
236 cv
[30].destination
= &(s
->ssl_enabled
);
238 cv
[31].destination
= &(s
->log_file_not_found
);
239 cv
[32].destination
= &(s
->log_request_handling
);
240 cv
[33].destination
= &(s
->log_response_header
);
241 cv
[34].destination
= &(s
->log_request_header
);
242 cv
[35].destination
= &(s
->log_ssl_noise
);
243 cv
[53].destination
= &(s
->log_timeouts
);
245 cv
[36].destination
= &(s
->allow_http11
);
246 cv
[39].destination
= s
->ssl_ca_file
;
247 cv
[41].destination
= &(s
->range_requests
);
249 cv
[47].destination
= s
->ssl_cipher_list
;
250 cv
[48].destination
= &(s
->ssl_use_sslv2
);
251 cv
[62].destination
= &(s
->ssl_use_sslv3
);
252 cv
[63].destination
= s
->ssl_dh_file
;
253 cv
[64].destination
= s
->ssl_ec_curve
;
254 cv
[66].destination
= &(s
->ssl_honor_cipher_order
);
255 cv
[67].destination
= &(s
->ssl_empty_fragments
);
257 cv
[49].destination
= &(s
->etag_use_inode
);
258 cv
[50].destination
= &(s
->etag_use_mtime
);
259 cv
[51].destination
= &(s
->etag_use_size
);
262 cv
[56].destination
= &(s
->ssl_verifyclient
);
263 cv
[57].destination
= &(s
->ssl_verifyclient_enforce
);
264 cv
[58].destination
= &(s
->ssl_verifyclient_depth
);
265 cv
[59].destination
= s
->ssl_verifyclient_username
;
266 cv
[60].destination
= &(s
->ssl_verifyclient_export_cert
);
267 cv
[65].destination
= &(s
->ssl_disable_client_renegotiation
);
269 srv
->config_storage
[i
] = s
;
271 if (0 != (ret
= config_insert_values_global(srv
, ((data_config
*)srv
->config_context
->data
[i
])->value
, cv
))) {
276 if (buffer_string_is_empty(stat_cache_string
)) {
277 srv
->srvconf
.stat_cache_engine
= STAT_CACHE_ENGINE_SIMPLE
;
278 } else if (buffer_is_equal_string(stat_cache_string
, CONST_STR_LEN("simple"))) {
279 srv
->srvconf
.stat_cache_engine
= STAT_CACHE_ENGINE_SIMPLE
;
281 } else if (buffer_is_equal_string(stat_cache_string
, CONST_STR_LEN("fam"))) {
282 srv
->srvconf
.stat_cache_engine
= STAT_CACHE_ENGINE_FAM
;
284 } else if (buffer_is_equal_string(stat_cache_string
, CONST_STR_LEN("disable"))) {
285 srv
->srvconf
.stat_cache_engine
= STAT_CACHE_ENGINE_NONE
;
287 log_error_write(srv
, __FILE__
, __LINE__
, "sb",
288 "server.stat-cache-engine can be one of \"disable\", \"simple\","
292 " but not:", stat_cache_string
);
296 buffer_free(stat_cache_string
);
303 #define PATCH(x) con->conf.x = s->x
304 int config_setup_connection(server
*srv
, connection
*con
) {
305 specific_config
*s
= srv
->config_storage
[0];
309 PATCH(document_root
);
310 PATCH(max_keep_alive_requests
);
311 PATCH(max_keep_alive_idle
);
312 PATCH(max_read_idle
);
313 PATCH(max_write_idle
);
315 PATCH(error_handler
);
316 PATCH(errorfile_prefix
);
318 PATCH(follow_symlink
);
321 PATCH(kbytes_per_second
);
322 PATCH(global_kbytes_per_second
);
323 PATCH(global_bytes_per_second_cnt
);
325 con
->conf
.global_bytes_per_second_cnt_ptr
= &s
->global_bytes_per_second_cnt
;
326 buffer_copy_buffer(con
->server_name
, s
->server_name
);
328 PATCH(log_request_header
);
329 PATCH(log_response_header
);
330 PATCH(log_request_handling
);
331 PATCH(log_condition_handling
);
332 PATCH(log_file_not_found
);
333 PATCH(log_ssl_noise
);
336 PATCH(range_requests
);
337 PATCH(force_lowercase_filenames
);
342 PATCH(ssl_pemfile_x509
);
343 PATCH(ssl_pemfile_pkey
);
347 PATCH(ssl_ca_file_cert_names
);
349 PATCH(ssl_cipher_list
);
352 PATCH(ssl_honor_cipher_order
);
353 PATCH(ssl_empty_fragments
);
354 PATCH(ssl_use_sslv2
);
355 PATCH(ssl_use_sslv3
);
356 PATCH(etag_use_inode
);
357 PATCH(etag_use_mtime
);
358 PATCH(etag_use_size
);
360 PATCH(ssl_verifyclient
);
361 PATCH(ssl_verifyclient_enforce
);
362 PATCH(ssl_verifyclient_depth
);
363 PATCH(ssl_verifyclient_username
);
364 PATCH(ssl_verifyclient_export_cert
);
365 PATCH(ssl_disable_client_renegotiation
);
370 int config_patch_connection(server
*srv
, connection
*con
, comp_key_t comp
) {
373 con
->conditional_is_valid
[comp
] = 1;
375 /* skip the first, the global context */
376 for (i
= 1; i
< srv
->config_context
->used
; i
++) {
377 data_config
*dc
= (data_config
*)srv
->config_context
->data
[i
];
378 specific_config
*s
= srv
->config_storage
[i
];
380 /* condition didn't match */
381 if (!config_check_cond(srv
, con
, dc
)) continue;
384 for (j
= 0; j
< dc
->value
->used
; j
++) {
385 data_unset
*du
= dc
->value
->data
[j
];
387 if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.document-root"))) {
388 PATCH(document_root
);
389 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.range-requests"))) {
390 PATCH(range_requests
);
391 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.error-handler-404"))) {
392 PATCH(error_handler
);
393 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.errorfile-prefix"))) {
394 PATCH(errorfile_prefix
);
395 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("mimetype.assign"))) {
397 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.max-keep-alive-requests"))) {
398 PATCH(max_keep_alive_requests
);
399 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.max-keep-alive-idle"))) {
400 PATCH(max_keep_alive_idle
);
401 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.max-write-idle"))) {
402 PATCH(max_write_idle
);
403 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.max-read-idle"))) {
404 PATCH(max_read_idle
);
405 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("mimetype.use-xattr"))) {
407 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("etag.use-inode"))) {
408 PATCH(etag_use_inode
);
409 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("etag.use-mtime"))) {
410 PATCH(etag_use_mtime
);
411 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("etag.use-size"))) {
412 PATCH(etag_use_size
);
413 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.pemfile"))) {
416 PATCH(ssl_pemfile_x509
);
417 PATCH(ssl_pemfile_pkey
);
419 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.ca-file"))) {
422 PATCH(ssl_ca_file_cert_names
);
424 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.honor-cipher-order"))) {
425 PATCH(ssl_honor_cipher_order
);
426 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.empty-fragments"))) {
427 PATCH(ssl_empty_fragments
);
428 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.use-sslv2"))) {
429 PATCH(ssl_use_sslv2
);
430 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.use-sslv3"))) {
431 PATCH(ssl_use_sslv3
);
432 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.cipher-list"))) {
433 PATCH(ssl_cipher_list
);
434 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.engine"))) {
436 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.dh-file"))) {
438 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.ec-curve"))) {
441 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.follow-symlink"))) {
442 PATCH(follow_symlink
);
444 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.name"))) {
445 buffer_copy_buffer(con
->server_name
, s
->server_name
);
446 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.tag"))) {
448 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("connection.kbytes-per-second"))) {
449 PATCH(kbytes_per_second
);
450 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("debug.log-request-handling"))) {
451 PATCH(log_request_handling
);
452 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("debug.log-request-header"))) {
453 PATCH(log_request_header
);
454 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("debug.log-response-header"))) {
455 PATCH(log_response_header
);
456 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("debug.log-condition-handling"))) {
457 PATCH(log_condition_handling
);
458 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("debug.log-file-not-found"))) {
459 PATCH(log_file_not_found
);
460 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("debug.log-ssl-noise"))) {
461 PATCH(log_ssl_noise
);
462 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("debug.log-timeouts"))) {
464 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.protocol-http11"))) {
466 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.force-lowercase-filenames"))) {
467 PATCH(force_lowercase_filenames
);
468 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("server.kbytes-per-second"))) {
469 PATCH(global_kbytes_per_second
);
470 PATCH(global_bytes_per_second_cnt
);
471 con
->conf
.global_bytes_per_second_cnt_ptr
= &s
->global_bytes_per_second_cnt
;
472 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.verifyclient.activate"))) {
473 PATCH(ssl_verifyclient
);
474 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.verifyclient.enforce"))) {
475 PATCH(ssl_verifyclient_enforce
);
476 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.verifyclient.depth"))) {
477 PATCH(ssl_verifyclient_depth
);
478 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.verifyclient.username"))) {
479 PATCH(ssl_verifyclient_username
);
480 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.verifyclient.exportcert"))) {
481 PATCH(ssl_verifyclient_export_cert
);
482 } else if (buffer_is_equal_string(du
->key
, CONST_STR_LEN("ssl.disable-client-renegotiation"))) {
483 PATCH(ssl_disable_client_renegotiation
);
488 con
->etag_flags
= (con
->conf
.etag_use_mtime
? ETAG_USE_MTIME
: 0) |
489 (con
->conf
.etag_use_inode
? ETAG_USE_INODE
: 0) |
490 (con
->conf
.etag_use_size
? ETAG_USE_SIZE
: 0);
500 const buffer
*source
;
514 static int tokenizer_open(server
*srv
, tokenizer_t
*t
, buffer
*basedir
, const char *fn
) {
515 if (buffer_string_is_empty(basedir
) ||
516 (fn
[0] == '/' || fn
[0] == '\\') ||
517 (fn
[0] == '.' && (fn
[1] == '/' || fn
[1] == '\\'))) {
518 t
->file
= buffer_init_string(fn
);
520 t
->file
= buffer_init_buffer(basedir
);
521 buffer_append_string(t
->file
, fn
);
524 if (0 != stream_open(&(t
->s
), t
->file
)) {
525 log_error_write(srv
, __FILE__
, __LINE__
, "sbss",
526 "opening configfile ", t
->file
, "failed:", strerror(errno
));
527 buffer_free(t
->file
);
531 t
->input
= t
->s
.start
;
543 static int tokenizer_close(server
*srv
, tokenizer_t
*t
) {
546 buffer_free(t
->file
);
547 return stream_close(&(t
->s
));
550 static int config_skip_newline(tokenizer_t
*t
) {
552 force_assert(t
->input
[t
->offset
] == '\r' || t
->input
[t
->offset
] == '\n');
553 if (t
->input
[t
->offset
] == '\r' && t
->input
[t
->offset
+ 1] == '\n') {
561 static int config_skip_comment(tokenizer_t
*t
) {
563 force_assert(t
->input
[t
->offset
] == '#');
564 for (i
= 1; t
->input
[t
->offset
+ i
] &&
565 (t
->input
[t
->offset
+ i
] != '\n' && t
->input
[t
->offset
+ i
] != '\r');
571 static int config_tokenizer(server
*srv
, tokenizer_t
*t
, int *token_id
, buffer
*token
) {
575 for (tid
= 0; tid
== 0 && t
->offset
< t
->size
&& t
->input
[t
->offset
] ; ) {
576 char c
= t
->input
[t
->offset
];
577 const char *start
= NULL
;
582 if (t
->input
[t
->offset
+ 1] == '>') {
585 buffer_copy_string_len(token
, CONST_STR_LEN("=>"));
587 tid
= TK_ARRAY_ASSIGN
;
589 log_error_write(srv
, __FILE__
, __LINE__
, "sbsdsds",
590 "source:", t
->source
,
591 "line:", t
->line
, "pos:", t
->line_pos
,
592 "use => for assignments in arrays");
595 } else if (t
->in_cond
) {
596 if (t
->input
[t
->offset
+ 1] == '=') {
599 buffer_copy_string_len(token
, CONST_STR_LEN("=="));
602 } else if (t
->input
[t
->offset
+ 1] == '~') {
605 buffer_copy_string_len(token
, CONST_STR_LEN("=~"));
609 log_error_write(srv
, __FILE__
, __LINE__
, "sbsdsds",
610 "source:", t
->source
,
611 "line:", t
->line
, "pos:", t
->line_pos
,
612 "only =~ and == are allowed in the condition");
617 } else if (t
->in_key
) {
620 buffer_copy_string_len(token
, t
->input
+ t
->offset
, 1);
625 log_error_write(srv
, __FILE__
, __LINE__
, "sbsdsds",
626 "source:", t
->source
,
627 "line:", t
->line
, "pos:", t
->line_pos
,
628 "unexpected equal-sign: =");
635 if (t
->input
[t
->offset
+ 1] == '=') {
638 buffer_copy_string_len(token
, CONST_STR_LEN("!="));
641 } else if (t
->input
[t
->offset
+ 1] == '~') {
644 buffer_copy_string_len(token
, CONST_STR_LEN("!~"));
648 log_error_write(srv
, __FILE__
, __LINE__
, "sbsdsds",
649 "source:", t
->source
,
650 "line:", t
->line
, "pos:", t
->line_pos
,
651 "only !~ and != are allowed in the condition");
657 log_error_write(srv
, __FILE__
, __LINE__
, "sbsdsds",
658 "source:", t
->source
,
659 "line:", t
->line
, "pos:", t
->line_pos
,
660 "unexpected exclamation-marks: !");
672 if (t
->in_brace
== 0) {
674 while (!done
&& t
->offset
< t
->size
) {
675 switch (t
->input
[t
->offset
]) {
678 config_skip_newline(t
);
684 t
->line_pos
+= config_skip_comment(t
);
699 buffer_copy_string_len(token
, CONST_STR_LEN("(EOL)"));
701 config_skip_newline(t
);
707 if (t
->in_brace
> 0) {
710 buffer_copy_string_len(token
, CONST_STR_LEN("(COMMA)"));
717 /* search for the terminating " */
718 start
= t
->input
+ t
->offset
+ 1;
719 buffer_copy_string_len(token
, CONST_STR_LEN(""));
721 for (i
= 1; t
->input
[t
->offset
+ i
]; i
++) {
722 if (t
->input
[t
->offset
+ i
] == '\\' &&
723 t
->input
[t
->offset
+ i
+ 1] == '"') {
725 buffer_append_string_len(token
, start
, t
->input
+ t
->offset
+ i
- start
);
727 start
= t
->input
+ t
->offset
+ i
+ 1;
735 if (t
->input
[t
->offset
+ i
] == '"') {
738 buffer_append_string_len(token
, start
, t
->input
+ t
->offset
+ i
- start
);
744 if (t
->input
[t
->offset
+ i
] == '\0') {
747 log_error_write(srv
, __FILE__
, __LINE__
, "sbsdsds",
748 "source:", t
->source
,
749 "line:", t
->line
, "pos:", t
->line_pos
,
750 "missing closing quote");
756 t
->line_pos
+= i
+ 1;
765 buffer_copy_string_len(token
, CONST_STR_LEN("("));
773 buffer_copy_string_len(token
, CONST_STR_LEN(")"));
782 buffer_copy_string_len(token
, CONST_STR_LEN("$"));
787 if (t
->input
[t
->offset
+ 1] == '=') {
789 buffer_copy_string_len(token
, CONST_STR_LEN("+="));
794 buffer_copy_string_len(token
, CONST_STR_LEN("+"));
803 buffer_copy_string_len(token
, CONST_STR_LEN("{"));
812 buffer_copy_string_len(token
, CONST_STR_LEN("}"));
821 buffer_copy_string_len(token
, CONST_STR_LEN("["));
830 buffer_copy_string_len(token
, CONST_STR_LEN("]"));
834 t
->line_pos
+= config_skip_comment(t
);
839 for (i
= 0; t
->input
[t
->offset
+ i
] &&
840 (isalpha((unsigned char)t
->input
[t
->offset
+ i
])
843 if (i
&& t
->input
[t
->offset
+ i
]) {
845 buffer_copy_string_len(token
, t
->input
+ t
->offset
, i
);
851 log_error_write(srv
, __FILE__
, __LINE__
, "sbsdsds",
852 "source:", t
->source
,
853 "line:", t
->line
, "pos:", t
->line_pos
,
854 "invalid character in condition");
857 } else if (isdigit((unsigned char)c
)) {
858 /* take all digits */
859 for (i
= 0; t
->input
[t
->offset
+ i
] && isdigit((unsigned char)t
->input
[t
->offset
+ i
]); i
++);
861 /* was there it least a digit ? */
865 buffer_copy_string_len(token
, t
->input
+ t
->offset
, i
);
871 /* the key might consist of [-.0-9a-z] */
872 for (i
= 0; t
->input
[t
->offset
+ i
] &&
873 (isalnum((unsigned char)t
->input
[t
->offset
+ i
]) ||
874 t
->input
[t
->offset
+ i
] == '.' ||
875 t
->input
[t
->offset
+ i
] == '_' || /* for env.* */
876 t
->input
[t
->offset
+ i
] == '-'
879 if (i
&& t
->input
[t
->offset
+ i
]) {
880 buffer_copy_string_len(token
, t
->input
+ t
->offset
, i
);
882 if (strcmp(token
->ptr
, "include") == 0) {
884 } else if (strcmp(token
->ptr
, "include_shell") == 0) {
885 tid
= TK_INCLUDE_SHELL
;
886 } else if (strcmp(token
->ptr
, "global") == 0) {
888 } else if (strcmp(token
->ptr
, "else") == 0) {
898 log_error_write(srv
, __FILE__
, __LINE__
, "sbsdsds",
899 "source:", t
->source
,
900 "line:", t
->line
, "pos:", t
->line_pos
,
901 "invalid character in variable name");
912 log_error_write(srv
, __FILE__
, __LINE__
, "sbsdsdbdd",
913 "source:", t
->source
,
914 "line:", t
->line
, "pos:", t
->line_pos
,
915 token
, token
->used
- 1, tid
);
919 } else if (t
->offset
< t
->size
) {
920 fprintf(stderr
, "%s.%d: %d, %s\n",
927 static int config_parse(server
*srv
, config_t
*context
, tokenizer_t
*t
) {
930 buffer
*token
, *lasttoken
;
933 pParser
= configparserAlloc( malloc
);
934 lasttoken
= buffer_init();
935 token
= buffer_init();
936 while((1 == (ret
= config_tokenizer(srv
, t
, &token_id
, token
))) && context
->ok
) {
937 buffer_copy_buffer(lasttoken
, token
);
938 configparser(pParser
, token_id
, token
, context
);
940 token
= buffer_init();
944 if (ret
!= -1 && context
->ok
) {
945 /* add an EOL at EOF, better than say sorry */
946 configparser(pParser
, TK_EOL
, buffer_init_string("(EOL)"), context
);
948 configparser(pParser
, 0, NULL
, context
);
951 configparserFree(pParser
, free
);
954 log_error_write(srv
, __FILE__
, __LINE__
, "sb",
955 "configfile parser failed at:", lasttoken
);
956 } else if (context
->ok
== 0) {
957 log_error_write(srv
, __FILE__
, __LINE__
, "sbsdsdsb",
958 "source:", t
->source
,
959 "line:", t
->line
, "pos:", t
->line_pos
,
960 "parser failed somehow near here:", lasttoken
);
963 buffer_free(lasttoken
);
965 return ret
== -1 ? -1 : 0;
968 static int tokenizer_init(tokenizer_t
*t
, const buffer
*source
, const char *input
, size_t size
) {
983 int config_parse_file(server
*srv
, config_t
*context
, const char *fn
) {
989 if (buffer_string_is_empty(context
->basedir
) ||
990 (fn
[0] == '/' || fn
[0] == '\\') ||
991 (fn
[0] == '.' && (fn
[1] == '/' || fn
[1] == '\\'))) {
992 filename
= buffer_init_string(fn
);
994 filename
= buffer_init_buffer(context
->basedir
);
995 buffer_append_string(filename
, fn
);
998 if (0 != stream_open(&s
, filename
)) {
1000 /* the file was empty, nothing to parse */
1003 log_error_write(srv
, __FILE__
, __LINE__
, "sbss",
1004 "opening configfile ", filename
, "failed:", strerror(errno
));
1008 tokenizer_init(&t
, filename
, s
.start
, s
.size
);
1009 ret
= config_parse(srv
, context
, &t
);
1013 buffer_free(filename
);
1017 static char* getCWD(void) {
1027 if (!s
) return NULL
;
1028 while (NULL
== getcwd(s
, len
)) {
1029 if (errno
!= ERANGE
|| SSIZE_MAX
- len
< len
) {
1034 s1
= realloc(s
, len
);
1044 int config_parse_cmd(server
*srv
, config_t
*context
, const char *cmd
) {
1051 if (NULL
== (oldpwd
= getCWD())) {
1052 log_error_write(srv
, __FILE__
, __LINE__
, "s",
1053 "cannot get cwd", strerror(errno
));
1057 source
= buffer_init_string(cmd
);
1058 out
= buffer_init();
1060 if (!buffer_string_is_empty(context
->basedir
)) {
1061 chdir(context
->basedir
->ptr
);
1064 if (0 != proc_open_buffer(cmd
, NULL
, out
, NULL
)) {
1065 log_error_write(srv
, __FILE__
, __LINE__
, "sbss",
1066 "opening", source
, "failed:", strerror(errno
));
1069 tokenizer_init(&t
, source
, CONST_BUF_LEN(out
));
1070 ret
= config_parse(srv
, context
, &t
);
1073 buffer_free(source
);
1080 static void context_init(server
*srv
, config_t
*context
) {
1083 context
->configs_stack
= array_init();
1084 context
->configs_stack
->is_weakref
= 1;
1085 context
->basedir
= buffer_init();
1088 static void context_free(config_t
*context
) {
1089 array_free(context
->configs_stack
);
1090 buffer_free(context
->basedir
);
1093 int config_read(server
*srv
, const char *fn
) {
1100 data_array
*modules
;
1102 context_init(srv
, &context
);
1103 context
.all_configs
= srv
->config_context
;
1106 pos
= strrchr(fn
, '\\');
1108 pos
= strrchr(fn
, '/');
1111 buffer_copy_string_len(context
.basedir
, fn
, pos
- fn
+ 1);
1115 dc
= data_config_init();
1116 buffer_copy_string_len(dc
->key
, CONST_STR_LEN("global"));
1118 force_assert(context
.all_configs
->used
== 0);
1119 dc
->context_ndx
= context
.all_configs
->used
;
1120 array_insert_unique(context
.all_configs
, (data_unset
*)dc
);
1121 context
.current
= dc
;
1123 /* default context */
1124 srv
->config
= dc
->value
;
1125 dpid
= data_integer_init();
1126 dpid
->value
= getpid();
1127 buffer_copy_string_len(dpid
->key
, CONST_STR_LEN("var.PID"));
1128 array_insert_unique(srv
->config
, (data_unset
*)dpid
);
1130 dcwd
= data_string_init();
1131 buffer_string_prepare_copy(dcwd
->value
, 1023);
1132 if (NULL
!= getcwd(dcwd
->value
->ptr
, dcwd
->value
->size
- 1)) {
1133 buffer_commit(dcwd
->value
, strlen(dcwd
->value
->ptr
));
1134 buffer_copy_string_len(dcwd
->key
, CONST_STR_LEN("var.CWD"));
1135 array_insert_unique(srv
->config
, (data_unset
*)dcwd
);
1137 dcwd
->free((data_unset
*) dcwd
);
1140 ret
= config_parse_file(srv
, &context
, fn
);
1142 /* remains nothing if parser is ok */
1143 force_assert(!(0 == ret
&& context
.ok
&& 0 != context
.configs_stack
->used
));
1144 context_free(&context
);
1150 if (NULL
!= (dc
= (data_config
*)array_get_element(srv
->config_context
, "global"))) {
1151 srv
->config
= dc
->value
;
1156 if (NULL
!= (modules
= (data_array
*)array_get_element(srv
->config
, "server.modules"))) {
1158 data_array
*prepends
;
1160 if (modules
->type
!= TYPE_ARRAY
) {
1161 fprintf(stderr
, "server.modules must be an array");
1165 prepends
= data_array_init();
1167 /* prepend default modules */
1168 if (NULL
== array_get_element(modules
->value
, "mod_indexfile")) {
1169 ds
= data_string_init();
1170 buffer_copy_string_len(ds
->value
, CONST_STR_LEN("mod_indexfile"));
1171 array_insert_unique(prepends
->value
, (data_unset
*)ds
);
1174 prepends
= (data_array
*)configparser_merge_data((data_unset
*)prepends
, (data_unset
*)modules
);
1175 force_assert(NULL
!= prepends
);
1176 buffer_copy_buffer(prepends
->key
, modules
->key
);
1177 array_replace(srv
->config
, (data_unset
*)prepends
);
1178 modules
->free((data_unset
*)modules
);
1181 /* append default modules */
1182 if (NULL
== array_get_element(modules
->value
, "mod_dirlisting")) {
1183 ds
= data_string_init();
1184 buffer_copy_string_len(ds
->value
, CONST_STR_LEN("mod_dirlisting"));
1185 array_insert_unique(modules
->value
, (data_unset
*)ds
);
1188 if (NULL
== array_get_element(modules
->value
, "mod_staticfile")) {
1189 ds
= data_string_init();
1190 buffer_copy_string_len(ds
->value
, CONST_STR_LEN("mod_staticfile"));
1191 array_insert_unique(modules
->value
, (data_unset
*)ds
);
1196 modules
= data_array_init();
1198 /* server.modules is not set */
1199 ds
= data_string_init();
1200 buffer_copy_string_len(ds
->value
, CONST_STR_LEN("mod_indexfile"));
1201 array_insert_unique(modules
->value
, (data_unset
*)ds
);
1203 ds
= data_string_init();
1204 buffer_copy_string_len(ds
->value
, CONST_STR_LEN("mod_dirlisting"));
1205 array_insert_unique(modules
->value
, (data_unset
*)ds
);
1207 ds
= data_string_init();
1208 buffer_copy_string_len(ds
->value
, CONST_STR_LEN("mod_staticfile"));
1209 array_insert_unique(modules
->value
, (data_unset
*)ds
);
1211 buffer_copy_string_len(modules
->key
, CONST_STR_LEN("server.modules"));
1212 array_insert_unique(srv
->config
, (data_unset
*)modules
);
1216 if (0 != config_insert(srv
)) {
1223 int config_set_defaults(server
*srv
) {
1225 specific_config
*s
= srv
->config_storage
[0];
1226 struct stat st1
, st2
;
1228 struct ev_map
{ fdevent_handler_t et
; const char *name
; } event_handlers
[] =
1230 /* - epoll is most reliable
1231 * - select works everywhere
1233 #ifdef USE_LINUX_EPOLL
1234 { FDEVENT_HANDLER_LINUX_SYSEPOLL
, "linux-sysepoll" },
1237 { FDEVENT_HANDLER_POLL
, "poll" },
1240 { FDEVENT_HANDLER_SELECT
, "select" },
1243 { FDEVENT_HANDLER_LIBEV
, "libev" },
1245 #ifdef USE_SOLARIS_DEVPOLL
1246 { FDEVENT_HANDLER_SOLARIS_DEVPOLL
,"solaris-devpoll" },
1248 #ifdef USE_SOLARIS_PORT
1249 { FDEVENT_HANDLER_SOLARIS_PORT
, "solaris-eventports" },
1251 #ifdef USE_FREEBSD_KQUEUE
1252 { FDEVENT_HANDLER_FREEBSD_KQUEUE
, "freebsd-kqueue" },
1253 { FDEVENT_HANDLER_FREEBSD_KQUEUE
, "kqueue" },
1255 { FDEVENT_HANDLER_UNSET
, NULL
}
1258 if (!buffer_string_is_empty(srv
->srvconf
.changeroot
)) {
1259 if (-1 == stat(srv
->srvconf
.changeroot
->ptr
, &st1
)) {
1260 log_error_write(srv
, __FILE__
, __LINE__
, "sb",
1261 "server.chroot doesn't exist:", srv
->srvconf
.changeroot
);
1264 if (!S_ISDIR(st1
.st_mode
)) {
1265 log_error_write(srv
, __FILE__
, __LINE__
, "sb",
1266 "server.chroot isn't a directory:", srv
->srvconf
.changeroot
);
1271 if (buffer_string_is_empty(s
->document_root
)) {
1272 log_error_write(srv
, __FILE__
, __LINE__
, "s",
1273 "a default document-root has to be set");
1278 buffer_copy_buffer(srv
->tmp_buf
, s
->document_root
);
1280 buffer_to_lower(srv
->tmp_buf
);
1282 if (2 == s
->force_lowercase_filenames
) { /* user didn't configure it in global section? */
1283 s
->force_lowercase_filenames
= 0; /* default to 0 */
1285 if (0 == stat(srv
->tmp_buf
->ptr
, &st1
)) {
1288 is_lower
= buffer_is_equal(srv
->tmp_buf
, s
->document_root
);
1290 /* lower-case existed, check upper-case */
1291 buffer_copy_buffer(srv
->tmp_buf
, s
->document_root
);
1293 buffer_to_upper(srv
->tmp_buf
);
1295 /* we have to handle the special case that upper and lower-casing results in the same filename
1296 * as in server.document-root = "/" or "/12345/" */
1298 if (is_lower
&& buffer_is_equal(srv
->tmp_buf
, s
->document_root
)) {
1299 /* lower-casing and upper-casing didn't result in
1300 * an other filename, no need to stat(),
1301 * just assume it is case-sensitive. */
1303 s
->force_lowercase_filenames
= 0;
1304 } else if (0 == stat(srv
->tmp_buf
->ptr
, &st2
)) {
1306 /* upper case exists too, doesn't the FS handle this ? */
1308 /* upper and lower have the same inode -> case-insensitve FS */
1310 if (st1
.st_ino
== st2
.st_ino
) {
1311 /* upper and lower have the same inode -> case-insensitve FS */
1313 s
->force_lowercase_filenames
= 1;
1319 if (srv
->srvconf
.port
== 0) {
1320 srv
->srvconf
.port
= s
->ssl_enabled
? 443 : 80;
1323 if (buffer_string_is_empty(srv
->srvconf
.event_handler
)) {
1324 /* choose a good default
1326 * the event_handler list is sorted by 'goodness'
1327 * taking the first available should be the best solution
1329 srv
->event_handler
= event_handlers
[0].et
;
1331 if (FDEVENT_HANDLER_UNSET
== srv
->event_handler
) {
1332 log_error_write(srv
, __FILE__
, __LINE__
, "s",
1333 "sorry, there is no event handler for this system");
1342 for (i
= 0; event_handlers
[i
].name
; i
++) {
1343 if (0 == strcmp(event_handlers
[i
].name
, srv
->srvconf
.event_handler
->ptr
)) {
1344 srv
->event_handler
= event_handlers
[i
].et
;
1349 if (FDEVENT_HANDLER_UNSET
== srv
->event_handler
) {
1350 log_error_write(srv
, __FILE__
, __LINE__
, "sb",
1351 "the selected event-handler in unknown or not supported:",
1352 srv
->srvconf
.event_handler
);
1358 if (s
->ssl_enabled
) {
1359 if (buffer_string_is_empty(s
->ssl_pemfile
)) {
1360 /* PEM file is require */
1362 log_error_write(srv
, __FILE__
, __LINE__
, "s",
1363 "ssl.pemfile has to be set");
1368 log_error_write(srv
, __FILE__
, __LINE__
, "s",
1369 "ssl support is missing, recompile with --with-openssl");