mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Pre-create the toplevel libvirt config directory
This commit is contained in:
parent
31ea5e9733
commit
6ad5b9d5fb
@ -1,3 +1,8 @@
|
||||
Wed Feb 14 17:01:24 EST 2007 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* qemud/qemud.c: Ensure we create the main libvirt config
|
||||
directory at startup
|
||||
|
||||
Wed Feb 14 16:47:24 EST 2007 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* qemud/conf.c: Fixed generation of <features> block, and
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user