]>
Commit | Line | Data |
---|---|---|
131b21f1 JB |
1 | diff -Nur rc-scripts-0.3.1.orig/rc.d/init.d/functions rc-scripts-0.3.1/rc.d/init.d/functions |
2 | --- rc-scripts-0.3.1.orig/rc.d/init.d/functions 2002-01-13 04:40:42.000000000 +0100 | |
3 | +++ rc-scripts-0.3.1/rc.d/init.d/functions 2003-08-12 23:35:08.555241552 +0200 | |
038ea68f | 4 | @@ -238,13 +238,18 @@ |
131b21f1 JB |
5 | return $exit_code |
6 | } | |
7 | ||
8 | -# A function to start a program (now it's usefull on read-only filesystem too) | |
9 | +# A function to start a program (now it's useful on read-only filesystem too) | |
10 | daemon() | |
11 | { | |
12 | - typeset errors="" prog="" | |
038ea68f | 13 | + typeset errors="" prog="" limits="" |
131b21f1 JB |
14 | typeset -i exit_code=0 |
15 | [ -z "$DEFAULT_SERVICE_RUN_NICE_LEVEL" ] && DEFAULT_SERVICE_RUN_NICE_LEVEL=0 | |
16 | - # Test syntax. Don't use -o instead || here - this will broke ksh --misiek | |
17 | + # "-u unlimited" (-p for ksh) to make sure daemons will be able to fork. | |
18 | + # "-c 0" to make sure it doesn't core dump anywhere; while this could mask | |
19 | + # problems with the daemon, it also closes some security problems. | |
20 | + # Users' limits are set via pam_limits. | |
038ea68f | 21 | + [ -z "$DEFAULT_SERVICE_LIMITS" ] && DEFAULT_SERVICE_LIMITS_HARD="-u unlimited -c 0" |
131b21f1 JB |
22 | + # Test syntax. Don't use -o instead || here - this will break ksh --misiek |
23 | while [ "$1" != "${1##-}" ] || [ "$1" != "${1##+}" ]; do | |
24 | case $1 in | |
25 | '') msg_usage " daemon [--user user] [+/-nicelevel] {program}" | |
038ea68f | 26 | @@ -273,20 +279,19 @@ |
131b21f1 JB |
27 | prog="$prog $*" |
28 | fi | |
29 | ||
30 | - # make sure it doesn't core dump anywhere; while this could mask | |
31 | - # problems with the daemon, it also closes some security problems | |
32 | - ulimit -c 0 | |
33 | - | |
34 | - # Make sure daemons will be able to fork. | |
35 | - # Limits are set via pam_limits. | |
36 | if [ -n "$KSH_VERSION" ]; then | |
37 | - ulimit -p unlimited | |
038ea68f | 38 | + limits="`echo ${SERVICE_LIMITS:-$DEFAULT_SERVICE_LIMITS} | sed -e 's/-\([SH]\?\)u/-\1p/'`" |
131b21f1 JB |
39 | elif [ -n "$ZSH_VERSION" ]; then |
40 | - ulimit -u unlimited | |
038ea68f | 41 | + limits="${SERVICE_LIMITS:-$DEFAULT_SERVICE_LIMITS}" |
131b21f1 JB |
42 | elif [ -n "$BASH_VERSION" ]; then |
43 | - ulimit -u unlimited | |
038ea68f | 44 | + limits="${SERVICE_LIMITS:-$DEFAULT_SERVICE_LIMITS}" |
131b21f1 JB |
45 | # elif [ -n "`$SH -c 'echo ${.sh.version}' 2>/dev/null`" ]; then |
46 | fi | |
47 | + # soft limits first - it's impossible to set hard limit lower than existing soft | |
038ea68f JB |
48 | + while echo "$limits" | grep -q '[^ ]'; do |
49 | + ulimit `echo ${limits} | sed -e 's/^ *\(-[^-]*\)\(-.*\)\?$/\1/'` | |
50 | + limits="`echo ${limits} | sed -e 's/^ *\(-[^-]*\)\(-.*\)\?$/\2/'`" | |
131b21f1 JB |
51 | + done |
52 | ||
53 | # And start it up. | |
54 | busy | |
55 | diff -Nur rc-scripts-0.3.1.orig/sysconfig/system rc-scripts-0.3.1/sysconfig/system | |
56 | --- rc-scripts-0.3.1.orig/sysconfig/system 2001-05-15 18:05:59.000000000 +0200 | |
57 | +++ rc-scripts-0.3.1/sysconfig/system 2003-08-12 23:32:38.022126064 +0200 | |
038ea68f | 58 | @@ -17,6 +17,17 @@ |
131b21f1 JB |
59 | # $SERVICE_RUN_NICE_LEVEL is not defined in /etc/sysconfig/<service> |
60 | DEFAULT_SERVICE_RUN_NICE_LEVEL=0 | |
61 | ||
62 | +# Default limits set before running demons (hard and soft) if | |
038ea68f | 63 | +# $SERVICE_LIMITS are not defined in /etc/sysconfig/<service> |
131b21f1 | 64 | +# Use "-u" for process limits (automatically translated to "-p" for ksh). |
038ea68f | 65 | +# Use "-Sx" or "-Hx" to set only soft or hard "x" limit. |
131b21f1 JB |
66 | +# Advised limits are: |
67 | +# "-u unlimited" to make sure daemons will be able to fork; | |
68 | +# "-c 0" to make sure it doesn't core dump anywhere; while this could mask | |
69 | +# problems with the daemon, it also closes some security problems; | |
70 | +# users' limits are set via pam_limits. | |
038ea68f | 71 | +DEFAULT_SERVICE_LIMITS="-u unlimited -c 0" |
131b21f1 JB |
72 | + |
73 | # Run isapnp at system startup ? | |
74 | RUN_ISAPNP=yes | |
75 |