diff --git a/src/mod_dirlisting.c b/src/mod_dirlisting.c index 52570f2b..222abf70 100644 --- a/src/mod_dirlisting.c +++ b/src/mod_dirlisting.c @@ -10,6 +10,7 @@ #include "stat_cache.h" +#include #include #include #include @@ -1025,7 +1026,6 @@ static int http_list_directory(request_st * const r, plugin_data * const p, buff URIHANDLER_FUNC(mod_dirlisting_subrequest) { plugin_data *p = p_d; - stat_cache_entry *sce = NULL; if (NULL != r->handler_module) return HANDLER_GO_ON; if (buffer_string_is_empty(&r->uri.path)) return HANDLER_GO_ON; @@ -1044,16 +1044,14 @@ URIHANDLER_FUNC(mod_dirlisting_subrequest) { "URI : %s", r->uri.path.ptr); } - sce = stat_cache_get_entry(&r->physical.path); - if (NULL == sce) { - log_error(r->conf.errh, __FILE__, __LINE__, - "stat_cache_get_entry failed: %s", r->physical.path.ptr); + if (!stat_cache_path_isdir(&r->physical.path)) { + if (errno == ENOTDIR) + return HANDLER_GO_ON; + log_perror(r->conf.errh,__FILE__,__LINE__,"%s",r->physical.path.ptr); r->http_status = 500; return HANDLER_FINISHED; } - if (!S_ISDIR(sce->st.st_mode)) return HANDLER_GO_ON; - if (http_list_directory(r, p, &r->physical.path)) { /* dirlisting failed */ r->http_status = 403; diff --git a/src/mod_evhost.c b/src/mod_evhost.c index b7eb9617..47257bcc 100644 --- a/src/mod_evhost.c +++ b/src/mod_evhost.c @@ -326,7 +326,6 @@ static void mod_evhost_build_doc_root_path(buffer *b, array *parsed_host, buffer static handler_t mod_evhost_uri_handler(request_st * const r, void *p_d) { plugin_data *p = p_d; - stat_cache_entry *sce = NULL; /* not authority set */ if (buffer_string_is_empty(&r->uri.authority)) return HANDLER_GO_ON; @@ -339,11 +338,8 @@ static handler_t mod_evhost_uri_handler(request_st * const r, void *p_d) { buffer * const b = &p->tmp_buf; mod_evhost_build_doc_root_path(b, &p->split_vals, &r->uri.authority, p->conf.path_pieces); - sce = stat_cache_get_entry(b); - if (NULL == sce) { + if (!stat_cache_path_isdir(b)) { log_perror(r->conf.errh, __FILE__, __LINE__, "%s", b->ptr); - } else if(!S_ISDIR(sce->st.st_mode)) { - log_error(r->conf.errh, __FILE__, __LINE__, "not a directory: %s", b->ptr); } else { buffer_copy_buffer(&r->physical.doc_root, b); } diff --git a/src/mod_mysql_vhost.c b/src/mod_mysql_vhost.c index 0afcacee..3f3ecc1e 100644 --- a/src/mod_mysql_vhost.c +++ b/src/mod_mysql_vhost.c @@ -269,7 +269,6 @@ SETDEFAULTS_FUNC(mod_mysql_vhost_set_defaults) { REQUEST_FUNC(mod_mysql_vhost_handle_docroot) { plugin_data *p = p_d; plugin_connection_data *c; - stat_cache_entry *sce; unsigned cols; MYSQL_ROW row; @@ -329,15 +328,10 @@ REQUEST_FUNC(mod_mysql_vhost_handle_docroot) { buffer_copy_string(b, row[0]); buffer_append_slash(b); - sce = stat_cache_get_entry(b); - if (NULL == sce) { + if (!stat_cache_path_isdir(b)) { log_perror(r->conf.errh, __FILE__, __LINE__, "%s", b->ptr); goto ERR500; } - if (!S_ISDIR(sce->st.st_mode)) { - log_error(r->conf.errh, __FILE__, __LINE__, "Not a directory %s", b->ptr); - goto ERR500; - } /* cache the data */ buffer_copy_buffer(c->server_name, &r->uri.authority); diff --git a/src/mod_simple_vhost.c b/src/mod_simple_vhost.c index 6e77eb26..f2321d76 100644 --- a/src/mod_simple_vhost.c +++ b/src/mod_simple_vhost.c @@ -152,21 +152,17 @@ static void build_doc_root_path(buffer *out, const buffer *sroot, const buffer * } static int build_doc_root(request_st * const r, plugin_data *p, buffer *out, const buffer *host) { - stat_cache_entry *sce = NULL; build_doc_root_path(out, p->conf.server_root, host, p->conf.document_root); /* one-element cache (positive cache, not negative cache) */ if (buffer_is_equal(out, &p->last_root)) return 1; - sce = stat_cache_get_entry(out); - if (NULL == sce) { + if (!stat_cache_path_isdir(out)) { if (p->conf.debug) { log_perror(r->conf.errh, __FILE__, __LINE__, "%s", out->ptr); } return 0; - } else if (!S_ISDIR(sce->st.st_mode)) { - return 0; } buffer_copy_buffer(&p->last_root, out); diff --git a/src/mod_vhostdb.c b/src/mod_vhostdb.c index 9bea5b89..e6c7e275 100644 --- a/src/mod_vhostdb.c +++ b/src/mod_vhostdb.c @@ -273,7 +273,6 @@ REQUEST_FUNC(mod_vhostdb_handle_docroot) { vhostdb_cache_entry *ve; const http_vhostdb_backend_t *backend; buffer *b; - stat_cache_entry *sce; /* no host specified? */ if (buffer_string_is_empty(&r->uri.authority)) return HANDLER_GO_ON; @@ -303,16 +302,10 @@ REQUEST_FUNC(mod_vhostdb_handle_docroot) { /* sanity check that really is a directory */ buffer_append_slash(b); - sce = stat_cache_get_entry(b); - if (NULL == sce) { + if (!stat_cache_path_isdir(b)) { log_perror(r->conf.errh, __FILE__, __LINE__, "%s", b->ptr); return mod_vhostdb_error_500(r); /* HANDLER_FINISHED */ } - if (!S_ISDIR(sce->st.st_mode)) { - log_error(r->conf.errh, __FILE__, __LINE__, - "Not a directory: %s", b->ptr); - return mod_vhostdb_error_500(r); /* HANDLER_FINISHED */ - } if (ve && !p->conf.vhostdb_cache) vhostdb_cache_entry_free(ve); diff --git a/src/t/test_mod_evhost.c b/src/t/test_mod_evhost.c index dbbbae77..ecb1aa6d 100644 --- a/src/t/test_mod_evhost.c +++ b/src/t/test_mod_evhost.c @@ -75,9 +75,9 @@ int main (void) { * stub functions */ -stat_cache_entry * stat_cache_get_entry(const buffer *name) { +int stat_cache_path_isdir(const buffer *name) { UNUSED(name); - return NULL; + return 1; } int config_plugin_values_init(server *srv, void *p_d, const config_plugin_keys_t *cpk, const char *mname) { diff --git a/src/t/test_mod_simple_vhost.c b/src/t/test_mod_simple_vhost.c index ef60f027..e01784a6 100644 --- a/src/t/test_mod_simple_vhost.c +++ b/src/t/test_mod_simple_vhost.c @@ -43,9 +43,9 @@ int main (void) { * stub functions */ -stat_cache_entry * stat_cache_get_entry(const buffer *name) { +int stat_cache_path_isdir(const buffer *name) { UNUSED(name); - return NULL; + return 1; } int config_plugin_values_init(server *srv, void *p_d, const config_plugin_keys_t *cpk, const char *mname) {