diff -Nur rc-scripts-0.4.0.2.orig/rc.d/init.d/functions rc-scripts-0.4.0.2/rc.d/init.d/functions --- rc-scripts-0.4.0.2.orig/rc.d/init.d/functions 2003-10-02 20:46:49.000000000 +0200 +++ rc-scripts-0.4.0.2/rc.d/init.d/functions 2003-10-12 15:50:17.035580952 +0200 @@ -263,13 +263,18 @@ return $exit_code } -# A function to start a program (now it's usefull on read-only filesystem too) +# A function to start a program (now it's useful on read-only filesystem too) daemon() { - typeset errors="" prog="" + typeset errors="" prog="" limits="" typeset -i exit_code=0 [ -z "$DEFAULT_SERVICE_RUN_NICE_LEVEL" ] && DEFAULT_SERVICE_RUN_NICE_LEVEL=0 - # Test syntax. Don't use -o instead || here - this will broke ksh --misiek + # "-u unlimited" (-p for ksh) to make sure daemons will be able to fork. + # "-c 0" to make sure it doesn't core dump anywhere; while this could mask + # problems with the daemon, it also closes some security problems. + # Users' limits are set via pam_limits. + [ -z "$DEFAULT_SERVICE_LIMITS" ] && DEFAULT_SERVICE_LIMITS_HARD="-u unlimited -c 0" + # Test syntax. Don't use -o instead || here - this will break ksh --misiek while [ "$1" != "${1##-}" ] || [ "$1" != "${1##+}" ]; do case $1 in '') @@ -299,20 +304,18 @@ prog="$prog $*" fi - # make sure it doesn't core dump anywhere; while this could mask - # problems with the daemon, it also closes some security problems - ulimit -c 0 - - # Make sure daemons will be able to fork. - # Limits are set via pam_limits. if [ -n "$KSH_VERSION" ]; then - ulimit -p unlimited + limits="`echo ${SERVICE_LIMITS:-$DEFAULT_SERVICE_LIMITS} | sed -e 's/-\([SH]\?\)u/-\1p/'`" elif [ -n "$ZSH_VERSION" ]; then - ulimit -u unlimited + limits="${SERVICE_LIMITS:-$DEFAULT_SERVICE_LIMITS}" elif [ -n "$BASH_VERSION" ]; then - ulimit -u unlimited + limits="${SERVICE_LIMITS:-$DEFAULT_SERVICE_LIMITS}" # elif [ -n "`$SH -c 'echo ${.sh.version}' 2>/dev/null`" ]; then fi + while echo "$limits" | grep -q '[^ ]'; do + ulimit `echo ${limits} | sed -e 's/^ *\(-[^-]*\)\(-.*\)\?$/\1/'` + limits="`echo ${limits} | sed -e 's/^ *\(-[^-]*\)\(-.*\)\?$/\2/'`" + done # And start it up. busy diff -Nur rc-scripts-0.4.0.2.orig/sysconfig/system rc-scripts-0.4.0.2/sysconfig/system --- rc-scripts-0.4.0.2.orig/sysconfig/system 2003-10-02 20:46:49.000000000 +0200 +++ rc-scripts-0.4.0.2/sysconfig/system 2003-10-12 15:50:53.502037208 +0200 @@ -17,6 +17,17 @@ # $SERVICE_RUN_NICE_LEVEL is not defined in /etc/sysconfig/ DEFAULT_SERVICE_RUN_NICE_LEVEL=0 +# Default limits set before running demons (hard and soft) if +# $SERVICE_LIMITS are not defined in /etc/sysconfig/ +# Use "-u" for process limits (automatically translated to "-p" for ksh). +# Use "-Sx" or "-Hx" to set only soft or hard "x" limit. +# Advised limits are: +# "-u unlimited" to make sure daemons will be able to fork; +# "-c 0" to make sure it doesn't core dump anywhere; while this could mask +# problems with the daemon, it also closes some security problems; +# users' limits are set via pam_limits. +DEFAULT_SERVICE_LIMITS="-u unlimited -c 0" + # Setup PNP using userspace tools? RUN_USERPNP=yes # Setup kernel space PNP (2.4.x)