[core] fixed the loading for default modules if they are specified explicitly

backported 1836 from trunk

From: Jan Kneschke <jan@kneschke.de>

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3129 152afb58-edef-0310-8abb-c4023f1b3aa9
This commit is contained in:
Jan Kneschke 2016-03-26 13:07:48 +00:00 committed by Stefan Bühler
parent 06d3c75440
commit 9ae7813685
2 changed files with 30 additions and 3 deletions

1
NEWS
View File

@ -53,6 +53,7 @@ NEWS
* [mod_proxy] accept LF delimited headers, not just CRLF (fixes #2594)
* [core] wait for grandchild to be ready when daemonizing (fixes #2712, thx pasdVn)
* [core] respond 411 Length Required if request has Transfer-Encoding: chunked (fixes #631)
* [core] fixed the loading for default modules if they are specified explicitly
- 1.4.39 - 2016-01-02
* [core] fix memset_s call (fixes #2698)

View File

@ -1177,6 +1177,10 @@ int config_read(server *srv, const char *fn) {
if (NULL != (modules = (data_array *)array_get_element(srv->config, "server.modules"))) {
data_string *ds;
data_array *prepends;
int prepend_mod_indexfile = 1;
int append_mod_dirlisting = 1;
int append_mod_staticfile = 1;
size_t i;
if (modules->type != TYPE_ARRAY) {
fprintf(stderr, "server.modules must be an array");
@ -1186,7 +1190,29 @@ int config_read(server *srv, const char *fn) {
prepends = data_array_init();
/* prepend default modules */
if (NULL == array_get_element(modules->value, "mod_indexfile")) {
for (i = 0; i < modules->value->used; i++) {
ds = (data_string *)modules->value->data[i];
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_indexfile"))) {
prepend_mod_indexfile = 0;
}
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_staticfile"))) {
append_mod_staticfile = 0;
}
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_dirlisting"))) {
append_mod_dirlisting = 0;
}
if (0 == prepend_mod_indexfile &&
0 == append_mod_dirlisting &&
0 == append_mod_staticfile) {
break;
}
}
if (prepend_mod_indexfile) {
ds = data_string_init();
buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_indexfile"));
array_insert_unique(prepends->value, (data_unset *)ds);
@ -1199,13 +1225,13 @@ int config_read(server *srv, const char *fn) {
modules = prepends;
/* append default modules */
if (NULL == array_get_element(modules->value, "mod_dirlisting")) {
if (append_mod_dirlisting) {
ds = data_string_init();
buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_dirlisting"));
array_insert_unique(modules->value, (data_unset *)ds);
}
if (NULL == array_get_element(modules->value, "mod_staticfile")) {
if (append_mod_staticfile) {
ds = data_string_init();
buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_staticfile"));
array_insert_unique(modules->value, (data_unset *)ds);