]> granicus.if.org Git - apache/commitdiff
Fix the cmd command for mod_include. When we are processing
authorRyan Bloom <rbb@apache.org>
Sat, 24 Nov 2001 00:17:01 +0000 (00:17 +0000)
committerRyan Bloom <rbb@apache.org>
Sat, 24 Nov 2001 00:17:01 +0000 (00:17 +0000)
a cmd command, we do not want to use the r->filename to set
the command name.  The command comes from the SSI tag.  To do this,
I added a variable to the function that builds the command line
in mod_cgi.  This allows the include_cmd function to specify
the command line itself.

PR: 8772

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

CHANGES
modules/arch/win32/mod_win32.c
modules/generators/mod_cgi.c
modules/generators/mod_cgi.h

diff --git a/CHANGES b/CHANGES
index 66e52dff454d42e3f8d54a1e6740abff09f0dc77..fa9437ed031d63252c7515c6b2f56198e4e2ac42 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,12 @@
 Changes with Apache 2.0.29-dev
 
+  *) Fix the cmd command for mod_include.  When we are processing
+     a cmd command, we do not want to use the r->filename to set
+     the command name.  The command comes from the SSI tag.  To do this,
+     I added a variable to the function that builds the command line
+     in mod_cgi.  This allows the include_cmd function to specify
+     the command line itself. [Ryan Bloom]
+
   *) Change open_logs hook to return a value, allowing you
      to flag a error while opening logs
      [Ian Holsman, Doug MacEachern]
index f8327c0433dd54f53ba9ea0aeebcfc514d6bb17e..52de6f95011bb8b94a3b8154a5f0f81a05c2d6e2 100644 (file)
@@ -412,7 +412,7 @@ 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)
+                                         request_rec *r, apr_pool_t *p, int replace_cmd)
 {
     const char *ext = NULL;
     const char *interpreter = NULL;
@@ -524,7 +524,7 @@ static apr_status_t ap_cgi_build_command(const char **cmd, const char ***argv,
 
 APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_cgi_build_command,
                         (const char **cmd, 
-                         const char ***argv, request_rec *r, apr_pool_t *p));
+                         const char ***argv, request_rec *r, apr_pool_t *p, int replace_cmd));
 
 static void register_hooks(apr_pool_t *p)
 {
index 6424dd50de6eda70a2aeb54d710d260aca027b85..07a8548864f8b2d8c9269892ff2fc1822447aa33 100644 (file)
@@ -487,19 +487,22 @@ static apr_status_t run_cgi_child(apr_file_t **script_out,
 
 
 static apr_status_t default_build_command(const char **cmd, const char ***argv,
-                                          request_rec *r, apr_pool_t *p)
+                                          request_rec *r, apr_pool_t *p,
+                                          int replace_cmd)
 {
     int numwords, x, idx;
     char *w;
     const char *args = r->args;
     const char *argv0;
 
-    /* Allow suexec's "/" check to succeed */
-    if ((argv0 = strrchr(r->filename, '/')) != NULL)
-        argv0++;
-    else
-        argv0 = r->filename;
-    *cmd = argv0;
+    if (replace_cmd) {
+        /* Allow suexec's "/" check to succeed */
+        if ((argv0 = strrchr(r->filename, '/')) != NULL)
+            argv0++;
+        else
+            argv0 = r->filename;
+        *cmd = argv0;
+    }
 
     if (!args || !args[0] || ap_strchr_c(args, '=')) {
         numwords = 1;
@@ -519,7 +522,7 @@ static apr_status_t default_build_command(const char **cmd, const char ***argv,
         numwords = APACHE_ARG_MAX - 1; /* Truncate args to prevent overrun */
     }
     *argv = apr_palloc(p, (numwords + 2) * sizeof(char *));
-    (*argv)[0] = argv0;
+    (*argv)[0] = *cmd;
     for (x = 1, idx = 1; x < numwords; x++) {
         w = ap_getword_nulls(p, &args, '+');
         ap_unescape_url(w);
@@ -594,7 +597,7 @@ static int cgi_handler(request_rec *r)
     ap_add_common_vars(r);
 
     /* build the command line */
-    if ((rv = cgi_build_command(&command, &argv, r, p)) != APR_SUCCESS) {
+    if ((rv = cgi_build_command(&command, &argv, r, p, 1)) != APR_SUCCESS) {
        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                      "don't know how to spawn child process: %s", 
                       r->filename);
@@ -822,7 +825,7 @@ static int include_cmd(include_ctx_t *ctx, apr_bucket_brigade **bb,
     apr_bucket *b;
     apr_status_t rv;
 
-    if ((rv = cgi_build_command(&command, &argv, r, r->pool)) != APR_SUCCESS) {
+    if ((rv = cgi_build_command(&command, &argv, r, r->pool, 0)) != APR_SUCCESS) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                       "don't know how to spawn cmd child process: %s", 
                       r->filename);
index b8530c1db0dff537d64a8a9d9b562950b44820a4..05dd55ff5218b457ebf0aec44cd1d9fceab32d3e 100644 (file)
@@ -73,6 +73,6 @@
  */
 APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_cgi_build_command, 
                         (const char **cmd, const char ***argv,
-                         request_rec *r, apr_pool_t *p));
+                         request_rec *r, apr_pool_t *p, int replace_cmd));
 
 #endif /* _MOD_CGI_H */