|
Pablo Greco |
40546a |
From 36d6dd80a2b3840e471add391e8b71556904fa60 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <36d6dd80a2b3840e471add391e8b71556904fa60@dist-git>
|
|
Pablo Greco |
40546a |
From: Martin Kletzander <mkletzan@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Mon, 20 Jan 2020 12:55:56 +0100
|
|
Pablo Greco |
40546a |
Subject: [PATCH] selinux: Do not report an error when not returning -1
|
|
Pablo Greco |
40546a |
MIME-Version: 1.0
|
|
Pablo Greco |
40546a |
Content-Type: text/plain; charset=UTF-8
|
|
Pablo Greco |
40546a |
Content-Transfer-Encoding: 8bit
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
I guess the reason for that was the automatic interpretation/stringification of
|
|
Pablo Greco |
40546a |
setfilecon_errno, but the code was not nice to read and it was a bit confusing.
|
|
Pablo Greco |
40546a |
Also, the logs and error states get cleaner this way.
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
Pablo Greco |
40546a |
(cherry picked from commit 86289374ef85f673677881ef863ae6b6ce7e88a2)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
https://bugzilla.redhat.com/show_bug.cgi?id=1788096
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
|
|
Pablo Greco |
40546a |
Message-Id: <20200120115556.138061-2-fidencio@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
Pablo Greco |
40546a |
---
|
|
Pablo Greco |
40546a |
src/security/security_selinux.c | 12 ++++++++----
|
|
Pablo Greco |
40546a |
1 file changed, 8 insertions(+), 4 deletions(-)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
|
|
Pablo Greco |
40546a |
index 96944d0202..0238f31e84 100644
|
|
Pablo Greco |
40546a |
--- a/src/security/security_selinux.c
|
|
Pablo Greco |
40546a |
+++ b/src/security/security_selinux.c
|
|
Pablo Greco |
40546a |
@@ -1177,14 +1177,18 @@ virSecuritySELinuxSetFileconHelper(const char *path, const char *tcon,
|
|
Pablo Greco |
40546a |
if (setfilecon_errno != EOPNOTSUPP && setfilecon_errno != ENOTSUP &&
|
|
Pablo Greco |
40546a |
setfilecon_errno != EROFS) {
|
|
Pablo Greco |
40546a |
VIR_WARNINGS_RESET
|
|
Pablo Greco |
40546a |
- virReportSystemError(setfilecon_errno,
|
|
Pablo Greco |
40546a |
- _("unable to set security context '%s' on '%s'"),
|
|
Pablo Greco |
40546a |
- tcon, path);
|
|
Pablo Greco |
40546a |
/* However, don't claim error if SELinux is in Enforcing mode and
|
|
Pablo Greco |
40546a |
* we are running as unprivileged user and we really did see EPERM.
|
|
Pablo Greco |
40546a |
* Otherwise we want to return error if SELinux is Enforcing. */
|
|
Pablo Greco |
40546a |
- if (security_getenforce() == 1 && (setfilecon_errno != EPERM || privileged))
|
|
Pablo Greco |
40546a |
+ if (security_getenforce() == 1 &&
|
|
Pablo Greco |
40546a |
+ (setfilecon_errno != EPERM || privileged)) {
|
|
Pablo Greco |
40546a |
+ virReportSystemError(setfilecon_errno,
|
|
Pablo Greco |
40546a |
+ _("unable to set security context '%s' on '%s'"),
|
|
Pablo Greco |
40546a |
+ tcon, path);
|
|
Pablo Greco |
40546a |
return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+ VIR_WARN("unable to set security context '%s' on '%s' (errno %d)",
|
|
Pablo Greco |
40546a |
+ tcon, path, setfilecon_errno);
|
|
Pablo Greco |
40546a |
} else {
|
|
Pablo Greco |
40546a |
const char *msg;
|
|
Pablo Greco |
40546a |
if (virFileIsSharedFSType(path, VIR_FILE_SHFS_NFS) == 1 &&
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.25.0
|
|
Pablo Greco |
40546a |
|