httpd: fix bug 601 "I:index.php does not run interpreter on DIR/ url"
function old new delta parse_conf 1462 1485 +23 index_html - 11 +11 handle_incoming_and_exit 2762 2749 -13 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 34/-13) Total: 21 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
db57fc22a6
commit
108b8c5367
@ -231,6 +231,8 @@ static const struct {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char index_html[] ALIGN1 = "index.html";
|
||||||
|
|
||||||
|
|
||||||
struct globals {
|
struct globals {
|
||||||
int verbose; /* must be int (used by getopt32) */
|
int verbose; /* must be int (used by getopt32) */
|
||||||
@ -328,7 +330,7 @@ enum {
|
|||||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
||||||
IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \
|
IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \
|
||||||
bind_addr_or_port = "80"; \
|
bind_addr_or_port = "80"; \
|
||||||
index_page = "index.html"; \
|
index_page = index_html; \
|
||||||
file_size = -1; \
|
file_size = -1; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@ -569,6 +571,8 @@ static void parse_conf(const char *path, int flag)
|
|||||||
ch = (buf[0] & ~0x20); /* toupper if it's a letter */
|
ch = (buf[0] & ~0x20); /* toupper if it's a letter */
|
||||||
|
|
||||||
if (ch == 'I') {
|
if (ch == 'I') {
|
||||||
|
if (index_page != index_html)
|
||||||
|
free((char*)index_page);
|
||||||
index_page = xstrdup(after_colon);
|
index_page = xstrdup(after_colon);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2101,8 +2105,12 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
|
|||||||
}
|
}
|
||||||
send_cgi_and_exit(urlcopy, prequest, length, cookie, content_type);
|
send_cgi_and_exit(urlcopy, prequest, length, cookie, content_type);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (urlp[-1] == '/')
|
||||||
|
strcpy(urlp, index_page);
|
||||||
|
if (stat(tptr, &sb) == 0) {
|
||||||
#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
|
||||||
{
|
|
||||||
char *suffix = strrchr(tptr, '.');
|
char *suffix = strrchr(tptr, '.');
|
||||||
if (suffix) {
|
if (suffix) {
|
||||||
Htaccess *cur;
|
Htaccess *cur;
|
||||||
@ -2112,16 +2120,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (prequest != request_GET && prequest != request_HEAD) {
|
|
||||||
send_headers_and_exit(HTTP_NOT_IMPLEMENTED);
|
|
||||||
}
|
|
||||||
#endif /* FEATURE_HTTPD_CGI */
|
|
||||||
|
|
||||||
if (urlp[-1] == '/')
|
|
||||||
strcpy(urlp, index_page);
|
|
||||||
if (stat(tptr, &sb) == 0) {
|
|
||||||
file_size = sb.st_size;
|
file_size = sb.st_size;
|
||||||
last_mod = sb.st_mtime;
|
last_mod = sb.st_mtime;
|
||||||
}
|
}
|
||||||
@ -2135,19 +2134,18 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
|
|||||||
send_cgi_and_exit("/cgi-bin/index.cgi", prequest, length, cookie, content_type);
|
send_cgi_and_exit("/cgi-bin/index.cgi", prequest, length, cookie, content_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
/* else fall through to send_file, it errors out if open fails: */
|
||||||
/* else {
|
|
||||||
* fall through to send_file, it errors out if open fails
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
if (prequest != request_GET && prequest != request_HEAD) {
|
||||||
|
/* POST for files does not make sense */
|
||||||
|
send_headers_and_exit(HTTP_NOT_IMPLEMENTED);
|
||||||
|
}
|
||||||
send_file_and_exit(tptr,
|
send_file_and_exit(tptr,
|
||||||
#if ENABLE_FEATURE_HTTPD_CGI
|
|
||||||
(prequest != request_HEAD ? SEND_HEADERS_AND_BODY : SEND_HEADERS)
|
(prequest != request_HEAD ? SEND_HEADERS_AND_BODY : SEND_HEADERS)
|
||||||
#else
|
|
||||||
SEND_HEADERS_AND_BODY
|
|
||||||
#endif
|
|
||||||
);
|
);
|
||||||
|
#else
|
||||||
|
send_file_and_exit(tptr, SEND_HEADERS_AND_BODY);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user