]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commit
util: maintain caps when running command with uid != 0
authorLaine Stump <laine@laine.org>
Thu, 7 Feb 2013 16:45:27 +0000 (11:45 -0500)
committerLaine Stump <laine@laine.org>
Wed, 13 Feb 2013 21:11:16 +0000 (16:11 -0500)
commit7a2e845a865dc7fa82d2393ea2a770cfc8cf00b4
tree132221e44213fab669b642ffcb3e36a569b3cfe4
parente11451f42e6590cd4124a8807910bf4463f6b3a2
util: maintain caps when running command with uid != 0

virCommand was previously calling virSetUIDGID() to change the uid and
gid of the child process, then separately calling
virSetCapabilities(). This did not work if the desired uid was != 0,
since a setuid to anything other than 0 normally clears all
capabilities bits.

The solution is to use the new virSetUIDGIDWithCaps(), sending it the
uid, gid, and capabilities bits. This will get the new process setup
properly.

Since the static functions virSetCapabilities() and
virClearCapabilities are no longer called, they have been removed.

NOTE: When combined with "filecap $path-to-qemu sys_rawio", this patch
will make CAP_SYS_RAWIO (which is required for passthrough of generic
scsi commands to a guest - see commits e8daeeb177db08397e6a7, and
74e0349) be retained by qemu when necessary. Apparently that
capability has been broken for non-root qemu ever since it was
originally added.
src/util/vircommand.c