mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
security_selinux: Add SetDirLabel support
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> (cherry picked from commit 3f48345f7ec0c44b8ce2371cab454d2118f830b4)
This commit is contained in:
parent
5290876dbc
commit
82dce08750
@ -2506,6 +2506,21 @@ virSecuritySELinuxGetSecurityMountOptions(virSecurityManagerPtr mgr,
|
||||
return opts;
|
||||
}
|
||||
|
||||
static char *
|
||||
virSecuritySELinuxDomainSetDirLabel(virSecurityManagerPtr mgr,
|
||||
virDomainDefPtr def,
|
||||
const char *path)
|
||||
{
|
||||
virSecurityLabelDefPtr seclabel;
|
||||
int ret = -1;
|
||||
|
||||
seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME);
|
||||
if (!seclabel || !seclabel->relabel)
|
||||
return 0;
|
||||
|
||||
return virSecuritySELinuxSetFilecon(path, seclabel->imagelabel);
|
||||
}
|
||||
|
||||
virSecurityDriver virSecurityDriverSELinux = {
|
||||
.privateDataLen = sizeof(virSecuritySELinuxData),
|
||||
.name = SECURITY_SELINUX_NAME,
|
||||
@ -2550,4 +2565,6 @@ virSecurityDriver virSecurityDriverSELinux = {
|
||||
|
||||
.domainGetSecurityMountOptions = virSecuritySELinuxGetSecurityMountOptions,
|
||||
.getBaseLabel = virSecuritySELinuxGetBaseLabel,
|
||||
|
||||
.domainSetDirLabel = virSecuritySELinuxDomainSetDirLabel,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user