diff --git a/qemud/qemud.c b/qemud/qemud.c index 6534ec3..9e37811 100644 --- a/qemud/qemud.c +++ b/qemud/qemud.c @@ -1899,6 +1899,9 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename) { virConfPtr conf; + char sockdirname[PATH_MAX]; + struct stat statbuf; + /* The following variable names must match the corresponding configuration strings. */ char *unix_sock_ro_perms = NULL; @@ -1974,6 +1977,21 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename) unix_sock_rw_perms = NULL; } + if (snprintf(sockdirname, PATH_MAX, "%s/run/libvirt", + LOCAL_STATE_DIR) >= PATH_MAX) + qemudLog(QEMUD_ERR, "%s remoteReadConfigFile()", + _("Resulting path too long for buffer in")); + if (chown(sockdirname, -1, unix_sock_gid) < 0) + qemudLog(QEMUD_ERR, "%s %s", _("Failed to change group of"), sockdirname); + + if (stat(sockdirname, &statbuf) < 0) + qemudLog(QEMUD_ERR, "%s %s", _("Failed to get statistics on"), sockdirname); + if (chmod(sockdirname, + (unix_sock_gid) + ? (statbuf.st_mode | S_IXGRP) + : (statbuf.st_mode & ~S_IXGRP)) < 0) + qemudLog(QEMUD_ERR, "%s %s", _("Failed to change permissions on"), sockdirname); + GET_CONF_INT (conf, filename, mdns_adv); GET_CONF_STR (conf, filename, mdns_name);