summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2008-10-03 14:25:12 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2008-10-03 14:25:12 +0000
commit7c6e721b62a25cd5bb7b1a6c21cc9d3c1e2f06c0 (patch)
tree34f41e516445032d64e6e597c2d33d72665857d3
parent83fbfa45915970f27d894ebb030d16865f30b05e (diff)
New option -D to daemonize spamd-setup for early bootup use. This avoids
spamd-setup hanging if there are various (network?) issues and the system not proceeding to multiuser so that this can be debugged. We do not use & for startup in /etc/rc because this makes the spamd-setup a child of the rc scripts after bootup (that is gross) Problem reported in PR 5864, change discussed with beck, ok millert
-rw-r--r--etc/rc4
-rw-r--r--libexec/spamd-setup/spamd-setup.88
-rw-r--r--libexec/spamd-setup/spamd-setup.c14
3 files changed, 17 insertions, 9 deletions
diff --git a/etc/rc b/etc/rc
index 350a19a05b9..d86621c3afd 100644
--- a/etc/rc
+++ b/etc/rc
@@ -1,4 +1,4 @@
-# $OpenBSD: rc,v 1.318 2008/07/09 20:23:47 djm Exp $
+# $OpenBSD: rc,v 1.319 2008/10/03 14:25:11 deraadt Exp $
# System startup script run by init on autoboot
# or after single-user.
@@ -722,7 +722,7 @@ if [ X"${spamd_flags}" != X"NO" ]; then
spamd_flags="${spamd_flags} -b"
fi
echo -n ' spamd'; eval /usr/libexec/spamd ${spamd_flags}
- /usr/libexec/spamd-setup
+ /usr/libexec/spamd-setup -D
if [ X"${spamd_black}" = X"NO" ]; then
echo -n ' spamlogd'
/usr/libexec/spamlogd ${spamlogd_flags}
diff --git a/libexec/spamd-setup/spamd-setup.8 b/libexec/spamd-setup/spamd-setup.8
index 260abc1f532..78979d412e8 100644
--- a/libexec/spamd-setup/spamd-setup.8
+++ b/libexec/spamd-setup/spamd-setup.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: spamd-setup.8,v 1.15 2007/05/31 19:19:40 jmc Exp $
+.\" $OpenBSD: spamd-setup.8,v 1.16 2008/10/03 14:25:10 deraadt Exp $
.\"
.\" Copyright (c) 2003 Jason L. Wright (jason@thought.net)
.\" All rights reserved.
@@ -23,7 +23,7 @@
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: May 31 2007 $
+.Dd $Mdocdate: October 3 2008 $
.Dt SPAMD-SETUP 8
.Os
.Sh NAME
@@ -31,7 +31,7 @@
.Nd parse and load file of spammer addresses
.Sh SYNOPSIS
.Nm spamd-setup
-.Op Fl bdn
+.Op Fl bdDn
.Sh DESCRIPTION
The
.Nm
@@ -74,6 +74,8 @@ is running with the
flag too.
.It Fl d
Debug mode reports a few pieces of information.
+.It Fl D
+Daemonize.
.It Fl n
Dry-run mode.
No data is shipped.
diff --git a/libexec/spamd-setup/spamd-setup.c b/libexec/spamd-setup/spamd-setup.c
index 51041a50816..2a9701187cc 100644
--- a/libexec/spamd-setup/spamd-setup.c
+++ b/libexec/spamd-setup/spamd-setup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spamd-setup.c,v 1.33 2007/09/02 15:19:20 deraadt Exp $ */
+/* $OpenBSD: spamd-setup.c,v 1.34 2008/10/03 14:25:10 deraadt Exp $ */
/*
* Copyright (c) 2003 Bob Beck. All rights reserved.
@@ -780,7 +780,7 @@ __dead void
usage(void)
{
- fprintf(stderr, "usage: %s [-bdn]\n", __progname);
+ fprintf(stderr, "usage: %s [-bdDn]\n", __progname);
exit(1);
}
@@ -791,9 +791,9 @@ main(int argc, char *argv[])
char **db_array, *buf, *name;
struct blacklist *blists;
struct servent *ent;
- int i, ch;
+ int daemonize = 0, i, ch;
- while ((ch = getopt(argc, argv, "bdn")) != -1) {
+ while ((ch = getopt(argc, argv, "bdDn")) != -1) {
switch (ch) {
case 'n':
dryrun = 1;
@@ -804,6 +804,9 @@ main(int argc, char *argv[])
case 'b':
greyonly = 0;
break;
+ case 'D':
+ daemonize = 1;
+ break;
default:
usage();
break;
@@ -814,6 +817,9 @@ main(int argc, char *argv[])
if (argc != 0)
usage();
+ if (daemonize)
+ daemon(0, 0);
+
if ((ent = getservbyname("spamd-cfg", "tcp")) == NULL)
errx(1, "cannot find service \"spamd-cfg\" in /etc/services");
ent->s_port = ntohs(ent->s_port);