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