httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/os/unix unixd.c unixd.h
Date Tue, 06 Jun 2000 21:45:17 GMT
rbb         00/06/06 14:45:17

  Modified:    .        STATUS
               src      CHANGES
               src/include http_core.h
               src/lib/apr configure.in
               src/lib/apr/include apr.h.in apr_thread_proc.h
               src/lib/apr/threadproc/unix proc.c threadproc.h
               src/main http_core.c
               src/modules/mpm/dexter mpm.h
               src/modules/mpm/mpmt_pthread mpm.h
               src/modules/mpm/prefork mpm.h
               src/modules/standard mod_cgi.c mod_include.c
               src/os/unix unixd.c unixd.h
  Log:
  Add the resource limiting code back to Apache 2.0.  This only works on
  Unix because I can't find any other platforms with rlimit.  If there are
  other platforms that need this code, then some of the code needs to move.
  This has just barely been tested, so it could probably use some good
  testing.
  
  Revision  Changes    Path
  1.78      +1 -3      apache-2.0/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/apache-2.0/STATUS,v
  retrieving revision 1.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- STATUS	2000/06/05 19:43:57	1.77
  +++ STATUS	2000/06/06 21:45:07	1.78
  @@ -1,5 +1,5 @@
   Apache 2.0 STATUS:
  -Last modified at [$Date: 2000/06/05 19:43:57 $]
  +Last modified at [$Date: 2000/06/06 21:45:07 $]
   
   Release:
   
  @@ -22,8 +22,6 @@
               default cgi module on Unix with a threaded MPM is the cgid
               module.  This should be override-able of course.
             Status: Jim Jagielski is looking into this.
  -
  -    * Put back resource limit code
   
       * suEXEC doesn't work
           Status: Manoj has posted an patch to fix this.
  
  
  
  1.141     +2 -0      apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.140
  retrieving revision 1.141
  diff -u -r1.140 -r1.141
  --- CHANGES	2000/06/06 05:58:15	1.140
  +++ CHANGES	2000/06/06 21:45:08	1.141
  @@ -1,4 +1,6 @@
   Changes with Apache 2.0a5
  +  *) Add Resource limiting code back into Apache 2.0. [Ryan Bloom]
  +
     *) Fix zombie process problem with mod_cgi.  [Jeff Trawick]
   
     *) Port mod_mmap_static to 2.0.  Make it go faster.  [Greg Ames]
  
  
  
  1.14      +10 -0     apache-2.0/src/include/http_core.h
  
  Index: http_core.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/http_core.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- http_core.h	2000/06/06 04:11:08	1.13
  +++ http_core.h	2000/06/06 21:45:09	1.14
  @@ -256,6 +256,16 @@
       unsigned add_default_charset : 2;
       char *add_default_charset_name;
   
  +    /* System Resource Control */
  +#ifdef RLIMIT_CPU
  +    struct rlimit *limit_cpu;
  +#endif
  +#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
  +    struct rlimit *limit_mem;
  +#endif
  +#ifdef RLIMIT_NPROC
  +    struct rlimit *limit_nproc;
  +#endif
       unsigned long limit_req_body;  /* limit on bytes in request msg body */
   
       /* logging options */
  
  
  
  1.100     +18 -0     apache-2.0/src/lib/apr/configure.in
  
  Index: configure.in
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/configure.in,v
  retrieving revision 1.99
  retrieving revision 1.100
  diff -u -r1.99 -r1.100
  --- configure.in	2000/06/05 23:31:52	1.99
  +++ configure.in	2000/06/06 21:45:10	1.100
  @@ -401,6 +401,24 @@
     
   AC_SUBST(oc) 
   
  +AC_MSG_CHECKING(struct rlimit)
  +AC_TRY_RUN([#include <sys/resource.h>
  +main()
  +{
  +    struct rlimit limit;
  +    limit.rlim_cur = 0;
  +    limit.rlim_max = 0;
  +    exit(0);
  +}], [
  +    struct_rlimit="1"
  +    AC_MSG_RESULT(yes) ], [
  +    struct_rlimit="0"
  +    AC_MSG_RESULT(no) ], [
  +    struct_rlimit="0"
  +    AC_MSG_RESULT(no) ] )
  +
  +AC_SUBST(struct_rlimit)
  +
   dnl #----------------------------- Checking for MMAP 
   echo $ac_n "${nl}Checking for MMAP...${nl}"
   AC_FUNC_MMAP
  
  
  
  1.29      +1 -0      apache-2.0/src/lib/apr/include/apr.h.in
  
  Index: apr.h.in
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr.h.in,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- apr.h.in	2000/06/01 01:01:15	1.28
  +++ apr.h.in	2000/06/06 21:45:10	1.29
  @@ -51,6 +51,7 @@
   #define APR_HAVE_INET_ADDR      @inet_addr@
   #define APR_HAVE_INET_NETWORK   @inet_network@
   #define APR_HAVE_UNION_SEMUN    @have_union_semun@
  +#define APR_HAVE_STRUCT_RLIMIT  @struct_rlimit@
   
   #if APR_HAVE_SYS_TYPES_H
   #include <sys/types.h>
  
  
  
  1.35      +28 -1     apache-2.0/src/lib/apr/include/apr_thread_proc.h
  
  Index: apr_thread_proc.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_thread_proc.h,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- apr_thread_proc.h	2000/05/26 16:23:13	1.34
  +++ apr_thread_proc.h	2000/06/06 21:45:10	1.35
  @@ -58,6 +58,9 @@
   #include "apr_file_io.h"
   #include "apr_general.h"
   #include "apr_errno.h"
  +#if APR_HAVE_STRUCT_RLIMIT
  +#include <sys/resource.h>
  +#endif
   
   #ifdef __cplusplus
   extern "C" {
  @@ -72,6 +75,10 @@
   #define APR_PARENT_BLOCK     3
   #define APR_CHILD_BLOCK      4
   
  +#define APR_LIMIT_CPU        0
  +#define APR_LIMIT_MEM        1
  +#define APR_LIMIT_NPROC      2
  +
   #if APR_HAS_OTHER_CHILD
   #define APR_OC_REASON_DEATH         0     /* child has died, caller must call
                                              * unregister still */
  @@ -332,7 +339,7 @@
   
   /*
   
  -=head1 ap_status_t ap_setprocattr_io(ap_procattr_t *attr, ap_int32_t in, ap_int32_t *out,
ap_int32_t err)
  +=head1 ap_status_t ap_setprocattr_io(ap_procattr_t *attr, ap_int32_t in, ap_int32_t out,
ap_int32_t err)
   
   B<Determine if any of stdin, stdout, or stderr should be linked to pipes when starting
a child process.> 
   
  @@ -452,6 +459,26 @@
   =cut
    */
   ap_status_t ap_setprocattr_detach(ap_procattr_t *attr, ap_int32_t detach);
  +
  +#if APR_HAVE_STRUCT_RLIMIT
  +/*
  +
  +=head1 ap_status_t ap_setprocattr_limit(ap_procattr_t *attr, ap_int32_t what, struct rlimit
*limit)
  +
  +B<Set the Resource Utilization limits when starting a new process.> 
  +
  +    arg 1) The procattr we care about. 
  +    arg 2) Which limit to set, one of:
  +                   APR_LIMIT_CPU
  +                   APR_LIMIT_MEM
  +                   APR_LIMIT_NPROC
  +    arg 3) Value to set the limit to.
  +
  +=cut
  + */
  +ap_status_t ap_setprocattr_limit(ap_procattr_t *attr, ap_int32_t what, 
  +                              struct rlimit *limit);
  +#endif
   
   #if APR_HAS_FORK
   /*
  
  
  
  1.30      +75 -0     apache-2.0/src/lib/apr/threadproc/unix/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/threadproc/unix/proc.c,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- proc.c	2000/05/24 00:15:05	1.29
  +++ proc.c	2000/06/06 21:45:11	1.30
  @@ -212,6 +212,48 @@
       return APR_INPARENT;
   }
   
  +#if APR_HAVE_STRUCT_RLIMIT
  +#if defined(RLIMIT_CPU) || defined(RLIMIT_NPROC) || defined(RLIMIT_AS) || defined(RLIMIT_DATA)
|| defined(RLIMIT_VMEM)
  +static ap_status_t limit_proc(ap_procattr_t *attr)
  +{
  +#ifdef RLIMIT_CPU
  +    if (attr->limit_cpu != NULL) {
  +        if ((setrlimit(RLIMIT_CPU, attr->limit_cpu)) != 0) {
  +            return errno;
  +        }
  +    }
  +#endif
  +#ifdef RLIMIT_NPROC
  +    if (attr->limit_nproc != NULL) {
  +        if ((setrlimit(RLIMIT_NPROC, attr->limit_nproc)) != 0) {
  +            return errno;
  +        }
  +    }
  +#endif
  +#if defined(RLIMIT_AS)
  +    if (attr->limit_mem != NULL) {
  +        if ((setrlimit(RLIMIT_AS, attr->limit_mem)) != 0) {
  +            return errno;
  +        }
  +    }
  +#elif defined(RLIMIT_DATA)
  +    if (attr->limit_mem != NULL) {
  +        if ((setrlimit(RLIMIT_DATA, attr->limit_mem)) != 0) {
  +            return errno;
  +        }
  +    }
  +#elif defined(RLIMIT_VMEM)
  +    if (attr->limit_mem != NULL) {
  +        if ((setrlimit(RLIMIT_VMEM, attr->limit_mem)) != 0) {
  +            return errno;
  +        }
  +    }
  +#endif
  +    return APR_SUCCESS;
  +}
  +#endif
  +#endif
  +
   ap_status_t ap_create_process(ap_proc_t *new, const char *progname, 
                                 char *const args[], char **env,
                                 ap_procattr_t *attr, ap_pool_t *cont)
  @@ -228,6 +270,7 @@
           return errno;
       }
       else if (new->pid == 0) { 
  +        int status;
           /* child process */
           if (attr->child_in) {
               ap_close(attr->parent_in);
  @@ -255,6 +298,12 @@
   
           ap_cleanup_for_exec();
   
  +#if defined(RLIMIT_CPU) || defined(RLIMIT_NPROC) || defined(RLIMIT_AS) || defined(RLIMIT_DATA)
|| defined(RLIMIT_VMEM)
  +        if ((status = limit_proc(attr)) != APR_SUCCESS) {
  +            return status;
  +        }
  +#endif 
  +
           if (attr->cmdtype == APR_SHELLCMD) {
               i = 0;
               while (args[i]) {
  @@ -338,3 +387,29 @@
       }
       return errno;
   } 
  +
  +ap_status_t ap_setprocattr_limit(ap_procattr_t *attr, ap_int32_t what, 
  +                          struct rlimit *limit)
  +{
  +    switch(what) {
  +        case APR_LIMIT_CPU:
  +#ifdef RLIMIT_CPU
  +            attr->limit_cpu = limit;
  +#else
  +            return APR_ENOTIMPL;
  +#endif
  +        case APR_LIMIT_MEM:
  +#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
  +            attr->limit_mem = limit;
  +#else
  +            return APR_ENOTIMPL;
  +#endif
  +        case APR_LIMIT_NPROC:
  +#ifdef RLIMIT_NPROC
  +            attr->limit_nproc = limit;
  +#else
  +            return APR_ENOTIMPL;
  +#endif
  +    }
  +    return APR_SUCCESS;
  +}  
  
  
  
  1.12      +12 -0     apache-2.0/src/lib/apr/threadproc/unix/threadproc.h
  
  Index: threadproc.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/threadproc/unix/threadproc.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- threadproc.h	2000/05/23 21:03:59	1.11
  +++ threadproc.h	2000/06/06 21:45:11	1.12
  @@ -61,6 +61,9 @@
   #if HAVE_PTHREAD_H
   #include <pthread.h>
   #endif
  +#if HAVE_SYS_RESOURCE_H
  +#include <sys/resource.h>
  +#endif
   #if HAVE_SIGNAL_H
   #include <signal.h>
   #endif
  @@ -109,6 +112,15 @@
       char *currdir;
       ap_int32_t cmdtype;
       ap_int32_t detached;
  +#ifdef RLIMIT_CPU
  +    struct rlimit *limit_cpu;
  +#endif
  +#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
  +    struct rlimit *limit_mem;
  +#endif
  +#ifdef RLIMIT_NPROC
  +    struct rlimit *limit_nproc;
  +#endif
   };
   
   /*This will move to ap_threadproc.h in time, but I need to figure it out
  
  
  
  1.70      +92 -0     apache-2.0/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_core.c,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- http_core.c	2000/06/06 04:11:07	1.69
  +++ http_core.c	2000/06/06 21:45:11	1.70
  @@ -72,6 +72,7 @@
   #include "apr_fnmatch.h"
   #include "http_connection.h"
   #include "util_ebcdic.h"
  +#include "mpm.h"
   
   /* Allow Apache to use ap_mmap */
   #ifdef USE_MMAP_FILES
  @@ -140,6 +141,16 @@
       conf->do_rfc1413 = DEFAULT_RFC1413 | 2; /* set bit 1 to indicate default */
       conf->satisfy = SATISFY_NOSPEC;
   
  +#ifdef RLIMIT_CPU
  +    conf->limit_cpu = NULL;
  +#endif
  +#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
  +    conf->limit_mem = NULL;
  +#endif
  +#ifdef RLIMIT_NPROC
  +    conf->limit_nproc = NULL;
  +#endif
  +
       conf->limit_req_body = 0;
       conf->sec = ap_make_array(a, 2, sizeof(void *));
   #ifdef WIN32
  @@ -243,6 +254,22 @@
   	conf->use_canonical_name = new->use_canonical_name;
       }
   
  +#ifdef RLIMIT_CPU
  +    if (new->limit_cpu) {
  +        conf->limit_cpu = new->limit_cpu;
  +    }
  +#endif
  +#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
  +    if (new->limit_mem) {
  +        conf->limit_mem = new->limit_mem;
  +    }
  +#endif
  +#ifdef RLIMIT_NPROC
  +    if (new->limit_nproc) {
  +        conf->limit_nproc = new->limit_nproc;
  +    }
  +#endif
  +
       if (new->limit_req_body) {
           conf->limit_req_body = new->limit_req_body;
       }
  @@ -2225,6 +2252,49 @@
   }
   #endif
   
  +#if !defined (RLIMIT_CPU) || !(defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS))
