From: Arkadiusz Miƛkiewicz Date: Wed, 23 Jul 2008 12:02:03 +0000 (+0000) Subject: - prevent sshd from being killed via oom X-Git-Tag: auto/th/openssh-5_1p1-2~1 X-Git-Url: https://git.pld-linux.org/?p=packages%2Fopenssh.git;a=commitdiff_plain;h=32322335c5a6f92ca0ff279f48173bfbffd5ecba - prevent sshd from being killed via oom Changed files: opensshd.init -> 1.32 --- diff --git a/opensshd.init b/opensshd.init index 798d514..17c2a2b 100644 --- a/opensshd.init +++ b/opensshd.init @@ -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 @@ else 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 @@ start() { 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