aboutsummaryrefslogtreecommitdiff
path: root/crypto/openssh/sshd.c
diff options
context:
space:
mode:
authorAttilio Rao <attilio@FreeBSD.org>2009-11-25 15:12:24 +0000
committerAttilio Rao <attilio@FreeBSD.org>2009-11-25 15:12:24 +0000
commit7a7043c787b61d6bf02733a04ade1947fc4ded2b (patch)
treef308da7e1d86252ddb2bfef1aafa5f589034f693 /crypto/openssh/sshd.c
parentd72dc9a7ebe0cd99bc5e2c56980ec0abcedd7465 (diff)
downloadsrc-7a7043c787b61d6bf02733a04ade1947fc4ded2b.tar.gz
src-7a7043c787b61d6bf02733a04ade1947fc4ded2b.zip
Avoid sshd, cron, syslogd and inetd to be killed under high-pressure swap
environments. Please note that this can't be done while such processes run in jails. Note: in future it would be interesting to find a way to do that selectively for any desired proccess (choosen by user himself), probabilly via a ptrace interface or whatever. Obtained from: Sandvine Incorporated Reviewed by: emaste, arch@ Sponsored by: Sandvine Incorporated MFC: 1 month
Notes
Notes: svn path=/head/; revision=199804
Diffstat (limited to 'crypto/openssh/sshd.c')
-rw-r--r--crypto/openssh/sshd.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/openssh/sshd.c b/crypto/openssh/sshd.c
index 249e20f355c5..422f0cb17a7e 100644
--- a/crypto/openssh/sshd.c
+++ b/crypto/openssh/sshd.c
@@ -47,6 +47,7 @@ __RCSID("$FreeBSD$");
#include <sys/types.h>
#include <sys/ioctl.h>
+#include <sys/mman.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
@@ -1293,6 +1294,10 @@ main(int ac, char **av)
/* Initialize configuration options to their default values. */
initialize_server_options(&options);
+ /* Avoid killing the process in high-pressure swapping environments. */
+ if (madvise(NULL, 0, MADV_PROTECT) != 0)
+ debug("madvise(): %.200s", strerror(errno));
+
/* Parse command-line arguments. */
while ((opt = getopt(ac, av, "f:p:b:k:h:g:u:o:C:dDeiqrtQRT46")) != -1) {
switch (opt) {