From: Bradley Nicholes Date: Wed, 21 Sep 2005 22:17:55 +0000 (+0000) Subject: Backport the use of apr_procattr_addrspace_set() to specify whether the new process... X-Git-Tag: 2.0.55~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=871c32b904e3637345e27e54ab96d344937c9bd1;p=thirdparty%2Fapache%2Fhttpd.git Backport the use of apr_procattr_addrspace_set() to specify whether the new process should be started in the current address space or a new address space. This should have no effect on most platforms other than NetWare. Reviewed By: jjclar, bnicholes, trawick git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.0.x@290850 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/STATUS b/STATUS index c96b3cd8b94..cf88c562a45 100644 --- a/STATUS +++ b/STATUS @@ -108,27 +108,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - *) mod_cgi: Added API call and overload of detached field in - cgi_exec_info_t structure to support loading in current or new address - space for CGIs. The patch change how NetWare use cmdtype for - processes. It was made necessary by changes done to log.c r1.145. - The HTTP and the APR patches are available at: - - - +1: jjclar, bnicholes, trawick - jerenkrantz: I'm confused as to the status of this backport. - trawick: Somebody commits the APR 0.9 patch, then: - do we have to wait for later APR 0.x release before putting - calls to apr_procattr_addrspace_set() into httpd-2.0.x, or - do we go ahead and introduce the prerequisite? - clar replies: I am ready to commit the apr 0.9.x patch, but then will - need the changes in the httpd-2.0.x to be done in order for NetWare - to work as expected when calling apr_proc_create. Should I do both, - APR and Http, at the same time? - wrowe: commit to APR. Use an APR version test *in httpd* to determine - if the old or new behavior should be used in httpd. In future versions - you could remove the test altogether. - *) mod_actions: Regression from 1.3: the file referred to must exist. Solve this by introducing the "virtual" modifier to the Action directive. PR 28553. diff --git a/modules/arch/netware/mod_netware.c b/modules/arch/netware/mod_netware.c index aa560f7931a..2c4e2248bf2 100644 --- a/modules/arch/netware/mod_netware.c +++ b/modules/arch/netware/mod_netware.c @@ -100,7 +100,6 @@ static apr_status_t ap_cgi_build_command(const char **cmd, const char ***argv, char *ext = NULL; char *cmd_only, *ptr; const char *new_cmd; - const char *detached = NULL; netware_dir_config *d; apr_file_t *fh; const char *args = ""; @@ -143,6 +142,7 @@ static apr_status_t ap_cgi_build_command(const char **cmd, const char ***argv, /* check if we have a registered command for the extension*/ new_cmd = apr_table_get(d->file_type_handlers, ext); + e_info->detached = AP_PROC_DETACHED; if (new_cmd == NULL) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "Could not find a command associated with the %s extension", ext); @@ -154,18 +154,12 @@ static apr_status_t ap_cgi_build_command(const char **cmd, const char ***argv, *cmd = apr_pstrcat (p, new_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->cmd_type = APR_PROGRAM_ENV; - } - else { - e_info->cmd_type = APR_PROGRAM; - } + if(apr_table_get(d->file_handler_mode, ext)) + e_info->detached |= AP_PROC_NEWADDRSPACE; } /* Tokenize the full command string into its arguments */ apr_tokenize_to_argv(*cmd, (char***)argv, p); - e_info->detached = 1; /* The first argument should be the executible */ *cmd = ap_server_root_relative(p, *argv[0]); diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index 1ff33bb559b..3a8ae8ef6b6 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -436,7 +436,9 @@ static apr_status_t run_cgi_child(apr_file_t **script_out, e_info->cmd_type)) != APR_SUCCESS) || ((rc = apr_procattr_detach_set(procattr, - e_info->detached)) != APR_SUCCESS) || + e_info->detached & AP_PROC_DETACHED)) != APR_SUCCESS) || + ((rc = apr_procattr_addrspace_set(procattr, + (e_info->detached & AP_PROC_NEWADDRSPACE) ? 1 : 0)) != APR_SUCCESS) || ((rc = apr_procattr_child_errfn_set(procattr, cgi_child_errfn)) != APR_SUCCESS)) { /* Something bad happened, tell the world. */ ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, diff --git a/modules/generators/mod_cgi.h b/modules/generators/mod_cgi.h index 7221093a836..cf9d9ba9d71 100644 --- a/modules/generators/mod_cgi.h +++ b/modules/generators/mod_cgi.h @@ -19,6 +19,9 @@ #include "mod_include.h" +#define AP_PROC_DETACHED 1 +#define AP_PROC_NEWADDRSPACE 2 + typedef enum {RUN_AS_SSI, RUN_AS_CGI} prog_types; typedef struct { @@ -27,7 +30,8 @@ typedef struct { apr_int32_t err_pipe; int process_cgi; apr_cmdtype_e cmd_type; - apr_int32_t detached; + apr_int32_t detached; /* used as a bitfield for detached_ & addrspace_set, */ + /* when initializing apr_proc_attr structure */ prog_types prog_type; apr_bucket_brigade **bb; include_ctx_t *ctx;