diff --git a/ChangeLog b/ChangeLog index 3ae0f8b126..1ebbb6c031 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Feb 14 17:01:24 EST 2007 Daniel P. Berrange + + * qemud/qemud.c: Ensure we create the main libvirt config + directory at startup + Wed Feb 14 16:47:24 EST 2007 Daniel P. Berrange * qemud/conf.c: Fixed generation of block, and diff --git a/qemud/qemud.c b/qemud/qemud.c index 5cc89b9c93..17c0e8ce03 100644 --- a/qemud/qemud.c +++ b/qemud/qemud.c @@ -239,6 +239,7 @@ static int qemudListen(struct qemud_server *server, int sys) { static struct qemud_server *qemudInitialize(int sys) { struct qemud_server *server; + char libvirtConf[PATH_MAX]; if (!(server = calloc(1, sizeof(struct qemud_server)))) return NULL; @@ -249,6 +250,15 @@ static struct qemud_server *qemudInitialize(int sys) { server->nextvmid = 1; if (sys) { + if (snprintf(libvirtConf, sizeof(libvirtConf), "%s/libvirt", SYSCONF_DIR) >= (int)sizeof(libvirtConf)) { + goto cleanup; + } + if (mkdir(libvirtConf, 0777) < 0) { + if (errno != EEXIST) { + goto cleanup; + } + } + if (snprintf(server->configDir, sizeof(server->configDir), "%s/libvirt/qemu", SYSCONF_DIR) >= (int)sizeof(server->configDir)) { goto cleanup; } @@ -258,6 +268,7 @@ static struct qemud_server *qemudInitialize(int sys) { } else { struct passwd *pw; int uid; + if ((uid = geteuid()) < 0) { goto cleanup; } @@ -265,6 +276,16 @@ static struct qemud_server *qemudInitialize(int sys) { goto cleanup; } + if (snprintf(libvirtConf, sizeof(libvirtConf), "%s/.libvirt", pw->pw_dir) >= (int)sizeof(libvirtConf)) { + goto cleanup; + } + if (mkdir(libvirtConf, 0777) < 0) { + if (errno != EEXIST) { + goto cleanup; + } + } + + if (snprintf(server->configDir, sizeof(server->configDir), "%s/.libvirt/qemu", pw->pw_dir) >= (int)sizeof(server->configDir)) { goto cleanup; }