summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd
diff options
context:
space:
mode:
authorTobias Heider <tobhe@cvs.openbsd.org>2024-04-08 12:45:19 +0000
committerTobias Heider <tobhe@cvs.openbsd.org>2024-04-08 12:45:19 +0000
commit29b3d1525506818c0263d36cf66211c739f57abe (patch)
tree9fae86561a30cb6e27c80983e60d53f3c5a9247e /usr.sbin/httpd
parentca06152c6f01c7b6634e95fdd330e645f71904ed (diff)
Call daemon() only in parent and before proc_exec() to avoid orphaning child
processes. Synced from relayd. ok kn@
Diffstat (limited to 'usr.sbin/httpd')
-rw-r--r--usr.sbin/httpd/httpd.c4
-rw-r--r--usr.sbin/httpd/proc.c5
2 files changed, 5 insertions, 4 deletions
diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c
index af863cf2710..686f41c88d0 100644
--- a/usr.sbin/httpd/httpd.c
+++ b/usr.sbin/httpd/httpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.c,v 1.73 2022/09/02 07:38:14 benno Exp $ */
+/* $OpenBSD: httpd.c,v 1.74 2024/04/08 12:45:18 tobhe Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -220,8 +220,6 @@ main(int argc, char *argv[])
proc_init(ps, procs, nitems(procs), debug, argc0, argv, proc_id);
log_procinit("parent");
- if (!debug && daemon(1, 0) == -1)
- err(1, "failed to daemonize");
if (ps->ps_noaction == 0)
log_info("startup");
diff --git a/usr.sbin/httpd/proc.c b/usr.sbin/httpd/proc.c
index e8b08dd2317..58ea14cc09b 100644
--- a/usr.sbin/httpd/proc.c
+++ b/usr.sbin/httpd/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.43 2024/01/17 08:22:40 claudio Exp $ */
+/* $OpenBSD: proc.c,v 1.44 2024/04/08 12:45:18 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(1, 0) == -1)
+ fatal("failed to daemonize");
+
/*
* Create the children sockets so we can use them
* to distribute the rest of the socketpair()s using