[libvirt] [PATCH 07/21] Fix initialization order bugs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



virInitialize must be the first libvirt function called to ensure
threads, error handling & random number generator are all setup.

Move UNIX socket directory permissions change to place of use
---
 daemon/libvirtd.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index db151cd..252d527 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -700,9 +700,15 @@ static int qemudInitPaths(struct qemud_server *server,
     int ret = -1;
     char *sock_dir_prefix = NULL;
 
-    if (unix_sock_dir)
+    if (unix_sock_dir) {
         sock_dir = unix_sock_dir;
-    else {
+        /* Change the group ownership of /var/run/libvirt to unix_sock_gid */
+        if (server->privileged) {
+            if (chown(unix_sock_dir, -1, unix_sock_gid) < 0)
+                VIR_ERROR(_("Failed to change group ownership of %s"),
+                          unix_sock_dir);
+        }
+    } else {
         sock_dir = sockname;
         if (server->privileged) {
             dir_prefix = strdup (LOCAL_STATE_DIR);
@@ -797,8 +803,6 @@ static struct qemud_server *qemudInitialize(int sigread) {
         return NULL;
     }
 
-    virInitialize();
-
     /*
      * Note that the order is important: the first ones have a higher
      * priority when calling virStateInitialize. We must register
@@ -2848,6 +2852,8 @@ int main(int argc, char **argv) {
         {0, 0, 0, 0}
     };
 
+    virInitialize();
+
     while (1) {
         int optidx = 0;
         int c;
@@ -2988,13 +2994,6 @@ int main(int argc, char **argv) {
     if (remoteReadConfigFile (server, remote_config_file) < 0)
         goto error2;
 
-    /* Change the group ownership of /var/run/libvirt to unix_sock_gid */
-    if (unix_sock_dir && server->privileged) {
-        if (chown(unix_sock_dir, -1, unix_sock_gid) < 0)
-            VIR_ERROR(_("Failed to change group ownership of %s"),
-                      unix_sock_dir);
-    }
-
     if (virEventAddHandleImpl(sigpipe[0],
                               VIR_EVENT_HANDLE_READABLE,
                               qemudDispatchSignalEvent,
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]