From nobody Sat Feb 7 05:53:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1593620153; cv=none; d=zohomail.com; s=zohoarc; b=BQDmqjPhoxfqVMyTcUvP8OR1iZ3XSdQZPSEGI0a24PnDElp1aLE+k93qDwYv+6QXvO+tB9WEiyw4bkJm5VEeTHaFEMg3LJFHOFpNKGAsjgacx77nQCNKwi9Q2kDT6e4hdZSu2SDzaNKzQRHoAdpMd0PlDbvHjTYWmT6/N0nwHk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593620153; h=Content-Type:Content-Transfer-Encoding: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; bh=sxfWBVSDa3dAvw6CiUf4SpcKezuALlnRjsDM9T4hpC4=; b=N9PeNUyAtxTcqFFJSj2H5G7TP6sMpto51z1T94+NsyQ09ZpZp3IEadodwnSMsqPXJjkX5TZyeOT996RL2iJnRdRJZrsxG66peFj2GAZsP9vPn0KCJt6MhcncEO1I6JMdV+v49uqi/F3+0fPNL7ev2hTuAP3jl44yNgjZBDOimYE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1593620153521426.4653294190564; Wed, 1 Jul 2020 09:15:53 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-167-UX8Hg4mzPZ26xn8IPGVCdg-1; Wed, 01 Jul 2020 12:15:46 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89A0E186A219; Wed, 1 Jul 2020 16:15:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A96C5C3F8; Wed, 1 Jul 2020 16:15:40 +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 39E306C9CB; Wed, 1 Jul 2020 16:15:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 061GFL3t005198 for ; Wed, 1 Jul 2020 12:15:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id CFA385C3F8; Wed, 1 Jul 2020 16:15:21 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F4EF5C1C5 for ; Wed, 1 Jul 2020 16:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593620150; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sxfWBVSDa3dAvw6CiUf4SpcKezuALlnRjsDM9T4hpC4=; b=Z9j0dGY5hsOXC1MwBDLfRdAZtukYJ3gRThz5+3rts0Och2fuTHn+k9v4NnQrq/Raf+uAgB jlMZdolo7q/aIj+X2KyZlqY3u7S5kZ/9d+CDPVR1OUr30Cp5dK6L/ZxpzU+BL01oB/oBD8 2lfO95W/eg/Pn8XKXgbIC3JbvnxIkko= X-MC-Unique: UX8Hg4mzPZ26xn8IPGVCdg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/7] security_selinux: Implement virSecurityManager{Set, Restore}SavedStateLabel Date: Wed, 1 Jul 2020 18:15:03 +0200 Message-Id: <7647272819ab84d8e65b00f3037dc8acfe59d6a6.1593620041.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" These APIs are are basically virSecuritySELinuxDomainSetPathLabelRO() and virSecuritySELinuxDomainRestorePathLabel(). Signed-off-by: Michal Privoznik --- src/security/security_selinux.c | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index f8c1a0a2f1..6b0581e4d9 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -2501,6 +2501,38 @@ virSecuritySELinuxRestoreHostdevLabel(virSecurityMan= agerPtr mgr, } =20 =20 +static int +virSecuritySELinuxSetSavedStateLabel(virSecurityManagerPtr mgr, + virDomainDefPtr def, + const char *savefile) +{ + virSecuritySELinuxDataPtr data =3D virSecurityManagerGetPrivateData(mg= r); + virSecurityLabelDefPtr secdef; + + secdef =3D virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME); + + if (!savefile || !secdef || !secdef->relabel || data->skipAllLabel) + return 0; + + return virSecuritySELinuxSetFilecon(mgr, savefile, data->content_conte= xt, false); +} + + +static int +virSecuritySELinuxRestoreSavedStateLabel(virSecurityManagerPtr mgr, + virDomainDefPtr def, + const char *savefile) +{ + virSecurityLabelDefPtr secdef; + + secdef =3D virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME); + if (!secdef || !secdef->relabel) + return 0; + + return virSecuritySELinuxRestoreFileLabel(mgr, savefile, true); +} + + static int virSecuritySELinuxSetChardevLabel(virSecurityManagerPtr mgr, virDomainDefPtr def, @@ -3616,6 +3648,9 @@ virSecurityDriver virSecurityDriverSELinux =3D { .domainSetSecurityHostdevLabel =3D virSecuritySELinuxSetHostdevLa= bel, .domainRestoreSecurityHostdevLabel =3D virSecuritySELinuxRestoreHostd= evLabel, =20 + .domainSetSavedStateLabel =3D virSecuritySELinuxSetSavedStat= eLabel, + .domainRestoreSavedStateLabel =3D virSecuritySELinuxRestoreSaved= StateLabel, + .domainSetSecurityImageFDLabel =3D virSecuritySELinuxSetImageFDLa= bel, .domainSetSecurityTapFDLabel =3D virSecuritySELinuxSetTapFDLabe= l, =20 --=20 2.26.2