|| !defined (RLIMIT_NPROC)
  +static const char *no_set_limit(cmd_parms *cmd, core_dir_config *conf,
  +                                char *arg, char *arg2)
  +{
  +    ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, cmd->server,
  +                "%s not supported on this platform", cmd->cmd->name);
  +    return NULL;
  +}
  +#endif
  +
  +#ifdef RLIMIT_CPU
  +static const char *set_limit_cpu(cmd_parms *cmd, core_dir_config *conf,
  +                                 char *arg, char *arg2)
  +{
  +    unixd_set_rlimit(cmd, &conf->limit_cpu, arg, arg2, RLIMIT_CPU);
  +    return NULL;
  +}
  +#endif
  +
  +#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
  +static const char *set_limit_mem(cmd_parms *cmd, core_dir_config *conf,
  +                                 char *arg, char * arg2)
  +{
  +#if defined(RLIMIT_AS)
  +    unixd_set_rlimit(cmd, &conf->limit_mem, arg, arg2 ,RLIMIT_AS);
  +#elif defined(RLIMIT_DATA)
  +    unixd_set_rlimit(cmd, &conf->limit_mem, arg, arg2, RLIMIT_DATA);
  +#elif defined(RLIMIT_VMEM)
  +    unixd_set_rlimit(cmd, &conf->limit_mem, arg, arg2, RLIMIT_VMEM);
  +#endif
  +    return NULL;
  +}
  +#endif
  +
  +#ifdef RLIMIT_NPROC
  +static const char *set_limit_nproc(cmd_parms *cmd, core_dir_config *conf,
  +                                   char *arg, char * arg2)
  +{
  +    unixd_set_rlimit(cmd, &conf->limit_nproc, arg, arg2, RLIMIT_NPROC);
  +    return NULL;
  +}
  +#endif
  +
   /* Note --- ErrorDocument will now work from .htaccess files.  
    * The AllowOverride of Fileinfo allows webmasters to turn it off
    */
  @@ -2363,6 +2433,28 @@
     (void*)XtOffsetOf(core_dir_config, limit_req_body),
     OR_ALL, TAKE1,
     "Limit (in bytes) on maximum size of request message body" },
  +/* System Resource Controls */
  +{ "RLimitCPU",
  +#ifdef RLIMIT_CPU
  +  set_limit_cpu, (void*)XtOffsetOf(core_dir_config, limit_cpu),
  +#else
  +  no_set_limit, NULL,
  +#endif
  +  OR_ALL, TAKE12, "Soft/hard limits for max CPU usage in seconds" },
  +{ "RLimitMEM",
  +#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined (RLIMIT_AS)
  +  set_limit_mem, (void*)XtOffsetOf(core_dir_config, limit_mem),
  +#else
  +  no_set_limit, NULL,
  +#endif
  +  OR_ALL, TAKE12, "Soft/hard limits for max memory usage per process" },
  +{ "RLimitNPROC",
  +#ifdef RLIMIT_NPROC
  +  set_limit_nproc, (void*)XtOffsetOf(core_dir_config, limit_nproc),
  +#else
  +  no_set_limit, NULL,
  +#endif
  +   OR_ALL, TAKE12, "soft/hard limits for max number of processes per uid" },
   { NULL }
   };
   
  
  
  
  1.2       +1 -0      apache-2.0/src/modules/mpm/dexter/mpm.h
  
  Index: mpm.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/dexter/mpm.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mpm.h	2000/05/18 23:25:01	1.1
  +++ mpm.h	2000/06/06 21:45:14	1.2
  @@ -58,6 +58,7 @@
   
   #include "httpd.h"
   #include "mpm_default.h"
  +#include "unixd.h"
   
   #ifndef APACHE_MPM_DEXTER_H
   #define APACHE_MPM_DEXTER_H
  
  
  
  1.2       +1 -0      apache-2.0/src/modules/mpm/mpmt_pthread/mpm.h
  
  Index: mpm.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/mpmt_pthread/mpm.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mpm.h	2000/05/18 23:25:02	1.1
  +++ mpm.h	2000/06/06 21:45:14	1.2
  @@ -56,6 +56,7 @@
    * University of Illinois, Urbana-Champaign.
    */
   #include "scoreboard.h"
  +#include "unixd.h"
   
   #ifndef APACHE_MPM_MPMT_PTHREAD_H
   #define APACHE_MPM_MPMT_PTHREAD_H
  
  
  
  1.2       +1 -0      apache-2.0/src/modules/mpm/prefork/mpm.h
  
  Index: mpm.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/prefork/mpm.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mpm.h	2000/05/18 23:25:06	1.1
  +++ mpm.h	2000/06/06 21:45:14	1.2
  @@ -59,6 +59,7 @@
   #include "httpd.h"
   #include "mpm_default.h"
   #include "scoreboard.h"
  +#include "unixd.h"
   
   #ifndef APACHE_MPM_PREFORK_H
   #define APACHE_MPM_PREFORK_H
  
  
  
  1.48      +17 -0     apache-2.0/src/modules/standard/mod_cgi.c
  
  Index: mod_cgi.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_cgi.c,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- mod_cgi.c	2000/06/06 05:58:16	1.47
  +++ mod_cgi.c	2000/06/06 21:45:14	1.48
  @@ -69,6 +69,8 @@
    * they fail.
    */
   
  +#define CORE_PRIVATE
  +
   #include "ap_config.h"
   #include "httpd.h"
   #include "http_config.h"
  @@ -305,6 +307,12 @@
       ap_status_t rc = APR_SUCCESS;
       ap_file_t *file = NULL;
       ap_iol *iol;
  +#if defined(RLIMIT_CPU)  || defined(RLIMIT_NPROC) || \
  +    defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS)
  +    core_dir_config *conf;
  +    conf = (core_dir_config *) ap_get_module_config(r->per_dir_config,             
                                                &core_module);
  +#endif
  +
   
   #ifdef DEBUG_CGI
   #ifdef OS2
  @@ -341,6 +349,15 @@
                                    APR_CHILD_BLOCK)) != APR_SUCCESS) ||
           ((rc = ap_setprocattr_dir(procattr, 
                                     ap_make_dirstr_parent(r->pool, r->filename))) !=
APR_SUCCESS) ||
  +#ifdef RLIMIT_CPU
  +        ((rc = ap_setprocattr_limit(procattr, APR_LIMIT_CPU, conf->limit_cpu)) != APR_SUCCESS)
