httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul J. Reder" <rede...@raleigh.ibm.com>
Subject [Patch]: Make cgis work properly under unix.
Date Mon, 06 Dec 1999 17:55:01 GMT
The following is a patch to make cgi scripts work correctly under
unix. Unix proc was not passing the program as the first arg. I
am confident in the APR_PROGRAM side of the code since I have 
tested and verified that it now works, but the APR_SHELLCMD side
seems to have an additional problem which I have not found yet. 
The APR_SHELLCMD part of the patch is required in order to
prevent an internal server error though.

-- 
Paul J. Reder
------------------------------------------------------------
"Remember, Information is not knowledge; Knowledge is not Wisdom;
Wisdom is not truth; Truth is not beauty; Beauty is not love;
Love is not music; Music is the best." -- Frank Zappa




Index: proc.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/threadproc/unix/proc.c,v
retrieving revision 1.13
diff -u -r1.13 proc.c
--- proc.c      1999/12/03 15:18:37     1.13
+++ proc.c      1999/12/06 17:46:38
@@ -337,7 +337,7 @@
     if (((*new)->pid = fork()) < 0) {
         return errno;
     }
-    else if ((*new)->pid == 0) {
+    else if ((*new)->pid == 0) {
         /* child process */
         if (attr->child_in) {
             ap_close(attr->parent_in);
@@ -371,12 +371,13 @@
                 i++;
             }
             newargs =
-               (my_stupid_string *) ap_palloc(cont, sizeof (char *) * (i + 3));
+               (my_stupid_string *) ap_palloc(cont, sizeof (char *) * (i + 4));
             newargs[0] = SHELL_PATH;
             newargs[1] = "-c";
+            newargs[2] = progname;
             i = 0;
             while (args[i]) {
-                newargs[i + 2] = args[i];
+                newargs[i + 3] = args[i];
                 i++;
             }
             newargs[i + 3] = NULL;
@@ -389,7 +390,20 @@
             if (attr->detached) {
                 ap_detach(&pgrp, attr->cntxt);
             }
-            execve(progname, args, env);
+            i = 0;
+            while (args[i]) {
+                i++;
+            }
+            newargs =
+               (my_stupid_string *) ap_palloc(cont, sizeof (char *) * (i + 2));
+            newargs[0] = progname;
+            i = 0;
+            while (args[i]) {
+                newargs[i + 1] = args[i];
+                i++;
+            }
+            newargs[i + 1] = NULL;
+            execve(progname, (char **) newargs, env);
         }
         exit(-1);  /* if we get here, there is a problem, so exit with an */
                    /* error code. */

Mime
View raw message