From 555f21649b909fd37a6153843249d72ca80ac427 Mon Sep 17 00:00:00 2001 From: cflip Date: Fri, 14 Jul 2023 19:16:02 -0600 Subject: Run executable files as CGI scripts Now if the server encounters an executable file that doesn't have a .php extension, it will run it as a CGI script. There should maybe be better heuristics for determining whether a file actually is a CGI script (sometimes files copied from Windows can be marked as executable) but this works for now. --- cfws.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cfws.c') diff --git a/cfws.c b/cfws.c index 930264a..04ec3c3 100644 --- a/cfws.c +++ b/cfws.c @@ -126,7 +126,12 @@ static void handle_request(const struct http_request *req, int sockfd) case SERVE_METHOD_PHP: if (flag_verbose) printf(" -> PHP %s\n", filepath); - file_read_php(filepath, req, sockfd); + file_read_cgi(filepath, "/usr/bin/php-cgi", req, sockfd); + break; + case SERVE_METHOD_CGI: + if (flag_verbose) + printf(" -> CGI %s\n", filepath); + file_read_cgi(filepath, filepath, req, sockfd); break; case SERVE_METHOD_ERROR: { if (flag_verbose) -- cgit v1.2.3