]> granicus.if.org Git - apache/commitdiff
Fixed a problem with the NetWare command line builder for building the CGI
authorBradley Nicholes <bnicholes@apache.org>
Fri, 11 Oct 2002 17:31:09 +0000 (17:31 +0000)
committerBradley Nicholes <bnicholes@apache.org>
Fri, 11 Oct 2002 17:31:09 +0000 (17:31 +0000)
command line.  It did not handle building the command line when given a
script rather than an executible.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@97181 13f79535-47bb-0310-9956-ffa450edef68

modules/arch/netware/mod_netware.c

index 4d9007c852c793e38239a80f986e6decb33949d0..5e6cf0b69dd51757cc5d6d21a560b62c6a691ba1 100644 (file)
@@ -112,12 +112,25 @@ static void *merge_netware_dir_configs(apr_pool_t *p, void *basev, void *addv)
 static const char *set_extension_map(cmd_parms *cmd, netware_dir_config *m,
                                      char *CGIhdlr, char *ext, char *detach)
 {
+    int i, len;
+
     if (*ext == '.')
         ++ext;
+  
+    if (CGIhdlr != NULL) {
+        len = strlen(CGIhdlr);    
+        for (i=0; i<len; i++) {
+            if (CGIhdlr[i] == '\\') {
+                CGIhdlr[i] = '/';
+            }
+        }
+    }
+
     apr_table_set(m->file_type_handlers, ext, CGIhdlr);
     if (detach) {
         apr_table_set(m->file_handler_mode, ext, "y");
     }
+
     return NULL;
 }
 
@@ -148,34 +161,47 @@ static apr_status_t ap_cgi_build_command(const char **cmd, const char ***argv,
             args = r->args;
         }
     }
+
     cmd_only = apr_pstrdup(p, *cmd);
 
     /* truncate any arguments from the cmd */
     for (ptr = cmd_only; *ptr && (*ptr != ' '); ptr++);
     *ptr = '\0';
 
+    /* Figure out what the extension is so that we can matche it. */
     ext = strrchr(apr_filename_of_pathname(cmd_only), '.');
     
+    /* eliminate the '.' if there is one */
     if (*ext == '.')
         ++ext;
 
     /* If it is an NLM then just execute it. */
     if (stricmp(ext, "nlm")) {
+        /* check if we have a registered command for the extension*/
         *cmd = apr_table_get(d->file_type_handlers, ext);
         if (*cmd == NULL) {
             ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                       "Could not find a command associated with the %s extension", ext);
             return APR_EBADF;
         }
+
+        /* If we have a registered command then add the file that was passed in as a
+          parameter to the registered command. */
+        *cmd = apr_pstrcat (p, *cmd, " ", cmd_only, NULL);
+
+        /* Run in its own address space if specified */
         detached = apr_table_get(d->file_handler_mode, ext);
         if (detached) {
             e_info->detached = 1;
         }
     }
 
+    /* Tokenize the full command string into its arguments */
     apr_tokenize_to_argv(*cmd, (char***)argv, p);
     e_info->cmd_type = APR_PROGRAM;
-    *cmd = ap_server_root_relative(p, cmd_only);
+
+    /* The first argument should be the executible */
+    *cmd = ap_server_root_relative(p, *argv[0]);
 
     return APR_SUCCESS;
 }