982648
From abda9a653cdb9ae482b7122e091c73c2df18f9e2 Mon Sep 17 00:00:00 2001
982648
Message-Id: <abda9a653cdb9ae482b7122e091c73c2df18f9e2@dist-git>
982648
From: Michal Privoznik <mprivozn@redhat.com>
982648
Date: Wed, 25 Jul 2018 08:27:09 +0200
982648
Subject: [PATCH] qemu: Remove unused bypassSecurityDriver from qemuOpenFileAs
982648
MIME-Version: 1.0
982648
Content-Type: text/plain; charset=UTF-8
982648
Content-Transfer-Encoding: 8bit
982648
982648
https://bugzilla.redhat.com/show_bug.cgi?id=1589115
982648
982648
This argument is not used anymore. The only function that is
982648
passing non-NULL (qemuDomainSaveMemory) does not actually care
982648
for the value (after 23087cfdb) and every other caller just
982648
passes NULL anyway.
982648
982648
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
982648
Reviewed-by: John Ferlan <jferlan@redhat.com>
982648
(cherry picked from commit 8677a476c7e5cbf7b344329d54d0b1a2d666ffc3)
982648
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
982648
Reviewed-by: Ján Tomko <jtomko@redhat.com>
982648
---
982648
 src/qemu/qemu_driver.c | 32 +++++++++-----------------------
982648
 1 file changed, 9 insertions(+), 23 deletions(-)
982648
982648
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
982648
index 62deae4b98..efd0a05c90 100644
982648
--- a/src/qemu/qemu_driver.c
982648
+++ b/src/qemu/qemu_driver.c
982648
@@ -152,7 +152,7 @@ static int qemuDomainManagedSaveLoad(virDomainObjPtr vm,
982648
 static int qemuOpenFileAs(uid_t fallback_uid, gid_t fallback_gid,
982648
                           bool dynamicOwnership,
982648
                           const char *path, int oflags,
982648
-                          bool *needUnlink, bool *bypassSecurityDriver);
982648
+                          bool *needUnlink);
982648
 
982648
 static int qemuGetDHCPInterfaces(virDomainPtr dom,
982648
                                  virDomainObjPtr vm,
982648
@@ -2984,9 +2984,6 @@ qemuCompressGetCommand(virQEMUSaveFormat compression)
982648
  * @path: path to file to open
982648
  * @oflags: flags for opening/creation of the file
982648
  * @needUnlink: set to true if file was created by this function
982648
- * @bypassSecurityDriver: optional pointer to a boolean that will be set to true
982648
- *                        if security driver operations are pointless (due to
982648
- *                        NFS mount)
982648
  *
982648
  * Internal function to properly create or open existing files, with
982648
  * ownership affected by qemu driver setup and domain DAC label.
982648
@@ -3001,8 +2998,7 @@ qemuOpenFile(virQEMUDriverPtr driver,
982648
              virDomainObjPtr vm,
982648
              const char *path,
982648
              int oflags,
982648
-             bool *needUnlink,
982648
-             bool *bypassSecurityDriver)
982648
+             bool *needUnlink)
982648
 {
982648
     int ret = -1;
982648
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
982648
@@ -3021,7 +3017,7 @@ qemuOpenFile(virQEMUDriverPtr driver,
982648
         goto cleanup;
982648
 
982648
     ret = qemuOpenFileAs(user, group, dynamicOwnership,
982648
-                         path, oflags, needUnlink, bypassSecurityDriver);
982648
+                         path, oflags, needUnlink);
982648
 
982648
  cleanup:
982648
     return ret;
982648
@@ -3031,12 +3027,11 @@ static int
982648
 qemuOpenFileAs(uid_t fallback_uid, gid_t fallback_gid,
982648
                bool dynamicOwnership,
982648
                const char *path, int oflags,
982648
-               bool *needUnlink, bool *bypassSecurityDriver)
982648
+               bool *needUnlink)
982648
 {
982648
     struct stat sb;
982648
     bool is_reg = true;
982648
     bool need_unlink = false;
982648
-    bool bypass_security = false;
982648
     unsigned int vfoflags = 0;
982648
     int fd = -1;
982648
     int path_shared = virFileIsSharedFS(path);
982648
@@ -3134,19 +3129,11 @@ qemuOpenFileAs(uid_t fallback_uid, gid_t fallback_gid,
982648
                                      path);
982648
                 goto cleanup;
982648
             }
