提交 06af6609 编写于 作者: M Michal Privoznik

virSecurityDACTransactionRun: Implement rollback

When iterating over list of paths/disk sources to relabel it may
happen that the process fails at some point. In that case, for
the sake of keeping seclabel refcount (stored in XATTRs) in sync
with reality we have to perform rollback. However, if that fails
too the only thing we can do is warn user.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 86def3c8
...@@ -229,7 +229,6 @@ virSecurityDACTransactionRun(pid_t pid ATTRIBUTE_UNUSED, ...@@ -229,7 +229,6 @@ virSecurityDACTransactionRun(pid_t pid ATTRIBUTE_UNUSED,
for (i = 0; i < list->nItems; i++) { for (i = 0; i < list->nItems; i++) {
virSecurityDACChownItemPtr item = list->items[i]; virSecurityDACChownItemPtr item = list->items[i];
/* TODO Implement rollback */
if (!item->restore) { if (!item->restore) {
rv = virSecurityDACSetOwnership(list->manager, rv = virSecurityDACSetOwnership(list->manager,
item->src, item->src,
...@@ -246,6 +245,19 @@ virSecurityDACTransactionRun(pid_t pid ATTRIBUTE_UNUSED, ...@@ -246,6 +245,19 @@ virSecurityDACTransactionRun(pid_t pid ATTRIBUTE_UNUSED,
break; break;
} }
for (; rv < 0 && i > 0; i--) {
virSecurityDACChownItemPtr item = list->items[i - 1];
if (!item->restore) {
virSecurityDACRestoreFileLabelInternal(list->manager,
item->src,
item->path);
} else {
VIR_WARN("Ignoring failed restore attempt on %s",
NULLSTR(item->src ? item->src->path : item->path));
}
}
if (list->lock) if (list->lock)
virSecurityManagerMetadataUnlock(list->manager, &state); virSecurityManagerMetadataUnlock(list->manager, &state);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册