[PATCH v2 04/10] security: implement domainUpdateSecurityImageLabel for DAC

Peng Liang posted 10 patches 1 month, 2 weeks ago

[PATCH v2 04/10] security: implement domainUpdateSecurityImageLabel for DAC

Posted by Peng Liang 1 month, 2 weeks ago
Signed-off-by: Peng Liang <liangpeng10@huawei.com>
---
 src/security/security_dac.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 1733d63410b3..d1e1552bb683 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -1132,6 +1132,23 @@ virSecurityDACMoveImageMetadata(virSecurityManager *mgr,
 }
 
 
+static int
+virSecurityDACUpdateImageLabel(virSecurityManager *mgr G_GNUC_UNUSED,
+                               virDomainDef *def G_GNUC_UNUSED,
+                               virStorageSource *src,
+                               virSecurityDomainImageLabelFlags flags G_GNUC_UNUSED)
+{
+    virStorageSource *n;
+
+    for (n = src; virStorageSourceIsBacking(n); n = n->backingStore) {
+        if (virSecurityUpdateTimestampIfexists(SECURITY_DAC_NAME, src->path) < 0)
+            return -1;
+    }
+
+    return 0;
+}
+
+
 static int
 virSecurityDACSetHostdevLabelHelper(const char *file,
                                     bool remember,
@@ -2539,6 +2556,7 @@ virSecurityDriver virSecurityDriverDAC = {
     .domainSetSecurityImageLabel        = virSecurityDACSetImageLabel,
     .domainRestoreSecurityImageLabel    = virSecurityDACRestoreImageLabel,
     .domainMoveImageMetadata            = virSecurityDACMoveImageMetadata,
+    .domainUpdateSecurityImageLabel     = virSecurityDACUpdateImageLabel,
 
     .domainSetSecurityMemoryLabel       = virSecurityDACSetMemoryLabel,
     .domainRestoreSecurityMemoryLabel   = virSecurityDACRestoreMemoryLabel,
-- 
2.31.1