]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virSetUIDGIDWithCaps: Assume PR_CAPBSET_DROP is always defined
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 24 Jun 2021 14:58:53 +0000 (16:58 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 1 Jul 2021 14:41:50 +0000 (16:41 +0200)
Bounding set capabilities were introduced in kernel commit of
v2.6.25-rc1~912. I guess it is safe to assume that all Linux
hosts we ran on have at least that version or newer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/util/virutil.c

index 199d4052864e818d1f2f243ab43dc6245e51de00..ed3d57662b2f754e09f4539c5902592a252c398c 100644 (file)
@@ -1182,13 +1182,12 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups,
         need_setuid = true;
         capng_update(CAPNG_ADD, CAPNG_EFFECTIVE|CAPNG_PERMITTED, CAP_SETUID);
     }
-# ifdef PR_CAPBSET_DROP
-    /* If newer kernel, we need also need setpcap to change the bounding set */
+
+    /* We need also need setpcap to change the bounding set */
     if (!capng_have_capability(CAPNG_EFFECTIVE, CAP_SETPCAP)) {
         need_setpcap = true;
         capng_update(CAPNG_ADD, CAPNG_EFFECTIVE|CAPNG_PERMITTED, CAP_SETPCAP);
     }
-# endif
 
     /* Tell system we want to keep caps across uid change */
     if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0)) {