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;
}
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)
{
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;
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;
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) {
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;
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) {
* @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 */