diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index 378c553f0c..b8f907aee1 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -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; diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c index 38d02acfa2..8a7d7e5314 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -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));