982648
-
982648
-            /* Since we had to setuid to create the file, and the fstype
982648
-               is NFS, we assume it's a root-squashing NFS share, and that
982648
-               the security driver stuff would have failed anyway */
982648
-
982648
-            bypass_security = true;
982648
         }
982648
     }
982648
  cleanup:
982648
     if (needUnlink)
982648
         *needUnlink = need_unlink;
982648
-    if (bypassSecurityDriver)
982648
-        *bypassSecurityDriver = bypass_security;
982648
     return fd;
982648
 
982648
  error:
982648
@@ -3198,7 +3185,6 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
982648
                      unsigned int flags,
982648
                      qemuDomainAsyncJob asyncJob)
982648
 {
982648
-    bool bypassSecurityDriver = false;
982648
     bool needUnlink = false;
982648
     int ret = -1;
982648
     int fd = -1;
982648
@@ -3218,7 +3204,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
982648
     }
982648
     fd = qemuOpenFile(driver, vm, path,
982648
                       O_WRONLY | O_TRUNC | O_CREAT | directFlag,
982648
-                      &needUnlink, &bypassSecurityDriver);
982648
+                      &needUnlink);
982648
     if (fd < 0)
982648
         goto cleanup;
982648
 
982648
@@ -3249,7 +3235,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
982648
     if (qemuFileWrapperFDClose(vm, wrapperFd) < 0)
982648
         goto cleanup;
982648
 
982648
-    if ((fd = qemuOpenFile(driver, vm, path, O_WRONLY, NULL, NULL)) < 0 ||
982648
+    if ((fd = qemuOpenFile(driver, vm, path, O_WRONLY, NULL)) < 0 ||
982648
         virQEMUSaveDataFinish(data, &fd, path) < 0)
982648
         goto cleanup;
982648
 
982648
@@ -3809,7 +3795,7 @@ doCoreDump(virQEMUDriverPtr driver,
982648
      * created.  */
982648
     if ((fd = qemuOpenFile(driver, vm, path,
982648
                            O_CREAT | O_TRUNC | O_WRONLY | directFlag,
982648
-                           NULL, NULL)) < 0)
982648
+                           NULL)) < 0)
982648
         goto cleanup;
982648
 
982648
     if (!(wrapperFd = virFileWrapperFdNew(&fd, path, flags)))
982648
@@ -6434,7 +6420,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
982648
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
982648
         goto error;
982648
 
982648
-    if ((fd = qemuOpenFile(driver, NULL, path, oflags, NULL, NULL)) < 0)
982648
+    if ((fd = qemuOpenFile(driver, NULL, path, oflags, NULL)) < 0)
982648
         goto error;
982648
     if (bypass_cache &&
982648
         !(*wrapperFd = virFileWrapperFdNew(&fd, path,
982648
@@ -11878,7 +11864,7 @@ qemuDomainStorageOpenStat(virQEMUDriverPtr driver,
982648
 {
982648
     if (virStorageSourceIsLocalStorage(src)) {
982648
         if ((*ret_fd = qemuOpenFile(driver, vm, src->path, O_RDONLY,
982648
-                                    NULL, NULL)) < 0)
982648
+                                    NULL)) < 0)
982648
             return -1;
982648
 
982648
         if (fstat(*ret_fd, ret_sb) < 0) {
982648
-- 
982648
2.18.0
982648