SOURCES: opensshd.init - prevent sshd from being killed via oom

arekm arekm at pld-linux.org
Wed Jul 23 14:02:09 CEST 2008


Author: arekm                        Date: Wed Jul 23 12:02:09 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- prevent sshd from being killed via oom

---- Files affected:
SOURCES:
   opensshd.init (1.31 -> 1.32) 

---- Diffs:

================================================================
Index: SOURCES/opensshd.init
diff -u SOURCES/opensshd.init:1.31 SOURCES/opensshd.init:1.32
--- SOURCES/opensshd.init:1.31	Mon May 19 08:09:17 2008
+++ SOURCES/opensshd.init	Wed Jul 23 14:02:03 2008
@@ -8,6 +8,7 @@
 #		Ssh can be used for remote login, remote file copying, TCP port \
 #		forwarding etc. Ssh offers strong encryption and authentication.
 
+SSHD_OOM_ADJUST=-17
 
 # Source function library
 . /etc/rc.d/init.d/functions
@@ -28,6 +29,16 @@
 	exit 0
 fi
 
+adjust_oom() {
+    if [ -e /var/run/sshd.pid ]; then
+	for pid in $(cat /var/run/sshd.pid); do
+        	if [ -w "/proc/$pid/oom_adj" ]; then
+	            echo "$SSHD_OOM_ADJUST" > "/proc/$pid/oom_adj" 2> /dev/null || :
+	        fi
+	done
+    fi
+}
+
 checkconfig() {
 	/usr/sbin/sshd -t || exit 1
 }
@@ -63,6 +74,7 @@
 		msg_starting OpenSSH
 		daemon --pidfile /var/run/sshd.pid /usr/sbin/sshd
 		RETVAL=$?
+		adjust_oom
 		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sshd
 	else
 		msg_already_running OpenSSH
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/opensshd.init?r1=1.31&r2=1.32&f=u



More information about the pld-cvs-commit mailing list