summaryrefslogtreecommitdiff
path: root/usr.sbin/snmpd
diff options
context:
space:
mode:
authorTobias Heider <tobhe@cvs.openbsd.org>2024-04-08 13:18:55 +0000
committerTobias Heider <tobhe@cvs.openbsd.org>2024-04-08 13:18:55 +0000
commit581bfe7f01e5bb860ede687c0e27c4bc1e69bbfe (patch)
tree7f64656434b459b8df016b483a44e1ada7105571 /usr.sbin/snmpd
parentd6e189c24917784bf5066d1b16f45078527f0592 (diff)
Call daemon() only in parent and before proc_exec() to avoid orphaning child
processes. Synced from relayd. ok florian@
Diffstat (limited to 'usr.sbin/snmpd')
-rw-r--r--usr.sbin/snmpd/proc.c5
-rw-r--r--usr.sbin/snmpd/snmpd.c4
2 files changed, 5 insertions, 4 deletions
diff --git a/usr.sbin/snmpd/proc.c b/usr.sbin/snmpd/proc.c
index 941857b7124..61355cdb59d 100644
--- a/usr.sbin/snmpd/proc.c
+++ b/usr.sbin/snmpd/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.30 2024/01/16 13:33:12 claudio Exp $ */
+/* $OpenBSD: proc.c,v 1.31 2024/04/08 13:18:54 tobhe Exp $ */
/*
* Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
@@ -205,6 +205,9 @@ proc_init(struct privsep *ps, struct privsep_proc *procs, unsigned int nproc,
privsep_process = PROC_PARENT;
proc_setup(ps, procs, nproc);
+ if (!debug && daemon(0, 0) == -1)
+ fatal("failed to daemonize");
+
/*
* Create the children sockets so we can use them
* to distribute the rest of the socketpair()s using
diff --git a/usr.sbin/snmpd/snmpd.c b/usr.sbin/snmpd/snmpd.c
index d3ecfd6f027..c48b2a959d6 100644
--- a/usr.sbin/snmpd/snmpd.c
+++ b/usr.sbin/snmpd/snmpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: snmpd.c,v 1.50 2023/12/22 13:04:30 martijn Exp $ */
+/* $OpenBSD: snmpd.c,v 1.51 2024/04/08 13:18:54 tobhe Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
@@ -222,8 +222,6 @@ main(int argc, char *argv[])
env->sc_engine_boots = 0;
proc_init(ps, procs, nitems(procs), debug, argc0, argv0, proc_id);
- if (!debug && daemon(0, 0) == -1)
- err(1, "failed to daemonize");
log_procinit("parent");
log_info("startup");