From: Jiri Denemark Date: Mon, 13 Dec 2010 10:18:45 +0000 (+0100) Subject: daemon: Change CWD to / before daemonizing X-Git-Tag: v0.8.7~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99800e54b7d876eeba98a1a7e70cac35848bd97c;p=thirdparty%2Flibvirt.git daemon: Change CWD to / before daemonizing We were doing so for child processes but not for libvirtd itself. --- diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 14777dd94a..2df9337279 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -3175,6 +3175,13 @@ int main(int argc, char **argv) { if (godaemon) { char ebuf[1024]; + + if (chdir("/") < 0) { + VIR_ERROR(_("cannot change to root directory: %s"), + virStrerror(errno, ebuf, sizeof(ebuf))); + goto error; + } + if ((statuswrite = daemonForkIntoBackground()) < 0) { VIR_ERROR(_("Failed to fork as daemon: %s"), virStrerror(errno, ebuf, sizeof ebuf));