From nobody Tue Sep 9 03:36:46 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=1749732656; cv=none; d=zohomail.com; s=zohoarc; b=Pd+qTjIcXB/7y7CjjPmllU+dcsdrD/tzM5Y8ByssIQh3EXF3bT9XTzcolYEd7gAt3/8N8pdX75SC5Gh1SysOFQit+gguT6DAhgrSsC+ZMTosbVfU58NUodmCRMaLe6ezYrYFAqqt6rlPBdoi2i8qug7PCe1TnDxFVyeBQ2ZFdJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749732656; 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=bE1O4Kv/1XuButdv6W+z0treaTGoEDDdBptw7mb4nUs=; b=AgKCh85hPCJgGNl3SwmutHNq8xTAduxXMSJb4GMADydF2e6Bi6o8qIZnj3G3B2MDQT79OUV4CRmERM8hGrO8XzQ2aT41XFftLoPZPO5dU252f7uucYvhNCC/XmoseE+Ifd/GHGtWnGCd4PghfYW+BadUKjASR5K7bhrmmgRsnBM= 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 1749732656919642.4161494226004; Thu, 12 Jun 2025 05:50:56 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E28D313AE; Thu, 12 Jun 2025 08:50:55 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0A47B124D; Thu, 12 Jun 2025 08:49:10 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 179B5E77; Thu, 12 Jun 2025 08:49:05 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 4FBB3D5B for ; Thu, 12 Jun 2025 08:48:58 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-204-OCMK71VXNAaEv3gebCl2bA-1; Thu, 12 Jun 2025 08:48:56 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B6E201801BD8 for ; Thu, 12 Jun 2025 12:48:55 +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 0D52D195609D for ; Thu, 12 Jun 2025 12:48:54 +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=1749732537; 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=VzwHPtXpgwQTbtBlbfVPKoz3aVwQdm3lBPAg48tT0gs=; b=E4C7RcerxyKJty4oV7cxE3tok8F6WDscR9mkJoE1KkXoUtWJM8aVIRVkonnK8A5Yb6aVDi UsvwQ1eCs+c+akF++P6ZaBYP23QYRj0LeUS5fcNkA6Hf747zHaTqCdmztIwFiFCbWdFURg bEITlFeLnaIRnzG0hBg4tbGd/qcY514= X-MC-Unique: OCMK71VXNAaEv3gebCl2bA-1 X-Mimecast-MFC-AGG-ID: OCMK71VXNAaEv3gebCl2bA_1749732535 To: devel@lists.libvirt.org Subject: [PATCH 04/15] virpcimock: Strip fakerootdir prefix in virFileCanonicalizePath() Date: Thu, 12 Jun 2025 14:48:36 +0200 Message-ID: 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: uhNMMUy6wCzZjZV9sGt9ORWZpxr7-MqFf3_lD0t5jDg_1749732535 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BPCQJLSDLT4ET2LHRLF6PZ7HPT3OGNGS X-Message-ID-Hash: BPCQJLSDLT4ET2LHRLF6PZ7HPT3OGNGS 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: 1749732659496116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The mocked implementation of virFileCanonicalizePath() redirects accesses to few dirs into a temporary directory, where PCI related files live. See getrealpath() for more info on this. Anyway, in the end - real implementation of virFileCanonicalizePath() is called which then might contain the 'fakerootdir' prefix. Up until now this did not matter because none of our test really cared about actual value of resolved path. They usually cared about last component of the path or something. But this will soon change. TLDR - if the returned path has $fakerootdir prefix, strip it. Signed-off-by: Michal Privoznik --- tests/virpcimock.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 34128d5516..4eff6d70e3 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -1184,13 +1184,23 @@ char * virFileCanonicalizePath(const char *path) { g_autofree char *newpath =3D NULL; + char *ret =3D NULL; =20 init_syms(); =20 if (getrealpath(&newpath, path) < 0) return NULL; =20 - return real_virFileCanonicalizePath(newpath); + ret =3D real_virFileCanonicalizePath(newpath); + + if (ret && fakerootdir && STRPREFIX(ret, fakerootdir)) { + size_t len =3D strlen(ret); + size_t preflen =3D strlen(fakerootdir); + + memmove(ret, ret + preflen, len - preflen + 1); + } + + return ret; } =20 # include "virmockstathelpers.c" --=20 2.49.0