From: Eric Covener Date: Sat, 17 Sep 2011 17:01:15 +0000 (+0000) Subject: PR51371: cross-compile issues with cgi and apr_procattr_limit_*. X-Git-Tag: 2.3.15~239 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f08932bf97fd79b046038e96d3e2566f743ee303;p=thirdparty%2Fapache%2Fhttpd.git PR51371: cross-compile issues with cgi and apr_procattr_limit_*. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1172019 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 95be63c5ccd..0fa1925048f 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,9 @@ Changes with Apache 2.3.15 PR 51714. [Stefan Fritsch, Jim Jagielski, Ruediger Pluem, Eric Covener, ] + *) Fix cross-compilation of mod_cgi/mod_cgid when APR_HAVE_STRUCT_RLIMIT is + false but RLIMIT_* are defined. PR51371. [Eric Covener] + *) core: Correctly obey ServerName / ServerAlias if the Host header from the request matches the VirtualHost address. PR 51709. [Micha Lenk ] diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index 02a5700f16b..121575c94ea 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -53,6 +53,12 @@ #include "mod_core.h" #include "mod_cgi.h" +#if APR_HAVE_STRUCT_RLIMIT +#if defined (RLIMIT_CPU) || defined (RLIMIT_NPROC) || defined (RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) +#define AP_CGI_USE_RLIMIT +#endif +#endif + module AP_MODULE_DECLARE_DATA cgi_module; static APR_OPTIONAL_FN_TYPE(ap_register_include_handler) *cgi_pfn_reg_with_ssi; @@ -382,9 +388,7 @@ static apr_status_t run_cgi_child(apr_file_t **script_out, apr_proc_t *procnew; apr_status_t rc = APR_SUCCESS; -#if defined(RLIMIT_CPU) || defined(RLIMIT_NPROC) || \ - defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS) - +#ifdef AP_CGI_USE_RLIMIT core_dir_config *conf = ap_get_core_module_config(r->per_dir_config); #endif @@ -424,15 +428,15 @@ static apr_status_t run_cgi_child(apr_file_t **script_out, ((rc = apr_procattr_dir_set(procattr, ap_make_dirstr_parent(r->pool, r->filename))) != APR_SUCCESS) || -#ifdef RLIMIT_CPU +#if defined(RLIMIT_CPU) && defined(AP_CGI_USE_RLIMIT) ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_CPU, conf->limit_cpu)) != APR_SUCCESS) || #endif -#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) +#if defined(AP_CGI_USE_RLIMIT) && (defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)) ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_MEM, conf->limit_mem)) != APR_SUCCESS) || #endif -#ifdef RLIMIT_NPROC +#if RLIMIT_NPROC && defined(AP_CGI_USE_RLIMIT) ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_NPROC, conf->limit_nproc)) != APR_SUCCESS) || #endif diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c index a18fa21e1b9..e88dc05d26c 100644 --- a/modules/generators/mod_cgid.c +++ b/modules/generators/mod_cgid.c @@ -70,6 +70,11 @@ #include #include /* for sockaddr_un */ +#if APR_HAVE_STRUCT_RLIMIT +#if defined (RLIMIT_CPU) || defined (RLIMIT_NPROC) || defined (RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) +#define AP_CGID_USE_RLIMIT +#endif +#endif module AP_MODULE_DECLARE_DATA cgid_module; @@ -168,7 +173,7 @@ typedef struct { int bufbytes; } cgid_server_conf; -#if defined (RLIMIT_CPU) || defined (RLIMIT_NPROC) || defined (RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) +#ifdef AP_CGID_USE_RLIMIT typedef struct { #ifdef RLIMIT_CPU int limit_cpu_set; @@ -203,7 +208,7 @@ typedef struct { apr_size_t args_len; int loglevel; /* to stuff in server_rec */ -#if defined (RLIMIT_CPU) || defined (RLIMIT_NPROC) || defined (RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) +#ifdef AP_CGID_USE_RLIMIT cgid_rlimit_t limits; #endif } cgid_req_t; @@ -459,7 +464,7 @@ static apr_status_t get_req(int fd, request_rec *r, char **argv0, char ***env, } *env = environ; -#if defined (RLIMIT_CPU) || defined (RLIMIT_NPROC) || defined (RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) +#ifdef AP_CGID_USE_RLIMIT if ((stat = sock_read(fd, &(req->limits), sizeof(cgid_rlimit_t))) != APR_SUCCESS) return stat; #endif @@ -524,7 +529,7 @@ static apr_status_t send_req(int fd, request_rec *r, char *argv0, char **env, return stat; } } -#ifdef RLIMIT_CPU +#if defined(RLIMIT_CPU) && defined(AP_CGID_USE_RLIMIT) if (core_conf->limit_cpu) { req.limits.limit_cpu = *(core_conf->limit_cpu); req.limits.limit_cpu_set = 1; @@ -534,7 +539,7 @@ static apr_status_t send_req(int fd, request_rec *r, char *argv0, char **env, } #endif -#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) +#if defined(AP_CGID_USE_RLIMIT) && (defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)) if (core_conf->limit_mem) { req.limits.limit_mem = *(core_conf->limit_mem); req.limits.limit_mem_set = 1; @@ -545,7 +550,7 @@ static apr_status_t send_req(int fd, request_rec *r, char *argv0, char **env, #endif -#ifdef RLIMIT_NPROC +#if defined(RLIMIT_NPROC) && defined(AP_CGID_USE_RLIMIT) if (core_conf->limit_nproc) { req.limits.limit_nproc = *(core_conf->limit_nproc); req.limits.limit_nproc_set = 1; @@ -555,7 +560,7 @@ static apr_status_t send_req(int fd, request_rec *r, char *argv0, char **env, } #endif -#if defined (RLIMIT_CPU) || defined (RLIMIT_NPROC) || defined (RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) +#ifdef AP_CGID_USE_RLIMIT if ( (stat = sock_write(fd, &(req.limits), sizeof(cgid_rlimit_t))) != APR_SUCCESS) return stat; #endif @@ -761,6 +766,7 @@ static int cgid_server(void *data) ((rc = apr_procattr_dir_set(procattr, ap_make_dirstr_parent(r->pool, r->filename))) != APR_SUCCESS) || ((rc = apr_procattr_cmdtype_set(procattr, cmd_type)) != APR_SUCCESS) || +#ifdef AP_CGID_USE_RLIMIT #ifdef RLIMIT_CPU ( (cgid_req.limits.limit_cpu_set) && ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_CPU, &cgid_req.limits.limit_cpu)) != APR_SUCCESS)) || @@ -772,6 +778,7 @@ static int cgid_server(void *data) #ifdef RLIMIT_NPROC ( (cgid_req.limits.limit_nproc_set) && ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_NPROC, &cgid_req.limits.limit_nproc)) != APR_SUCCESS)) || +#endif #endif ((rc = apr_procattr_child_errfn_set(procattr, cgid_child_errfn)) != APR_SUCCESS)) {