mirror of https://gitee.com/openkylin/libvirt.git
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 185e07a5f8
.
This commit is contained in:
parent
1281f4a100
commit
f8cf4962ac
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue