diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2015-12-08 03:21:10 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2015-12-08 03:21:10 +0000 |
commit | acb418c80566decc9baeba027ae53bcfb8714070 (patch) | |
tree | d09b653ea634f5fc5fa1fd0ce7e42cd2ef2f9ac8 /libexec/spamd/spamd.c | |
parent | 4b154a643b4ef5a4448fd2e5b4d8e2e11d596eb5 (diff) |
Initially pledge spamd
All the work done by Ricardo Mestre <serial@helheim.mooo.com> - Thanks.
Diffstat (limited to 'libexec/spamd/spamd.c')
-rw-r--r-- | libexec/spamd/spamd.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/libexec/spamd/spamd.c b/libexec/spamd/spamd.c index 806161d589e..bdc22b9ec8d 100644 --- a/libexec/spamd/spamd.c +++ b/libexec/spamd/spamd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spamd.c,v 1.134 2015/12/05 20:32:53 henning Exp $ */ +/* $OpenBSD: spamd.c,v 1.135 2015/12/08 03:21:09 beck Exp $ */ /* * Copyright (c) 2015 Henning Brauer <henning@openbsd.org> @@ -112,6 +112,7 @@ void getcaddr(struct con *); void gethelo(char *, size_t, char *); int read_configline(FILE *); void spamd_tls_init(char *, char *); +void check_spamd_db(void); char hostname[HOST_NAME_MAX+1]; struct syslog_data sdata = SYSLOG_DATA_INIT; @@ -1353,9 +1354,21 @@ main(int argc, char *argv[]) greylist ? " (greylist)" : "", (syncrecv || syncsend) ? " (sync)" : ""); - if (!greylist) + if (syncsend || syncrecv) { + syncfd = sync_init(sync_iface, sync_baddr, sync_port); + if (syncfd == -1) + err(1, "sync init"); + } + + if ((pw = getpwnam("_spamd")) == NULL) + errx(1, "no such user _spamd"); + + if (!greylist) { maxblack = maxcon; - else if (maxblack > maxcon) + + if (pledge("stdio rpath inet proc id", NULL) == -1) + err(1, "pledge"); + } else if (maxblack > maxcon) usage(); rlp.rlim_cur = rlp.rlim_max = maxcon + 15; @@ -1421,15 +1434,6 @@ main(int argc, char *argv[]) if (bind(conflisten, (struct sockaddr *)&lin, sizeof lin) == -1) err(1, "bind local"); - if (syncsend || syncrecv) { - syncfd = sync_init(sync_iface, sync_baddr, sync_port); - if (syncfd == -1) - err(1, "sync init"); - } - - if ((pw = getpwnam("_spamd")) == NULL) - errx(1, "no such user _spamd"); - if (debug == 0) { if (daemon(1, 1) == -1) err(1, "daemon"); @@ -1442,6 +1446,11 @@ main(int argc, char *argv[]) exit(1); } + check_spamd_db(); + + if (pledge("stdio rpath wpath flock inet proc exec id", NULL) == -1) + err(1, "pledge"); + maxblack = (maxblack >= maxcon) ? maxcon - 100 : maxblack; if (maxblack < 0) maxblack = 0; @@ -1510,6 +1519,9 @@ jail: setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) err(1, "failed to drop privs"); + if (pledge("stdio inet", NULL) == -1) + err(1, "pledge"); + if (listen(smtplisten, 10) == -1) err(1, "listen"); |