提交 0f1993aa 编写于 作者: J Jim Fehlig

Don't autogenerate seclabels of type 'none'

When security drivers are active but confinement is not enabled,
there is no need to autogenerate <seclabel> elements when starting
a domain def that contains no <seclabel> elements. In fact,
autogenerating the elements can result in needless save/restore and
migration failures when the security driver is not active on the
restore/migration target.

This patch changes the virSecurityManagerGenLabel function in
src/security_manager.c to only autogenerate a <seclabel> element
if none is already defined for the domain *and* default
confinement is enabled. Otherwise the needless <seclabel>
autogeneration is skipped.

Resolves: https://bugzilla.opensuse.org/show_bug.cgi?id=1051017
上级 ff7e0a1a
...@@ -650,31 +650,33 @@ virSecurityManagerGenLabel(virSecurityManagerPtr mgr, ...@@ -650,31 +650,33 @@ virSecurityManagerGenLabel(virSecurityManagerPtr mgr,
for (i = 0; sec_managers[i]; i++) { for (i = 0; sec_managers[i]; i++) {
generated = false; generated = false;
seclabel = virDomainDefGetSecurityLabelDef(vm, sec_managers[i]->drv->name); seclabel = virDomainDefGetSecurityLabelDef(vm, sec_managers[i]->drv->name);
if (!seclabel) { if (seclabel == NULL) {
if (!(seclabel = virSecurityLabelDefNew(sec_managers[i]->drv->name))) /* Only generate seclabel if confinement is enabled */
goto cleanup; if (!virSecurityManagerGetDefaultConfined(sec_managers[i])) {
generated = seclabel->implicit = true; VIR_DEBUG("Skipping auto generated seclabel");
} continue;
if (seclabel->type == VIR_DOMAIN_SECLABEL_DEFAULT) {
if (virSecurityManagerGetDefaultConfined(sec_managers[i])) {
seclabel->type = VIR_DOMAIN_SECLABEL_DYNAMIC;
} else { } else {
seclabel->type = VIR_DOMAIN_SECLABEL_NONE; if (!(seclabel = virSecurityLabelDefNew(sec_managers[i]->drv->name)))
seclabel->relabel = false; goto cleanup;
generated = seclabel->implicit = true;
seclabel->type = VIR_DOMAIN_SECLABEL_DYNAMIC;
}
} else {
if (seclabel->type == VIR_DOMAIN_SECLABEL_DEFAULT) {
if (virSecurityManagerGetDefaultConfined(sec_managers[i])) {
seclabel->type = VIR_DOMAIN_SECLABEL_DYNAMIC;
} else {
seclabel->type = VIR_DOMAIN_SECLABEL_NONE;
seclabel->relabel = false;
}
} }
}
if (seclabel->type == VIR_DOMAIN_SECLABEL_NONE) { if (seclabel->type == VIR_DOMAIN_SECLABEL_NONE) {
if (virSecurityManagerGetRequireConfined(sec_managers[i])) { if (virSecurityManagerGetRequireConfined(sec_managers[i])) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Unconfined guests are not allowed on this host")); _("Unconfined guests are not allowed on this host"));
goto cleanup; goto cleanup;
} else if (vm->nseclabels && generated) { }
VIR_DEBUG("Skipping auto generated seclabel of type none");
virSecurityLabelDefFree(seclabel);
seclabel = NULL;
continue;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册