]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virFileRewrite: Allow setting owner
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 9 Feb 2022 11:22:00 +0000 (12:22 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 11 Feb 2022 12:16:40 +0000 (13:16 +0100)
commit04ed2518501a9de96e08fca3147d1a8a3cdd6776
tree338f96a1c8f853b93def53b5d6f2cba6669b3f88
parent70f8299285fac1533153832f47711fa1f0dbd3b6
virFileRewrite: Allow setting owner

Currently, due to the way virFileRewrite() works, the rewritten
file is owned by user and group that the daemon runs under. So
far, this is not a problem, because the function is used to write
XML files or secrets for persistent objects (domains, networks,
etc.) and we don't need other users to read/write those files.

But shortly, this function is going to be used for creating files
for QEMU domains. There we want the QEMU process (i.e. different
user) to read the file.

Therefore, introduce two new arguments: @uid and @gid that allow
setting desired owner of the file. Pass -1 to preserve current
behaviour (i.e. create the file owned by the user running the
daemon).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/util/virfile.c
src/util/virfile.h
src/util/virxml.c