]> xenbits.xensource.com Git - libvirt.git/commitdiff
security_selinux: Drop @optional from _virSecuritySELinuxContextItem
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 22 Aug 2019 08:21:11 +0000 (10:21 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 30 Aug 2019 10:38:52 +0000 (12:38 +0200)
Now, that we don't need to remember if setting context is
'optional' (the argument only made
virSecuritySELinuxSetFileconImpl() return a different success
code), we can drop it from the _virSecuritySELinuxContextItem
structure as we don't need to remember it in transactions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/security/security_selinux.c

index 87e1ba202d2193682a5b7ba62cfaaf2bd5ed9c72..e5b55fccb449d26491093df58a4f0e5822653805 100644 (file)
@@ -81,7 +81,6 @@ typedef virSecuritySELinuxContextItem *virSecuritySELinuxContextItemPtr;
 struct _virSecuritySELinuxContextItem {
     char *path;
     char *tcon;
-    bool optional;
     bool remember; /* Whether owner remembering should be done for @path/@src */
     bool restore; /* Whether current operation is 'set' or 'restore' */
 };
@@ -122,7 +121,6 @@ static int
 virSecuritySELinuxContextListAppend(virSecuritySELinuxContextListPtr list,
                                     const char *path,
                                     const char *tcon,
-                                    bool optional,
                                     bool remember,
                                     bool restore)
 {
@@ -135,7 +133,6 @@ virSecuritySELinuxContextListAppend(virSecuritySELinuxContextListPtr list,
     if (VIR_STRDUP(item->path, path) < 0 || VIR_STRDUP(item->tcon, tcon) < 0)
         goto cleanup;
 
-    item->optional = optional;
     item->remember = remember;
     item->restore = restore;
 
@@ -170,7 +167,6 @@ virSecuritySELinuxContextListFree(void *opaque)
  * virSecuritySELinuxTransactionAppend:
  * @path: Path to chown
  * @tcon: target context
- * @optional: true if setting @tcon is optional
  * @remember: if the original owner should be recorded/recalled
  * @restore: if current operation is set or restore
  *
@@ -187,7 +183,6 @@ virSecuritySELinuxContextListFree(void *opaque)
 static int
 virSecuritySELinuxTransactionAppend(const char *path,
                                     const char *tcon,
-                                    bool optional,
                                     bool remember,
                                     bool restore)
 {
@@ -198,7 +193,7 @@ virSecuritySELinuxTransactionAppend(const char *path,
         return 0;
 
     if (virSecuritySELinuxContextListAppend(list, path, tcon,
-                                            optional, remember, restore) < 0)
+                                            remember, restore) < 0)
         return -1;
 
     return 1;
@@ -234,7 +229,6 @@ virSecuritySELinuxRecallLabel(const char *path,
 static int virSecuritySELinuxSetFileconHelper(virSecurityManagerPtr mgr,
                                               const char *path,
                                               const char *tcon,
-                                              bool optional,
                                               bool remember);
 
 
@@ -290,7 +284,6 @@ virSecuritySELinuxTransactionRun(pid_t pid ATTRIBUTE_UNUSED,
             rv = virSecuritySELinuxSetFileconHelper(list->manager,
                                                     item->path,
                                                     item->tcon,
-                                                    item->optional,
                                                     remember);
         } else {
             rv = virSecuritySELinuxRestoreFileLabel(list->manager,
@@ -1342,7 +1335,6 @@ static int
 virSecuritySELinuxSetFileconHelper(virSecurityManagerPtr mgr,
                                    const char *path,
                                    const char *tcon,
-                                   bool optional,
                                    bool remember)
 {
     bool privileged = virSecurityManagerGetPrivileged(mgr);
@@ -1353,7 +1345,7 @@ virSecuritySELinuxSetFileconHelper(virSecurityManagerPtr mgr,
     int ret = -1;
 
     if ((rc = virSecuritySELinuxTransactionAppend(path, tcon,
-                                                  optional, remember, false)) < 0)
+                                                  remember, false)) < 0)
         return -1;
     else if (rc > 0)
         return 0;
@@ -1425,7 +1417,7 @@ virSecuritySELinuxSetFilecon(virSecurityManagerPtr mgr,
                              const char *tcon,
                              bool remember)
 {
-    return virSecuritySELinuxSetFileconHelper(mgr, path, tcon, false, remember);
+    return virSecuritySELinuxSetFileconHelper(mgr, path, tcon, remember);
 }
 
 static int
@@ -1512,7 +1504,7 @@ virSecuritySELinuxRestoreFileLabel(virSecurityManagerPtr mgr,
     }
 
     if ((rc = virSecuritySELinuxTransactionAppend(path, NULL,
-                                                  false, recall, true)) < 0) {
+                                                  recall, true)) < 0) {
         goto cleanup;
     } else if (rc > 0) {
         ret = 0;