||
  +#endif
  +#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
  +        ((rc = ap_setprocattr_limit(procattr, APR_LIMIT_MEM, conf->limit_mem)) != APR_SUCCESS)
||
  +#endif
  +#ifdef RLIMIT_NPROC
  +        ((rc = ap_setprocattr_limit(procattr, APR_LIMIT_NPROC, conf->limit_nproc)) !=
APR_SUCCESS) ||
  +#endif
           ((rc = ap_setprocattr_cmdtype(procattr, APR_PROGRAM)) != APR_SUCCESS)) {
           /* Something bad happened, tell the world. */
   	ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r,
  
  
  
  1.35      +18 -0     apache-2.0/src/modules/standard/mod_include.c
  
  Index: mod_include.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_include.c,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- mod_include.c	2000/05/27 22:40:37	1.34
  +++ mod_include.c	2000/06/06 21:45:15	1.35
  @@ -76,6 +76,8 @@
    * -Doug MacEachern
    */
   
  +#define CORE_PRIVATE
  +
   #ifdef USE_PERL_SSI
   #include "config.h"
   #undef VOIDUSED
  @@ -94,6 +96,7 @@
   #include "http_log.h"
   #include "http_main.h"
   #include "util_script.h"
  +#include "http_core.h"
   #include <string.h>
   #ifdef HAVE_PWD_H
   #include <pwd.h>
  @@ -828,6 +831,12 @@
       char **argv;
       ap_file_t *file = NULL;
       ap_iol *iol;
  +#if defined(RLIMIT_CPU)  || defined(RLIMIT_NPROC) || \
  +    defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS)
  +    core_dir_config *conf; 
  +    conf = (core_dir_config *) ap_get_module_config(r->per_dir_config,
  +                                                    &core_module);
  +#endif
   
       arg.r = r;
       arg.s = s;
  @@ -863,6 +872,15 @@
           (ap_setprocattr_io(procattr, APR_NO_PIPE, 
                              APR_FULL_BLOCK, APR_NO_PIPE) != APR_SUCCESS) ||
           (ap_setprocattr_dir(procattr, ap_make_dirstr_parent(r->pool, r->filename))
!= APR_SUCCESS) ||
  +#ifdef RLIMIT_CPU
  +        ((rc = ap_setprocattr_limit(procattr, APR_LIMIT_CPU, conf->limit_cpu)) != APR_SUCCESS)
