Note: this patch is obsolete. There is a more current versions of suPHP 0.6.x where rlimits can be set via the Apache configuration using the directives RLimitCPU, RLimitMEM, RLimitNPROC.
rlimit-patch for suPHP
patch -p0 < rlimit-0.1.0-0.5.2-patch
autoconf
autoheader
after this the configuration possibilities are enhanced by the following options
--with-rlimit-cpu=SECONDS limit cpu time with setrlimit --with-rlimit-as=BYTES limit total available memory with setrlimit --with-rlimit-nproc=COUNT limit number of processes with setrlimit --with-rlimit-nofile=COUNT limit number of open files with setrlimit
so just run configure with your preferences, make, and make install
e.g. ./configure --prefix=/usr/local --with-apache-user=apache --with-rlimit-cpu=120 --with-rlimit-as=52428800 --with-rlimit-nproc=15 --with-rlimit-nofile=100
make && make install
this will limit every execution of a php script to 2 minutes cpu time, 50 MB memory, 15 processes, and a maximum number of 100 open files.
For the other configuration directives see the suPHP documentation
The patch is tested with Apache 1.3.x only!