diff --git a/src/response.c b/src/response.c index 03030d69..f0399c64 100644 --- a/src/response.c +++ b/src/response.c @@ -414,24 +414,6 @@ handler_t http_response_prepare(server *srv, connection *con) { } - - /* can we read the file ? */ - if (!(sce->st.st_mode & S_IROTH) && - !(srv->gid == sce->st.st_gid && - sce->st.st_mode & S_IRGRP) && - !(srv->uid == sce->st.st_uid && - sce->st.st_mode & S_IRUSR)) { - - con->http_status = 403; - - if (con->conf.log_request_handling) { - log_error_write(srv, __FILE__, __LINE__, "s", "-- access denied"); - log_error_write(srv, __FILE__, __LINE__, "sb", "Path :", con->physical.path); - } - - buffer_reset(con->physical.path); - return HANDLER_FINISHED; - } } else { switch (errno) { case EACCES: diff --git a/src/stat_cache.c b/src/stat_cache.c index b428aad0..33645a0f 100644 --- a/src/stat_cache.c +++ b/src/stat_cache.c @@ -420,10 +420,20 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_ /* stat() failed, ENOENT, ... and so on */ return HANDLER_ERROR; } + if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode)) { size_t k; - + + if (S_ISREG(st.st_mode)) { + int fd; + /* see if we can open the file for reading */ + if (-1 == (fd = open(name->ptr, O_RDONLY))) { + return HANDLER_ERROR; + } + close(fd); + } + if (NULL == sce) { int osize = 0;