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