From 4086302b287620825eb0013b67adf6f5459db046 Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Sat, 13 Apr 2002 19:50:46 +0000 Subject: [PATCH] In order for Win32 to accept the shebang line of #!perl so we 1) search the PATH and 2) resolve perl.exe for perl, we must add the progtype so we can override APR_PROGRAM with APR_PROGRAM_PATH. This is the API change only for the cgi build command line option function. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94634 13f79535-47bb-0310-9956-ffa450edef68 --- modules/arch/win32/mod_win32.c | 8 +++++--- modules/generators/mod_cgi.c | 34 ++++++++++++++++++---------------- modules/generators/mod_cgi.h | 7 ++++++- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/modules/arch/win32/mod_win32.c b/modules/arch/win32/mod_win32.c index fb5300d846..ce7f0d6d30 100644 --- a/modules/arch/win32/mod_win32.c +++ b/modules/arch/win32/mod_win32.c @@ -412,7 +412,8 @@ 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) + request_rec *r, apr_pool_t *p, + int replace_cmd, apr_cmdtype_e *type) { const char *ext = NULL; const char *interpreter = NULL; @@ -525,8 +526,9 @@ 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, int replace_cmd)); + (const char **cmd, const char ***argv, + request_rec *r, apr_pool_t *p, + int replace_cmd, apr_cmdtype_e *type)); static void register_hooks(apr_pool_t *p) { diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index fe6a1f55ea..0dcf7f3ff6 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -510,7 +510,7 @@ 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, - int replace_cmd) + int replace_cmd, apr_cmdtype_e * type) { int numwords, x, idx; char *w; @@ -638,14 +638,6 @@ 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, 1)) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, - "don't know how to spawn child process: %s", - r->filename); - return HTTP_INTERNAL_SERVER_ERROR; - } - e_info.cmd_type = APR_PROGRAM; e_info.in_pipe = APR_CHILD_BLOCK; e_info.out_pipe = APR_CHILD_BLOCK; @@ -655,6 +647,15 @@ static int cgi_handler(request_rec *r) e_info.ctx = NULL; e_info.next = NULL; + /* build the command line */ + if ((rv = cgi_build_command(&command, &argv, r, p, 1, &e_info.cmd_type)) + != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + "don't know how to spawn child process: %s", + r->filename); + return HTTP_INTERNAL_SERVER_ERROR; + } + /* run the script in its own process */ if ((rv = run_cgi_child(&script_out, &script_in, &script_err, command, argv, r, p, &e_info)) != APR_SUCCESS) { @@ -886,13 +887,6 @@ 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, 0)) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, - "don't know how to spawn cmd child process: %s", - r->filename); - return HTTP_INTERNAL_SERVER_ERROR; - } - e_info.cmd_type = APR_SHELLCMD; e_info.in_pipe = APR_NO_PIPE; e_info.out_pipe = APR_FULL_BLOCK; @@ -902,6 +896,14 @@ static int include_cmd(include_ctx_t *ctx, apr_bucket_brigade **bb, e_info.ctx = ctx; e_info.next = f->next; + if ((rv = cgi_build_command(&command, &argv, r, r->pool, 0, &e_info.cmd_type)) + != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + "don't know how to spawn cmd child process: %s", + r->filename); + return HTTP_INTERNAL_SERVER_ERROR; + } + /* run the script in its own process */ if ((rv = run_cgi_child(&script_out, &script_in, &script_err, command, argv, r, r->pool, &e_info)) != APR_SUCCESS) { diff --git a/modules/generators/mod_cgi.h b/modules/generators/mod_cgi.h index eeb9e052dc..eec72ec43b 100644 --- a/modules/generators/mod_cgi.h +++ b/modules/generators/mod_cgi.h @@ -67,12 +67,17 @@ * @param argv Pointer to the arguments to pass (may be overridden) * @param r The current request * @param p The pool to allocate correct cmd/argv elements within. + * @param replace_cmd Set true if r->filename is valid and may + * replace argv[0] and cmd, otherwise false + * @param type Set to APR_SHELLCMD or APR_PROGRAM on entry, may be + * changed to invoke the program with alternate semantics. * @remark This callback may be registered by the os-specific module * to correct the command and arguments for apr_proc_create invocation * on a given os. mod_cgi will call the function if registered. */ APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_cgi_build_command, (const char **cmd, const char ***argv, - request_rec *r, apr_pool_t *p, int replace_cmd)); + request_rec *r, apr_pool_t *p, + int replace_cmd, apr_cmdtype_e *type)); #endif /* _MOD_CGI_H */ -- 2.40.0