From bf949ae69e139767ee5bb4b518d99fdb93037dd2 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 19 Aug 2018 12:31:41 +0000 Subject: Call daemon with 0 as first argument so that it changes the cwd to /. It is not a problem in slowcgi since it calls chroot(2) and then chdir(2) shortly afterwards but hopefully prevents copying code into daemons where it does matter. Problem first observed by dlg in ntpd(8) which keeps sitting in the directory from where it was started which might for example prevent an unmount. Discussed with deraadt@ --- slowcgi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'slowcgi.c') diff --git a/slowcgi.c b/slowcgi.c index 8d8c970..696af72 100644 --- a/slowcgi.c +++ b/slowcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slowcgi.c,v 1.53 2018/08/13 16:54:50 florian Exp $ */ +/* $OpenBSD: slowcgi.c,v 1.54 2018/08/19 12:31:41 florian Exp $ */ /* * Copyright (c) 2013 David Gwynne * Copyright (c) 2013 Florian Obser @@ -323,7 +323,7 @@ main(int argc, char *argv[]) if (geteuid() != 0) errx(1, "need root privileges"); - if (!debug && daemon(1, 0) == -1) + if (!debug && daemon(0, 0) == -1) err(1, "daemon"); if (!debug) { -- cgit v1.2.3-2-gb3c3