||
  +#endif
  +#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
  +        ((rc = ap_setprocattr_limit(procattr, APR_LIMIT_MEM, conf->limit_mem)) != APR_SUCCESS)
||
  +#endif
  +#ifdef RLIMIT_NPROC
  +        ((rc = ap_setprocattr_limit(procattr, APR_LIMIT_NPROC, conf->limit_nproc)) !=
APR_SUCCESS) ||
  +#endif
           (ap_setprocattr_cmdtype(procattr, APR_SHELLCMD) != APR_SUCCESS)) {
           /* Something bad happened, tell the world. */
   	ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
  
  
  
  1.13      +59 -1     apache-2.0/src/os/unix/unixd.c
  
  Index: unixd.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/os/unix/unixd.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- unixd.c	2000/04/26 14:54:57	1.12
  +++ unixd.c	2000/06/06 21:45:16	1.13
  @@ -63,6 +63,8 @@
   #include "http_log.h"
   #include "unixd.h"
   #include <pwd.h>
  +#include <sys/resource.h>
  +#include <sys/resource.h>
   
   unixd_config_rec unixd_config;
   
  @@ -394,4 +396,60 @@
               ap_sys_siglist[sig] = "";
   }
   #endif /* NEED_AP_SYS_SIGLIST */
  - 
  +
  +#if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_NPROC)
