diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index f7f90cd656..05efdbc9bf 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -272,7 +272,6 @@ virSecuritySELinuxTransactionRun(pid_t pid ATTRIBUTE_UNUSED, for (i = 0; i < list->nItems; i++) { virSecuritySELinuxContextItemPtr item = list->items[i]; - /* TODO Implement rollback */ if (!item->restore) { rv = virSecuritySELinuxSetFileconHelper(list->manager, item->path, @@ -289,6 +288,18 @@ virSecuritySELinuxTransactionRun(pid_t pid ATTRIBUTE_UNUSED, break; } + for (; rv < 0 && i > 0; i--) { + virSecuritySELinuxContextItemPtr item = list->items[i - 1]; + + if (!item->restore) { + virSecuritySELinuxRestoreFileLabel(list->manager, + item->path, + list->lock); + } else { + VIR_WARN("Ignoring failed restore attempt on %s", item->path); + } + } + if (list->lock) virSecurityManagerMetadataUnlock(list->manager, &state);