1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

Fix initialization order bugs

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
This commit is contained in:
Daniel P. Berrange 2009-10-16 11:29:01 +01:00
parent 0264e1678c
commit 5f67253813

View File

@ -700,9 +700,15 @@ static int qemudInitPaths(struct qemud_server *server,
int ret = -1; int ret = -1;
char *sock_dir_prefix = NULL; char *sock_dir_prefix = NULL;
if (unix_sock_dir) if (unix_sock_dir) {
sock_dir = 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; sock_dir = sockname;
if (server->privileged) { if (server->privileged) {
dir_prefix = strdup (LOCAL_STATE_DIR); dir_prefix = strdup (LOCAL_STATE_DIR);
@ -797,8 +803,6 @@ static struct qemud_server *qemudInitialize(int sigread) {
return NULL; return NULL;
} }
virInitialize();
/* /*
* Note that the order is important: the first ones have a higher * Note that the order is important: the first ones have a higher
* priority when calling virStateInitialize. We must register * priority when calling virStateInitialize. We must register
@ -2847,6 +2851,8 @@ int main(int argc, char **argv) {
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
virInitialize();
while (1) { while (1) {
int optidx = 0; int optidx = 0;
int c; int c;
@ -2989,13 +2995,6 @@ int main(int argc, char **argv) {
if (remoteReadConfigFile (server, remote_config_file) < 0) if (remoteReadConfigFile (server, remote_config_file) < 0)
goto error2; 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], if (virEventAddHandleImpl(sigpipe[0],
VIR_EVENT_HANDLE_READABLE, VIR_EVENT_HANDLE_READABLE,
qemudDispatchSignalEvent, qemudDispatchSignalEvent,