From nobody Sun Feb 8 18:33:11 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 153535737339818.060915641625115; Mon, 27 Aug 2018 01:09:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E69C5F736; Mon, 27 Aug 2018 08:09:31 +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 472AC51DFF; Mon, 27 Aug 2018 08:09:31 +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 EE4384A47A; Mon, 27 Aug 2018 08:09:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7R8993t032567 for ; Mon, 27 Aug 2018 04:09:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id B3A372027056; Mon, 27 Aug 2018 08:09:09 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-81.brq.redhat.com [10.40.204.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41713202704E for ; Mon, 27 Aug 2018 08:09:09 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 27 Aug 2018 10:08:36 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 23/28] security_dac: Pass virSecurityManagerPtr to virSecurityDACSetOwnership 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: , MIME-Version: 1.0 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 27 Aug 2018 08:09:32 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function is going call security manager APIs and therefore it needs pointer to it. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- src/security/security_dac.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 4b623dcf39..1a33386b84 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -626,12 +626,13 @@ virSecurityDACSetOwnershipInternal(const virSecurityD= ACData *priv, =20 =20 static int -virSecurityDACSetOwnership(virSecurityDACDataPtr priv, +virSecurityDACSetOwnership(virSecurityManagerPtr mgr, virStorageSourcePtr src, const char *path, uid_t uid, gid_t gid) { + virSecurityDACDataPtr priv =3D virSecurityManagerGetPrivateData(mgr); struct stat sb; =20 if (!path && src && src->path && @@ -731,7 +732,7 @@ virSecurityDACSetImageLabelInternal(virSecurityManagerP= tr mgr, return -1; } =20 - return virSecurityDACSetOwnership(priv, src, NULL, user, group); + return virSecurityDACSetOwnership(mgr, src, NULL, user, group); } =20 =20 @@ -847,7 +848,7 @@ virSecurityDACSetHostdevLabelHelper(const char *file, if (virSecurityDACGetIds(secdef, priv, &user, &group, NULL, NULL) < 0) return -1; =20 - return virSecurityDACSetOwnership(priv, NULL, file, user, group); + return virSecurityDACSetOwnership(mgr, NULL, file, user, group); } =20 =20 @@ -1226,7 +1227,7 @@ virSecurityDACSetChardevLabel(virSecurityManagerPtr m= gr, switch ((virDomainChrType)dev_source->type) { case VIR_DOMAIN_CHR_TYPE_DEV: case VIR_DOMAIN_CHR_TYPE_FILE: - ret =3D virSecurityDACSetOwnership(priv, NULL, + ret =3D virSecurityDACSetOwnership(mgr, NULL, dev_source->data.file.path, user, group); break; @@ -1236,10 +1237,10 @@ virSecurityDACSetChardevLabel(virSecurityManagerPtr= mgr, virAsprintf(&out, "%s.out", dev_source->data.file.path) < 0) goto done; if (virFileExists(in) && virFileExists(out)) { - if (virSecurityDACSetOwnership(priv, NULL, in, user, group) < = 0 || - virSecurityDACSetOwnership(priv, NULL, out, user, group) <= 0) + if (virSecurityDACSetOwnership(mgr, NULL, in, user, group) < 0= || + virSecurityDACSetOwnership(mgr, NULL, out, user, group) < = 0) goto done; - } else if (virSecurityDACSetOwnership(priv, NULL, + } else if (virSecurityDACSetOwnership(mgr, NULL, dev_source->data.file.path, user, group) < 0) { goto done; @@ -1249,7 +1250,7 @@ virSecurityDACSetChardevLabel(virSecurityManagerPtr m= gr, =20 case VIR_DOMAIN_CHR_TYPE_UNIX: if (!dev_source->data.nix.listen) { - if (virSecurityDACSetOwnership(priv, NULL, + if (virSecurityDACSetOwnership(mgr, NULL, dev_source->data.nix.path, user, group) < 0) goto done; @@ -1433,7 +1434,7 @@ virSecurityDACSetGraphicsLabel(virSecurityManagerPtr = mgr, if (gfx->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE && gfx->data.spice.gl =3D=3D VIR_TRISTATE_BOOL_YES && gfx->data.spice.rendernode) { - if (virSecurityDACSetOwnership(priv, NULL, + if (virSecurityDACSetOwnership(mgr, NULL, gfx->data.spice.rendernode, user, group) < 0) return -1; @@ -1477,7 +1478,7 @@ virSecurityDACSetInputLabel(virSecurityManagerPtr mgr, if (virSecurityDACGetIds(seclabel, priv, &user, &group, NULL, NULL= ) < 0) return -1; =20 - ret =3D virSecurityDACSetOwnership(priv, NULL, input->source.evdev= , user, group); + ret =3D virSecurityDACSetOwnership(mgr, NULL, input->source.evdev,= user, group); break; =20 case VIR_DOMAIN_INPUT_TYPE_MOUSE: @@ -1651,7 +1652,7 @@ virSecurityDACSetMemoryLabel(virSecurityManagerPtr mg= r, if (virSecurityDACGetIds(seclabel, priv, &user, &group, NULL, NULL= ) < 0) return -1; =20 - ret =3D virSecurityDACSetOwnership(priv, NULL, mem->nvdimmPath, us= er, group); + ret =3D virSecurityDACSetOwnership(mgr, NULL, mem->nvdimmPath, use= r, group); break; =20 case VIR_DOMAIN_MEMORY_MODEL_DIMM: @@ -1739,27 +1740,27 @@ virSecurityDACSetAllLabel(virSecurityManagerPtr mgr, return -1; =20 if (def->os.loader && def->os.loader->nvram && - virSecurityDACSetOwnership(priv, NULL, + virSecurityDACSetOwnership(mgr, NULL, def->os.loader->nvram, user, group) < 0) return -1; =20 if (def->os.kernel && - virSecurityDACSetOwnership(priv, NULL, + virSecurityDACSetOwnership(mgr, NULL, def->os.kernel, user, group) < 0) return -1; =20 if (def->os.initrd && - virSecurityDACSetOwnership(priv, NULL, + virSecurityDACSetOwnership(mgr, NULL, def->os.initrd, user, group) < 0) return -1; =20 if (def->os.dtb && - virSecurityDACSetOwnership(priv, NULL, + virSecurityDACSetOwnership(mgr, NULL, def->os.dtb, user, group) < 0) return -1; =20 if (def->os.slic_table && - virSecurityDACSetOwnership(priv, NULL, + virSecurityDACSetOwnership(mgr, NULL, def->os.slic_table, user, group) < 0) return -1; =20 @@ -1782,7 +1783,7 @@ virSecurityDACSetSavedStateLabel(virSecurityManagerPt= r mgr, if (virSecurityDACGetImageIds(secdef, priv, &user, &group) < 0) return -1; =20 - return virSecurityDACSetOwnership(priv, NULL, savefile, user, group); + return virSecurityDACSetOwnership(mgr, NULL, savefile, user, group); } =20 =20 @@ -2102,7 +2103,7 @@ virSecurityDACDomainSetPathLabel(virSecurityManagerPt= r mgr, if (virSecurityDACGetIds(seclabel, priv, &user, &group, NULL, NULL) < = 0) return -1; =20 - return virSecurityDACSetOwnership(priv, NULL, path, user, group); + return virSecurityDACSetOwnership(mgr, NULL, path, user, group); } =20 virSecurityDriver virSecurityDriverDAC =3D { --=20 2.16.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list