mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
security: add MANAGER_MOUNT_NAMESPACE flag
The VIR_SECURITY_MANAGER_MOUNT_NAMESPACE flag informs the DAC driver if mount namespaces are in use for the VM. Will be used for future changes. Wire it up in the qemu driver
This commit is contained in:
parent
239781e03a
commit
321031e482
@ -419,6 +419,8 @@ qemuSecurityInit(virQEMUDriverPtr driver)
|
||||
if (virQEMUDriverIsPrivileged(driver)) {
|
||||
if (cfg->dynamicOwnership)
|
||||
flags |= VIR_SECURITY_MANAGER_DYNAMIC_OWNERSHIP;
|
||||
if (virBitmapIsBitSet(cfg->namespaces, QEMU_DOMAIN_NS_MOUNT))
|
||||
flags |= VIR_SECURITY_MANAGER_MOUNT_NAMESPACE;
|
||||
if (!(mgr = qemuSecurityNewDAC(QEMU_DRIVER_NAME,
|
||||
cfg->user,
|
||||
cfg->group,
|
||||
|
@ -57,6 +57,7 @@ struct _virSecurityDACData {
|
||||
gid_t *groups;
|
||||
int ngroups;
|
||||
bool dynamicOwnership;
|
||||
bool mountNamespace;
|
||||
char *baselabel;
|
||||
virSecurityManagerDACChownCallback chownCallback;
|
||||
};
|
||||
@ -237,6 +238,15 @@ virSecurityDACSetDynamicOwnership(virSecurityManagerPtr mgr,
|
||||
priv->dynamicOwnership = dynamicOwnership;
|
||||
}
|
||||
|
||||
void
|
||||
virSecurityDACSetMountNamespace(virSecurityManagerPtr mgr,
|
||||
bool mountNamespace)
|
||||
{
|
||||
virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
|
||||
priv->mountNamespace = mountNamespace;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virSecurityDACSetChownCallback(virSecurityManagerPtr mgr,
|
||||
virSecurityManagerDACChownCallback chownCallback)
|
||||
|
@ -32,6 +32,9 @@ int virSecurityDACSetUserAndGroup(virSecurityManagerPtr mgr,
|
||||
void virSecurityDACSetDynamicOwnership(virSecurityManagerPtr mgr,
|
||||
bool dynamic);
|
||||
|
||||
void virSecurityDACSetMountNamespace(virSecurityManagerPtr mgr,
|
||||
bool mountNamespace);
|
||||
|
||||
void virSecurityDACSetChownCallback(virSecurityManagerPtr mgr,
|
||||
virSecurityManagerDACChownCallback chownCallback);
|
||||
|
||||
|
@ -146,7 +146,8 @@ virSecurityManagerNewDAC(const char *virtDriver,
|
||||
virSecurityManagerPtr mgr;
|
||||
|
||||
virCheckFlags(VIR_SECURITY_MANAGER_NEW_MASK |
|
||||
VIR_SECURITY_MANAGER_DYNAMIC_OWNERSHIP, NULL);
|
||||
VIR_SECURITY_MANAGER_DYNAMIC_OWNERSHIP |
|
||||
VIR_SECURITY_MANAGER_MOUNT_NAMESPACE, NULL);
|
||||
|
||||
mgr = virSecurityManagerNewDriver(&virSecurityDriverDAC,
|
||||
virtDriver,
|
||||
@ -161,6 +162,7 @@ virSecurityManagerNewDAC(const char *virtDriver,
|
||||
}
|
||||
|
||||
virSecurityDACSetDynamicOwnership(mgr, flags & VIR_SECURITY_MANAGER_DYNAMIC_OWNERSHIP);
|
||||
virSecurityDACSetMountNamespace(mgr, flags & VIR_SECURITY_MANAGER_MOUNT_NAMESPACE);
|
||||
virSecurityDACSetChownCallback(mgr, chownCallback);
|
||||
|
||||
return mgr;
|
||||
|
@ -36,6 +36,7 @@ typedef enum {
|
||||
VIR_SECURITY_MANAGER_REQUIRE_CONFINED = 1 << 2,
|
||||
VIR_SECURITY_MANAGER_PRIVILEGED = 1 << 3,
|
||||
VIR_SECURITY_MANAGER_DYNAMIC_OWNERSHIP = 1 << 4,
|
||||
VIR_SECURITY_MANAGER_MOUNT_NAMESPACE = 1 << 5,
|
||||
} virSecurityManagerNewFlags;
|
||||
|
||||
# define VIR_SECURITY_MANAGER_NEW_MASK \
|
||||
|
Loading…
Reference in New Issue
Block a user