From nobody Tue Sep 9 03:11:51 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1749732586; cv=none; d=zohomail.com; s=zohoarc; b=OCIJY2aFdd8zyVjewyLUdUP1/LomSJlGw0v6L626MDgyJuaS9Am57aq2QFRkU3B5ObD17FLCm9BOwcs5TV8yEoM9yUsxw+Lj1BULJn/qvmrDPZI12S6LAlx2zVNuUPN1tqNQYgdRruFctbUt6n0W7b4/Fkt3EZ7qtwM0mWycfHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749732586; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=XJF9RVBlAlfDefKOOJthQZx7IVCngyr+i4plr7800uQ=; b=Eq13uMl1wYRP4ivUA44d/R+WuncNJN2i8vGdiTVR0XwL/as/PVsbVVVc0TuSQeBxzU+ohtId0+BJu1314QJjOTR2BqrGAXpSlTqSazSY2sP/eEfHLAlFboWJs0Bd7wX4yzLqYvJVnOryHSOIOQz3iEvJl6AmK4wnMY2wC7L0HhI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 174973258668586.6220234644527; Thu, 12 Jun 2025 05:49:46 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A3946E31; Thu, 12 Jun 2025 08:49:45 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A05941284; Thu, 12 Jun 2025 08:49:00 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 92307D47; Thu, 12 Jun 2025 08:48:56 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E820FD44 for ; Thu, 12 Jun 2025 08:48:55 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-_ZQ6ZQwBO4GRAQewSRBIGg-1; Thu, 12 Jun 2025 08:48:54 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 84FEB19560AA for ; Thu, 12 Jun 2025 12:48:53 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BF584195609D for ; Thu, 12 Jun 2025 12:48:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749732535; h=from:from: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; bh=qJwShT9QD+qXyxt1kYMR63EdomEZ/clVLsf6ymiPTQg=; b=M7TaXvcUvoGIIAd/SXSMFahxPmV5H1KsvLDWWnyAVc+D5vcwxPGxlh/pOlgY5WNZQiMsIz DMKUz2bCOqHqFr5qvNb3YGPl77hULn91sCbkRtk7Q39eyccel/nsMr0uAZ/wrxsCD4m+Ny YotgBJmW7/QZ0FzfxJRkpul/rwkhY/I= X-MC-Unique: _ZQ6ZQwBO4GRAQewSRBIGg-1 X-Mimecast-MFC-AGG-ID: _ZQ6ZQwBO4GRAQewSRBIGg_1749732533 To: devel@lists.libvirt.org Subject: [PATCH 02/15] virt-aa-helper: Use virFileCanonicalizePath() Date: Thu, 12 Jun 2025 14:48:34 +0200 Message-ID: <9fbe46b31e5c455c9afe2bcbd4b50be30b4b7f16.1749732372.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: P4Ktt7WP8_hbZZMwNAU5HnmHExTrWAH23hJ-mDjW8YI_1749732533 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: CZLDVE3X565CE7VH5MRRR6RPEPVQYMS6 X-Message-ID-Hash: CZLDVE3X565CE7VH5MRRR6RPEPVQYMS6 X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1749732588788116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik While use of realpath() is not forbidden, our some of our mocks already have a test friendly reimplementation of virFileCanonicalizePath(). Use the latter. Signed-off-by: Michal Privoznik --- src/security/virt-aa-helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index e3802c18be..d4358ebf9c 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -712,7 +712,7 @@ vah_add_path(virBuffer *buf, const char *path, const ch= ar *perms, bool recursive tmp =3D g_strdup(path); } else { pathtmp =3D g_strdup(path + strlen(pathdir)); - if ((pathreal =3D realpath(pathdir, NULL)) =3D=3D NULL) { + if (!(pathreal =3D virFileCanonicalizePath(pathdir))) { vah_error(NULL, 0, pathdir); vah_error(NULL, 0, _("could not find realpath")); return rc; --=20 2.49.0