On 07/08/14 00:55, Eric Blake wrote:
On 07/04/2014 05:29 AM, Peter Krempa wrote:
> Add backends for this frontend function so that we can use it in the
> snapshot creation code.
> ---
> src/storage/storage_backend_fs.c | 17 +++++++++++++++++
> src/storage/storage_backend_gluster.c | 28 ++++++++++++++++++++++++++++
> 2 files changed, 45 insertions(+)
>
> static int
> +virStorageFileBackendGlusterCreate(virStorageSourcePtr src)
> +{
> + virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
> + glfs_fd_t *fd = NULL;
> + int save_errno;
> + int ret = -1;
> +
> + if (!(fd = glfs_open(priv->vol, src->path, O_CREAT | O_TRUNC |
O_WRONLY)))
> + return -1;
> +
> + if (src->drv->uid != 0 || src->drv->gid != 0) {
Isn't our sentinel value -1 for default? I think that comparison against
0 is likely to be wrong for running qemu:///session.
ACK with this change:
if (src->drv->uid != (uid_t)-1 || src->drv->gid != (gid_t)-1) {
Actually the init code changes the sentinel value -1 to the actual uid,
so what I wanted for this condition is:
if (src->drv->uid != getuid() || ..
.. or possibly geteuid, I'll have to look up whether gluster uses the
effective uid, or the actual uid.
Additionally as a non-root cannot give up ownership of a file, we should
probably make it a little stricter and not call it if get(e)uid() isn't
root.
Peter