render / rpms / libvirt

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