]> git.pld-linux.org Git - packages/rc-scripts.git/blob - rc-scripts-ulimits.patch
fb4477c6b22bfc3e07d6442de3003bb931f6810d
[packages/rc-scripts.git] / rc-scripts-ulimits.patch
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
4 @@ -238,13 +238,18 @@
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=""
13 +       typeset errors="" prog="" limits=""
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.
21 +       [ -z "$DEFAULT_SERVICE_LIMITS" ] && DEFAULT_SERVICE_LIMITS_HARD="-u unlimited -c 0"
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}"
26 @@ -273,20 +279,19 @@
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
38 +               limits="`echo ${SERVICE_LIMITS:-$DEFAULT_SERVICE_LIMITS} | sed -e 's/-\([SH]\?\)u/-\1p/'`"
39         elif [ -n "$ZSH_VERSION" ]; then
40 -               ulimit -u unlimited
41 +               limits="${SERVICE_LIMITS:-$DEFAULT_SERVICE_LIMITS}"
42         elif [ -n "$BASH_VERSION" ]; then
43 -               ulimit -u unlimited
44 +               limits="${SERVICE_LIMITS:-$DEFAULT_SERVICE_LIMITS}"
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
48 +       while echo "$limits" | grep -q '[^ ]'; do
49 +               ulimit `echo ${limits} | sed -e 's/^ *\(-[^-]*\)\(-.*\)\?$/\1/'`
50 +               limits="`echo ${limits} | sed -e 's/^ *\(-[^-]*\)\(-.*\)\?$/\2/'`"
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
58 @@ -17,6 +17,17 @@
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
63 +# $SERVICE_LIMITS are not defined in /etc/sysconfig/<service>
64 +# Use "-u" for process limits (automatically translated to "-p" for ksh).
65 +# Use "-Sx" or "-Hx" to set only soft or hard "x" limit.
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.
71 +DEFAULT_SERVICE_LIMITS="-u unlimited -c 0"
72 +
73  # Run isapnp at system startup ?
74  RUN_ISAPNP=yes
75  
This page took 0.021955 seconds and 2 git commands to generate.