]> granicus.if.org Git - apache/commitdiff
Respect the process_cgi argument
authorWilliam A. Rowe Jr <wrowe@apache.org>
Sat, 13 Apr 2002 22:34:16 +0000 (22:34 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Sat, 13 Apr 2002 22:34:16 +0000 (22:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94639 13f79535-47bb-0310-9956-ffa450edef68

modules/arch/win32/mod_win32.c

index b35fc262cd7d5ecff0a9506a7e1328e00a2e20fa..184356376998e2083bb249d21efd5e1ef95e094e 100644 (file)
@@ -413,25 +413,31 @@ static apr_array_header_t *split_argv(apr_pool_t *p, const char *interp,
 
 static apr_status_t ap_cgi_build_command(const char **cmd, const char ***argv,
                                          request_rec *r, apr_pool_t *p, 
-                                         int replace_cmd, apr_cmdtype_e *type)
+                                         int process_cgi, apr_cmdtype_e *type)
 {
     const char *ext = NULL;
     const char *interpreter = NULL;
     win32_dir_conf *d;
     apr_file_t *fh;
-    const char *args = r->args;
+    const char *args = "";
 
     d = (win32_dir_conf *)ap_get_module_config(r->per_dir_config, 
                                                &win32_module);
 
-    /* Handle the complete file name, we DON'T want to follow suexec, since
-     * an unrooted command is as predictable as shooting craps in Win32.
-     *
-     * Notice that unlike most mime extension parsing, we have to use the
-     * win32 parsing here, therefore the final extension is the only one
-     * we will consider
-     */
-    ext = strrchr(apr_filename_of_pathname(r->filename), '.');
+    if (process_cgi) {
+        /* Handle the complete file name, we DON'T want to follow suexec, since
+         * an unrooted command is as predictable as shooting craps in Win32.
+         *
+         * Notice that unlike most mime extension parsing, we have to use the
+         * win32 parsing here, therefore the final extension is the only one
+         * we will consider
+         */
+        *cmd = r->filename;
+        if (r->args && r->args[0] && !ap_strchr_c(r->args, '=')) {
+            args = r->args;
+        }
+    }
+    ext = strrchr(apr_filename_of_pathname(*cmd), '.');
     
     /* If the file has an extension and it is not .com and not .exe and
      * we've been instructed to search the registry, then do so.
@@ -451,7 +457,7 @@ static apr_status_t ap_cgi_build_command(const char **cmd, const char ***argv,
                       == INTERPRETER_SOURCE_REGISTRY_STRICT);
         interpreter = get_interpreter_from_win32_registry(r->pool, ext,
                                                           strict);
-        if (interpreter) {
+        if (interpreter && *type != APR_SHELLCMD) {
             *type = APR_PROGRAM_PATH;
         }
         else {
@@ -470,12 +476,11 @@ static apr_status_t ap_cgi_build_command(const char **cmd, const char ***argv,
         /* Need to peek into the file figure out what it really is... 
          * ### aught to go back and build a cache for this one of these days.
          */
-        if (((rv = apr_file_open(&fh, r->filename, APR_READ | APR_BUFFERED,
+        if (((rv = apr_file_open(&fh, *cmd, APR_READ | APR_BUFFERED,
                                  APR_OS_DEFAULT, r->pool)) != APR_SUCCESS) 
             || ((rv = apr_file_read(fh, buffer, &bytes)) != APR_SUCCESS)) {
             ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
-                          "Failed to read cgi file %s for testing",
-                          r->filename);
+                          "Failed to read cgi file %s for testing", *cmd);
             return rv;
         }
         apr_file_close(fh);
@@ -494,7 +499,9 @@ static apr_status_t ap_cgi_build_command(const char **cmd, const char ***argv,
                 while (isspace(*interpreter)) {
                     ++interpreter;
                 }
-                *type = APR_PROGRAM_PATH;
+                if (*type != APR_SHELLCMD) {
+                    *type = APR_PROGRAM_PATH;
+                }
             }
         }
         else {
@@ -515,16 +522,11 @@ static apr_status_t ap_cgi_build_command(const char **cmd, const char ***argv,
     if (!interpreter) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
                       "%s is not executable; ensure interpreted scripts have "
-                      "\"#!\" first line", 
-                      r->filename);
+                      "\"#!\" first line", *cmd);
         return APR_EBADF;
     }
 
-    if (!args || ap_strchr_c(args, '=')) {
-        args = "";
-    }
-
-    *argv = (const char **)(split_argv(p, interpreter, r->filename,
+    *argv = (const char **)(split_argv(p, interpreter, *cmd,
                                        args)->elts);
     *cmd = (*argv)[0];
     return APR_SUCCESS;