mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Make sure the rundir is accessible by the user
otherwise the user might not have enough permissions to access the socket if root's umask is 077. http://bugs.debian.org/614210
This commit is contained in:
parent
9189301426
commit
24bfa52e93
@ -3277,16 +3277,20 @@ int main(int argc, char **argv) {
|
|||||||
/* Ensure the rundir exists (on tmpfs on some systems) */
|
/* Ensure the rundir exists (on tmpfs on some systems) */
|
||||||
if (geteuid() == 0) {
|
if (geteuid() == 0) {
|
||||||
const char *rundir = LOCALSTATEDIR "/run/libvirt";
|
const char *rundir = LOCALSTATEDIR "/run/libvirt";
|
||||||
|
mode_t old_umask;
|
||||||
|
|
||||||
|
old_umask = umask(022);
|
||||||
if (mkdir (rundir, 0755)) {
|
if (mkdir (rundir, 0755)) {
|
||||||
if (errno != EEXIST) {
|
if (errno != EEXIST) {
|
||||||
char ebuf[1024];
|
char ebuf[1024];
|
||||||
VIR_ERROR(_("unable to create rundir %s: %s"), rundir,
|
VIR_ERROR(_("unable to create rundir %s: %s"), rundir,
|
||||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||||
ret = VIR_DAEMON_ERR_RUNDIR;
|
ret = VIR_DAEMON_ERR_RUNDIR;
|
||||||
|
umask(old_umask);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
umask(old_umask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Beyond this point, nothing should rely on using
|
/* Beyond this point, nothing should rely on using
|
||||||
|
Loading…
Reference in New Issue
Block a user