Add umask to _virCommand, allow user to set umask to command.
Set umask(002) to qemu process to overwrite the default umask
of 022 set by many distros, so that unix sockets created for
virtio-serial has expected permissions.
Fix problem reported here:
https://sourceware.org/bugzilla/show_bug.cgi?id=13078#c11
https://bugzilla.novell.com/show_bug.cgi?id=888166
To use virtio-serial device, unix socket created for chardev with
default umask(022) has insufficient permissions.
e.g.:
-device virtio-serial \
-chardev socket,path=/tmp/foo,server,nowait,id=foo \
-device virtserialport,chardev=foo,name=org.fedoraproject.port.0
srwxr-xr-x 1 qemu qemu 0 21. Jul 14:19 /tmp/somefile.sock
Other users in the same group (like real user, test engines, etc)
cannot write to this socket.
Signed-off-by: Chunyan Liu <cyliu@suse.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
virCommandSetPreExecHook;
virCommandSetSELinuxLabel;
virCommandSetUID;
+virCommandSetUmask;
virCommandSetWorkingDirectory;
virCommandToString;
virCommandWait;
virCommandSetPreExecHook(cmd, qemuProcessHook, &hookData);
virCommandSetMaxProcesses(cmd, cfg->maxProcesses);
virCommandSetMaxFiles(cmd, cfg->maxFiles);
+ virCommandSetUmask(cmd, 0x002);
VIR_DEBUG("Setting up security labelling");
if (virSecurityManagerSetChildProcessLabel(driver->securityManager,
#if defined(WITH_SECDRIVER_APPARMOR)
char *appArmorProfile;
#endif
+ int umask;
};
/* See virCommandSetDryRun for description for this variable */
/* child */
+ if (cmd->umask)
+ umask(cmd->umask);
ret = EXIT_CANCELED;
openmax = sysconf(_SC_OPEN_MAX);
if (openmax < 0) {
cmd->maxFiles = files;
}
+void virCommandSetUmask(virCommandPtr cmd, int umask)
+{
+ if (!cmd || cmd->has_error)
+ return;
+
+ cmd->umask = umask;
+}
+
/**
* virCommandClearCaps:
* @cmd: the command to modify
void virCommandSetMaxMemLock(virCommandPtr cmd, unsigned long long bytes);
void virCommandSetMaxProcesses(virCommandPtr cmd, unsigned int procs);
void virCommandSetMaxFiles(virCommandPtr cmd, unsigned int files);
+void virCommandSetUmask(virCommandPtr cmd, int umask);
void virCommandClearCaps(virCommandPtr cmd);