|| defined(RLIMIT_AS)
  +API_EXPORT(void) unixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit, 
  +                           const char *arg, const char * arg2, int type)
  +{
  +    char *str;
  +    struct rlimit *limit;
  +    /* If your platform doesn't define rlim_t then typedef it in ap_config.h */
  +    rlim_t cur = 0;
  +    rlim_t max = 0;
  +
  +    *plimit = (struct rlimit *)ap_pcalloc(cmd->pool, sizeof(**plimit));
  +    limit = *plimit;
  +    if ((getrlimit(type, limit)) != 0)  {
  +        *plimit = NULL;
  +        ap_log_error(APLOG_MARK, APLOG_ERR, cmd->server,
  +                     "%s: getrlimit failed", cmd->cmd->name);
  +        return;
  +    }
  +
  +    if ((str = ap_getword_conf(cmd->pool, &arg))) {
  +        if (!strcasecmp(str, "max")) {
  +            cur = limit->rlim_max;
  +        }
  +        else {
  +            cur = atol(str);
  +        }
  +    }
  +    else {
  +        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, cmd->server,
  +                     "Invalid parameters for %s", cmd->cmd->name);
  +        return;
  +    }
  +
  +    if (arg2 && (str = ap_getword_conf(cmd->pool, &arg2))) {
  +        max = atol(str);
  +    }
  +
  +    /* if we aren't running as root, cannot increase max */
  +    if (geteuid()) {
  +        limit->rlim_cur = cur;
  +        if (max) {
  +            ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, cmd->server,
  +                         "Must be uid 0 to raise maximum %s", cmd->cmd->name);
  +        }
  +    }
  +    else {
  +        if (cur) {
  +            limit->rlim_cur = cur;
  +        }
  +        if (max) {
  +            limit->rlim_max = max;
  +        }
  +    }
  +}
  +#endif
  +
  
  
  
  1.8       +6 -0      apache-2.0/src/os/unix/unixd.h
  
  Index: unixd.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/os/unix/unixd.h,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- unixd.h	2000/04/26 14:54:57	1.7
  +++ unixd.h	2000/06/06 21:45:16	1.8
  @@ -60,6 +60,7 @@
   #define UNIXD_H
   
   #include "httpd.h"
  +#include <sys/resource.h>
   
   /* common stuff that unix MPMs will want */
   
  @@ -85,6 +86,11 @@
   void unixd_pre_config(void);
   const char *unixd_set_user(cmd_parms *cmd, void *dummy, char *arg);
   const char *unixd_set_group(cmd_parms *cmd, void *dummy, char *arg);
  +#if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || \
  +    defined(RLIMIT_NPROC) || defined(RLIMIT_AS)
  +API_EXPORT(void) unixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit,
  +                           const char *arg, const char * arg2, int type);
  +#endif
   
   /* Information on signals for the various platforms */
   
  
  
  

Mime
View raw message