From c9b37fee25d643c8ca890386a7d072dde655273c Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 8 Sep 2011 18:23:25 +0200 Subject: [PATCH] selinux: Detect virt_use_nfs boolean set If we fail setting label on a file and this file is on NFS share, it is wise to advise user to set virt_use_nfs selinux boolean variable. --- src/security/security_selinux.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index ca54f9be7f..028f5b26f3 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -420,8 +420,17 @@ SELinuxSetFilecon(const char *path, char *tcon) * virt_use_{nfs,usb,pci} boolean tunables to allow it... */ if (setfilecon_errno != EOPNOTSUPP) { + const char *errmsg; + if ((virStorageFileIsSharedFSType(path, + VIR_STORAGE_FILE_SHFS_NFS) == 1) && + security_get_boolean_active("virt_use_nfs") != 1) { + errmsg = _("unable to set security context '%s' on '%s'. " + "Consider setting virt_use_nfs"); + } else { + errmsg = _("unable to set security context '%s' on '%s'"); + } virReportSystemError(setfilecon_errno, - _("unable to set security context '%s' on '%s'"), + errmsg, tcon, path); if (security_getenforce() == 1) return -1; -- 2.39.5