render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From 4f9e2b4b36fda208d25acf4126abbf4fee37f0b5 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <4f9e2b4b36fda208d25acf4126abbf4fee37f0b5@dist-git>
a41c76
From: Michal Privoznik <mprivozn@redhat.com>
a41c76
Date: Tue, 25 Feb 2020 11:24:52 +0100
a41c76
Subject: [PATCH] security: Don't fail if locking a file on NFS mount fails
a41c76
a41c76
The way that our file locking works is that we open() the file we
a41c76
want to lock and then use fcntl(fd, F_SETLKW, ...) to lock it.
a41c76
The problem is, we are doing all of these as root which doesn't
a41c76
work if the file lives on root squashed NFS, because if it does
a41c76
then the open() fails. The way to resolve this is to make this a
a41c76
non fatal error and leave callers deal with this (i.e. disable
a41c76
remembering) - implemented in the previous commit.
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1804672
a41c76
a41c76
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
a41c76
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
a41c76
(cherry picked from commit f16663d58f7aab6bf800fcffd34f83f522927897)
a41c76
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
a41c76
Message-Id: <d3cb3d3214cf3e67bd357fa9781ce55f8dc8c751.1582626185.git.mprivozn@redhat.com>
a41c76
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
---
a41c76
 src/security/security_manager.c | 5 +++++
a41c76
 1 file changed, 5 insertions(+)
a41c76
a41c76
diff --git a/src/security/security_manager.c b/src/security/security_manager.c
a41c76
index 9d06316a99..23ed6a127c 100644
a41c76
--- a/src/security/security_manager.c
a41c76
+++ b/src/security/security_manager.c
a41c76
@@ -1343,6 +1343,11 @@ virSecurityManagerMetadataLock(virSecurityManagerPtr mgr G_GNUC_UNUSED,
a41c76
                 continue;
a41c76
             }
a41c76
 
a41c76
+            if (virFileIsSharedFS(p)) {
a41c76
+                /* Probably a root squashed NFS. */
a41c76
+                continue;
a41c76
+            }
a41c76
+
a41c76
             virReportSystemError(errno,
a41c76
                                  _("unable to open %s"),
a41c76
                                  p);
a41c76
-- 
a41c76
2.25.1
a41c76