diff options
Diffstat (limited to 'debian/openssh-server.init')
-rw-r--r-- | debian/openssh-server.init | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/debian/openssh-server.init b/debian/openssh-server.init index 67b204789..8c38eedf5 100644 --- a/debian/openssh-server.init +++ b/debian/openssh-server.init | |||
@@ -16,6 +16,7 @@ set -e | |||
16 | test -x /usr/sbin/sshd || exit 0 | 16 | test -x /usr/sbin/sshd || exit 0 |
17 | ( /usr/sbin/sshd -\? 2>&1 | grep -q OpenSSH ) 2>/dev/null || exit 0 | 17 | ( /usr/sbin/sshd -\? 2>&1 | grep -q OpenSSH ) 2>/dev/null || exit 0 |
18 | 18 | ||
19 | SSHD_OOM_ADJUST=-17 | ||
19 | if test -f /etc/default/ssh; then | 20 | if test -f /etc/default/ssh; then |
20 | . /etc/default/ssh | 21 | . /etc/default/ssh |
21 | fi | 22 | fi |
@@ -70,6 +71,15 @@ check_config() { | |||
70 | fi | 71 | fi |
71 | } | 72 | } |
72 | 73 | ||
74 | adjust_oom() { | ||
75 | if [ -e /var/run/sshd.pid ]; then | ||
76 | PID="$(head -n1 /var/run/sshd.pid)" | ||
77 | if [ -e "/proc/$PID/oom_adj" ]; then | ||
78 | printf '%s' "$SSHD_OOM_ADJUST" >"/proc/$PID/oom_adj" | ||
79 | fi | ||
80 | fi | ||
81 | } | ||
82 | |||
73 | export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" | 83 | export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" |
74 | 84 | ||
75 | case "$1" in | 85 | case "$1" in |
@@ -80,6 +90,7 @@ case "$1" in | |||
80 | log_daemon_msg "Starting OpenBSD Secure Shell server" "sshd" | 90 | log_daemon_msg "Starting OpenBSD Secure Shell server" "sshd" |
81 | if start-stop-daemon --start --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS; then | 91 | if start-stop-daemon --start --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS; then |
82 | log_end_msg 0 | 92 | log_end_msg 0 |
93 | adjust_oom | ||
83 | else | 94 | else |
84 | log_end_msg 1 | 95 | log_end_msg 1 |
85 | fi | 96 | fi |
@@ -113,6 +124,7 @@ case "$1" in | |||
113 | check_dev_null log_end_msg | 124 | check_dev_null log_end_msg |
114 | if start-stop-daemon --start --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS; then | 125 | if start-stop-daemon --start --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS; then |
115 | log_end_msg 0 | 126 | log_end_msg 0 |
127 | adjust_oom | ||
116 | else | 128 | else |
117 | log_end_msg 1 | 129 | log_end_msg 1 |
118 | fi | 130 | fi |