]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
security: Try to lock only paths with remember == true
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 1 Oct 2019 08:30:05 +0000 (10:30 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 11 Oct 2019 15:01:08 +0000 (17:01 +0200)
So far all items on the chown/setfilecon list have the same
.remember value.  But this will change shortly. Therefore, don't
try to lock paths which we won't manipulate XATTRs for.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
src/security/security_dac.c
src/security/security_selinux.c

index 4b4afef18a26ab7d9a446882f5a7c4f12107d31b..5df50bdcf5fabc3ba528cc609039c7e5cb162d78 100644 (file)
@@ -232,9 +232,11 @@ virSecurityDACTransactionRun(pid_t pid ATTRIBUTE_UNUSED,
             return -1;
 
         for (i = 0; i < list->nItems; i++) {
-            const char *p = list->items[i]->path;
+            virSecurityDACChownItemPtr item = list->items[i];
+            const char *p = item->path;
 
-            VIR_APPEND_ELEMENT_COPY_INPLACE(paths, npaths, p);
+            if (item->remember)
+                VIR_APPEND_ELEMENT_COPY_INPLACE(paths, npaths, p);
         }
 
         if (!(state = virSecurityManagerMetadataLock(list->manager, paths, npaths)))
index e879fa39ab7458a84c740d7225d01141f5181b47..e3be724a2bb1b65bcd3520291e5e10043ef3a605 100644 (file)
@@ -266,9 +266,11 @@ virSecuritySELinuxTransactionRun(pid_t pid ATTRIBUTE_UNUSED,
             return -1;
 
         for (i = 0; i < list->nItems; i++) {
-            const char *p = list->items[i]->path;
+            virSecuritySELinuxContextItemPtr item = list->items[i];
+            const char *p = item->path;
 
-            VIR_APPEND_ELEMENT_COPY_INPLACE(paths, npaths, p);
+            if (item->remember)
+                VIR_APPEND_ELEMENT_COPY_INPLACE(paths, npaths, p);
         }
 
         if (!(state = virSecurityManagerMetadataLock(list->manager, paths, npaths)))