summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Bloom <rbb@apache.org>2001-11-24 01:17:01 +0100
committerRyan Bloom <rbb@apache.org>2001-11-24 01:17:01 +0100
commite674055ddb46f11629b9e5730d864f3c0e24d2d5 (patch)
tree424c06ca7eb39252e9bd8732e67f5eda30dda25a
parentchange open_logs hook to return a value, allowing you to flag a error (diff)
downloadapache2-e674055ddb46f11629b9e5730d864f3c0e24d2d5.tar.xz
apache2-e674055ddb46f11629b9e5730d864f3c0e24d2d5.zip
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. PR: 8772 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92150 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CHANGES7
-rw-r--r--modules/arch/win32/mod_win32.c4
-rw-r--r--modules/generators/mod_cgi.c23
-rw-r--r--modules/generators/mod_cgi.h2
4 files changed, 23 insertions, 13 deletions
diff --git a/CHANGES b/CHANGES
index 66e52dff45..fa9437ed03 100644
--- 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]
diff --git a/modules/arch/win32/mod_win32.c b/modules/arch/win32/mod_win32.c
index f8327c0433..52de6f9501 100644
--- a/modules/arch/win32/mod_win32.c
+++ b/modules/arch/win32/mod_win32.c
@@ -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)
{
diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c
index 6424dd50de..07a8548864 100644
--- a/modules/generators/mod_cgi.c
+++ b/modules/generators/mod_cgi.c
@@ -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);
diff --git a/modules/generators/mod_cgi.h b/modules/generators/mod_cgi.h
index b8530c1db0..05dd55ff52 100644
--- a/modules/generators/mod_cgi.h
+++ b/modules/generators/mod_cgi.h
@@ -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 */