src/server/safs/cgi.c

changeset 450
d7b276de183b
parent 433
39fe86ae4db0
child 451
edbbb3000494
--- a/src/server/safs/cgi.c	Sat Dec 03 18:00:35 2022 +0100
+++ b/src/server/safs/cgi.c	Sun Dec 04 09:09:55 2022 +0100
@@ -41,6 +41,7 @@
 #include "../util/util.h"
 #include "../util/pblock.h"
 #include "../daemon/netsite.h"
+#include "../daemon/vfs.h"
 #include "../util/io.h"
 #include "../daemon/event.h"
 
@@ -66,6 +67,12 @@
         }
     }
     
+    // using stat, not vfs_stat, because running scripts/executables works only
+    // with the sys fs
+    if(!vfs_is_sys(rq->vfs)) {
+        log_ereport(LOG_WARN, "send-cgi: VFS setting ignored");
+    }
+    
     struct stat s;
     if(stat(path, &s)) {
         int statuscode = util_errno2status(errno);
@@ -115,7 +122,6 @@
         while(n < content_length) {
             r = netbuf_getbytes(sn->inbuf, buf, 4096);
             if(r <= 0) {
-                // TODO: handle error
                 log_ereport(
                         LOG_FAILURE,
                         "send-cgi: script: %s: cannot read request body",
@@ -126,7 +132,6 @@
             }
             ssize_t w = write(handler->process.in[1], buf, r);
             if(w <= 0) {
-                // TODO: handle error
                 log_ereport(
                         LOG_FAILURE,
                         "send-cgi: script: %s: cannot send request body to cgi process",
@@ -196,6 +201,7 @@
         log_ereport(LOG_FAILURE, "cgi-send: kill script: %s", path);
         kill(handler->process.pid, SIGKILL);
         cgi_parser_free(handler->parser);
+        cgi_close(&handler->process);
         return REQ_ABORTED;
     }
     

mercurial