]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: only fchown newly created files in virFileOpenAs
authorLaine Stump <laine@laine.org>
Wed, 24 Aug 2011 08:50:49 +0000 (04:50 -0400)
committerLaine Stump <laine@laine.org>
Wed, 24 Aug 2011 19:32:00 +0000 (15:32 -0400)
commitb1643dc15c5de886fefe56ad18608d65f1325a2c
tree08df0cb6ddbc657ccbb85404494bb9522cdd99c2
parent7ae740fcb1df941a3dfef31c0993d9d1128845f4
util: only fchown newly created files in virFileOpenAs

virFileOpenAs takes desired uid:gid as arguments, and not only uses
them for a fork/setuid/setgid when retrying failed open operations,
but additionally always forces the opened file to be owned by the
given uid:gid.

One example of the problems this causes is that, when restoring a
domain from a file that is owned by the qemu user, opening the file
chowns it to root. if dynamic_ownership=1 this is coincidentally
expected, but if dynamic_ownership=0, no existing file should ever
have its ownership changed.

This patch adds an extra check before calling fchown() - it only does
it if O_CREAT was passed to virFileOpenAs() in the openflags.
src/util/util.c