1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

storage: create: Create files with correct mode

Use correct mode when pre-creating files (for snapshots). The refactor
changing to storage driver usage caused a regression as some systems
created the file with 000 permissions forbidding qemu to write the file.

Pass mode to the creating functions to avoid the problem.

Regression since 185e07a5f82bc0692324f3ee13b4816d71b653c1.
This commit is contained in:
Peter Krempa 2014-07-28 16:09:39 +02:00
parent 1281f4a100
commit f8cf4962ac
2 changed files with 11 additions and 2 deletions

View File

@ -1390,8 +1390,12 @@ static int
virStorageFileBackendFileCreate(virStorageSourcePtr src)
{
int fd = -1;
mode_t mode = S_IRUSR;
if ((fd = virFileOpenAs(src->path, O_WRONLY | O_TRUNC | O_CREAT, 0,
if (!src->readonly)
mode |= S_IWUSR;
if ((fd = virFileOpenAs(src->path, O_WRONLY | O_TRUNC | O_CREAT, mode,
src->drv->uid, src->drv->gid, 0)) < 0) {
errno = -fd;
return -1;

View File

@ -638,8 +638,13 @@ virStorageFileBackendGlusterCreate(virStorageSourcePtr src)
{
virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
glfs_fd_t *fd = NULL;
mode_t mode = S_IRUSR;
if (!(fd = glfs_open(priv->vol, src->path, O_CREAT | O_TRUNC | O_WRONLY)))
if (!src->readonly)
mode |= S_IWUSR;
if (!(fd = glfs_creat(priv->vol, src->path,
O_CREAT | O_TRUNC | O_WRONLY, mode)))
return -1;
ignore_value(glfs_close(fd));