diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/config.c | 11 | ||||
-rw-r--r-- | usr.sbin/smtpd/lka.c | 8 | ||||
-rw-r--r-- | usr.sbin/smtpd/queue.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/scheduler.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtp.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.c | 17 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 3 | ||||
-rw-r--r-- | usr.sbin/smtpd/util.c | 16 |
8 files changed, 17 insertions, 50 deletions
diff --git a/usr.sbin/smtpd/config.c b/usr.sbin/smtpd/config.c index 32e75b81e55..19a675e049a 100644 --- a/usr.sbin/smtpd/config.c +++ b/usr.sbin/smtpd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.22 2013/12/26 17:25:32 eric Exp $ */ +/* $OpenBSD: config.c,v 1.23 2014/02/04 09:05:06 eric Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -20,6 +20,7 @@ #include <sys/queue.h> #include <sys/tree.h> #include <sys/socket.h> +#include <sys/resource.h> #include <event.h> #include <imsg.h> @@ -99,8 +100,16 @@ init_pipes(void) void config_process(enum smtp_proc_type proc) { + struct rlimit rl; + smtpd_process = proc; setproctitle("%s", proc_title(proc)); + + if (getrlimit(RLIMIT_NOFILE, &rl) == -1) + fatal("fdlimit: getrlimit"); + rl.rlim_cur = rl.rlim_max; + if (setrlimit(RLIMIT_NOFILE, &rl) == -1) + fatal("fdlimit: setrlimit"); } void diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index a4b9b953fb1..7674fa26303 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.161 2013/11/20 09:22:42 eric Exp $ */ +/* $OpenBSD: lka.c,v 1.162 2014/02/04 09:05:06 eric Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -653,12 +653,6 @@ lka(void) signal(SIGPIPE, SIG_IGN); signal(SIGHUP, SIG_IGN); - /* - * lka opens all kinds of files and sockets, so bump the limit to max. - * XXX: need to analyse the exact hard limit. - */ - fdlimit(1.0); - config_peer(PROC_PARENT); config_peer(PROC_QUEUE); config_peer(PROC_SMTP); diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index 31a8027c55a..6bf02686638 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.156 2013/11/20 09:22:42 eric Exp $ */ +/* $OpenBSD: queue.c,v 1.157 2014/02/04 09:05:06 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -590,8 +590,6 @@ queue(void) signal(SIGPIPE, SIG_IGN); signal(SIGHUP, SIG_IGN); - fdlimit(1.0); - config_peer(PROC_PARENT); config_peer(PROC_CONTROL); config_peer(PROC_SMTP); diff --git a/usr.sbin/smtpd/scheduler.c b/usr.sbin/smtpd/scheduler.c index 98343bf0144..cf4e55e8378 100644 --- a/usr.sbin/smtpd/scheduler.c +++ b/usr.sbin/smtpd/scheduler.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scheduler.c,v 1.40 2013/12/26 17:25:32 eric Exp $ */ +/* $OpenBSD: scheduler.c,v 1.41 2014/02/04 09:05:06 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -416,8 +416,6 @@ scheduler(void) config_process(PROC_SCHEDULER); - fdlimit(1.0); - backend->init(); if (chroot(PATH_CHROOT) == -1) diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c index aa3ea72f14d..106e81c795b 100644 --- a/usr.sbin/smtpd/smtp.c +++ b/usr.sbin/smtpd/smtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp.c,v 1.131 2013/12/05 15:05:53 eric Exp $ */ +/* $OpenBSD: smtp.c,v 1.132 2014/02/04 09:05:06 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -274,8 +274,6 @@ smtp(void) signal(SIGPIPE, SIG_IGN); signal(SIGHUP, SIG_IGN); - fdlimit(1.0); - config_peer(PROC_CONTROL); config_peer(PROC_PARENT); config_peer(PROC_LKA); diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index fb14c68885f..3fdd9c807a3 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.208 2013/12/26 17:25:32 eric Exp $ */ +/* $OpenBSD: smtpd.c,v 1.209 2014/02/04 09:05:06 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -852,21 +852,6 @@ fork_peers(void) { tree_init(&children); - /* - * Pick descriptor limit that will guarantee impossibility of fd - * starvation condition. The logic: - * - * Treat hardlimit as 100%. - * Limit smtp to 50% (inbound connections) - * Limit mta to 50% (outbound connections) - * Limit mda to 50% (local deliveries) - * In all three above, compute max session limit by halving the fd - * limit (50% -> 25%), because each session costs two fds. - * Limit queue to 100% to cover the extreme case when tons of fds are - * opened for all four possible purposes (smtp, mta, mda, bounce) - */ - fdlimit(0.5); - init_pipes(); child_add(queue(), CHILD_DAEMON, proc_title(PROC_QUEUE)); diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 254b6f54a43..0e1153a4c4a 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.441 2013/12/06 14:26:25 eric Exp $ */ +/* $OpenBSD: smtpd.h,v 1.442 2014/02/04 09:05:06 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -1343,7 +1343,6 @@ int lowercase(char *, const char *, size_t); void xlowercase(char *, const char *, size_t); int uppercase(char *, const char *, size_t); uint64_t generate_uid(void); -void fdlimit(double); int availdesc(void); int ckdir(const char *, mode_t, uid_t, gid_t, int); int rmtree(char *, int); diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c index c9c9103eff1..94e618e376b 100644 --- a/usr.sbin/smtpd/util.c +++ b/usr.sbin/smtpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.105 2014/01/08 15:30:49 deraadt Exp $ */ +/* $OpenBSD: util.c,v 1.106 2014/02/04 09:05:06 eric Exp $ */ /* * Copyright (c) 2000,2001 Markus Friedl. All rights reserved. @@ -658,20 +658,6 @@ generate_uid(void) } void -fdlimit(double percent) -{ - struct rlimit rl; - - if (percent < 0 || percent > 1) - fatalx("fdlimit: parameter out of range"); - if (getrlimit(RLIMIT_NOFILE, &rl) == -1) - fatal("fdlimit: getrlimit"); - rl.rlim_cur = percent * rl.rlim_max; - if (setrlimit(RLIMIT_NOFILE, &rl) == -1) - fatal("fdlimit: setrlimit"); -} - -void session_socket_blockmode(int fd, enum blockmodes bm) { int flags; |