diff --git a/NEWS b/NEWS index 5db90368..2736cbc8 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/src/configfile.c b/src/configfile.c index 758b5da0..21fc3a4b 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -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);