]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
daemon: Change CWD to / before daemonizing
authorJiri Denemark <jdenemar@redhat.com>
Mon, 13 Dec 2010 10:18:45 +0000 (11:18 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 14 Dec 2010 09:53:35 +0000 (10:53 +0100)
We were doing so for child processes but not for libvirtd itself.

daemon/libvirtd.c

index 14777dd94adfe9a3bdeeedafa816e83bf904071d..2df93372791441ed5aa010a2d0beec31eadfe5b6 100644 (file)
@@ -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));