summaryrefslogtreecommitdiff
path: root/cfws.c
diff options
context:
space:
mode:
authorcflip <cflip@cflip.net>2023-07-14 19:16:02 -0600
committercflip <cflip@cflip.net>2023-07-14 19:16:02 -0600
commit555f21649b909fd37a6153843249d72ca80ac427 (patch)
tree32b0a646b81d89278bf3769be0a971fb7729ac78 /cfws.c
parent8ddca3948791d484614f1b2a753f04c478072050 (diff)
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.
Diffstat (limited to 'cfws.c')
-rw-r--r--cfws.c7
1 files changed, 6 insertions, 1 deletions
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)