From nobody Mon Feb 9 03:56:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1567093169; cv=none; d=zoho.com; s=zohoarc; b=MwyHSBizbHwWnIqYS0pFxacEK6HjXFT19BEhWHhsLzlzs4mxJ4VKW5ZxgLJR/gPOuJUwAIk2us/QvvbK+xmbWzb/Ss9Q1ePTkd296EZRAQvIztNjE+BM4vK8uus5ykPfvqKsfFl4lYcR2kxuQ1JDSsxWUR+vdjOoL7tpWzt0DzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567093169; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4f5UcslLOjALeyS+Ri++yZoK5+ybvblzbZdgjfgwZpw=; b=ev3SEz1LHcil8HpTN7QJwCT3BraMfnRDtEKCINj0Kqk6z8fTDCjuvTWA8IuxS0eULFwz8Pfj+PdfMsWXmcH21LCCxlw23cxg9eI1ytj5NL2ru0FEjwxCENFZF+QIArfbObdM6N+baVRiEe+suEjK2LFT8I9lWyrsxUJKIg4KsRU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1567093169216403.3700926191624; Thu, 29 Aug 2019 08:39:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F26D82CE972; Thu, 29 Aug 2019 15:39:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE06D5F7DA; Thu, 29 Aug 2019 15:39:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6A5AD180B536; Thu, 29 Aug 2019 15:39:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7TFdQEI015881 for ; Thu, 29 Aug 2019 11:39:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 97BBD60E3E; Thu, 29 Aug 2019 15:39:26 +0000 (UTC) Received: from caroline (unknown [10.43.2.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B0E560CC0; Thu, 29 Aug 2019 15:39:24 +0000 (UTC) Received: from caroline.brq.redhat.com (caroline.usersys.redhat.com [127.0.0.1]) by caroline (Postfix) with ESMTP id 19EF612001F; Thu, 29 Aug 2019 17:39:23 +0200 (CEST) From: Martin Kletzander To: libvir-list@redhat.com Date: Thu, 29 Aug 2019 17:39:11 +0200 Message-Id: <38f93e5f719e27b12221176d3c96bcc27a30da56.1567093058.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com Subject: [libvirt] [PATCH] selinux: Do not report an error when not returning -1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 29 Aug 2019 15:39:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" I guess the reason for that was the automatic interpretation/stringificatio= n of setfilecon_errno, but the code was not nice to read and it was a bit confus= ing. Also, the logs and error states get cleaner this way. Signed-off-by: Martin Kletzander Reviewed-by: Michal Privoznik --- I'm still waiting for the build in travis to finish, so don't stone me if it fails. The link is here: https://travis-ci.org/nertpinx/libvirt/builds/578= 418517 src/security/security_selinux.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 4d0c7a46ae23..bbb5318aa0ee 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1301,14 +1301,18 @@ virSecuritySELinuxSetFileconImpl(const char *path, if (setfilecon_errno !=3D EOPNOTSUPP && setfilecon_errno !=3D ENOT= SUP && setfilecon_errno !=3D EROFS) { VIR_WARNINGS_RESET - virReportSystemError(setfilecon_errno, - _("unable to set security context '%s' on= '%s'"), - tcon, path); /* However, don't claim error if SELinux is in Enforcing mode = and * we are running as unprivileged user and we really did see E= PERM. * Otherwise we want to return error if SELinux is Enforcing. = */ - if (security_getenforce() =3D=3D 1 && (setfilecon_errno !=3D E= PERM || privileged)) + if (security_getenforce() =3D=3D 1 && + (setfilecon_errno !=3D EPERM || privileged)) { + virReportSystemError(setfilecon_errno, + _("unable to set security context '%s= ' on '%s'"), + tcon, path); return -1; + } + VIR_WARN(_("unable to set security context '%s' on '%s' (errno= %d)"), + tcon, path, setfilecon_errno); } else { const char *msg; if (virFileIsSharedFSType(path, VIR_FILE_SHFS_NFS) =3D=3D 1 && --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list