From nobody Tue Mar 3 03:06:30 2026 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=1771921420; cv=none; d=zohomail.com; s=zohoarc; b=T7YX4cqldyDhkNc+Shr+AX3ASd2hXiclTz/8Byyz4RqhVzW1XZbPPuKTFZpMzW59J8ieA/lMvvbgtr8DhjkB2PciD13uP2g2Fqxe0dMdxX0SgbRYIilCBkJU+YN+UYNOhdSucQKCF5nlebZgigIHkgYiCkuiOhveGSMv26yRum0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771921420; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner: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=/gzKndvGrxni3fOV4sHjNyLjfogzFv/PDa+CXHPfFRU=; b=H//apm/wO6/jyoE4UytWpsxG5bLqG+sMi2/ufRRNXE5joNdQnjF1X/qLb6vFlR1e7t3QrPRtkToIQQXnvhfS9rNC8avuPa9o5yfQOg/Edu161U2STeNYl6vfDwdyzu1HmpCmyIJGPr4edw/ny6Kq9ovBdUzhlpY94NfGWuJFjtQ= 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 1771921420300493.87393907915316; Tue, 24 Feb 2026 00:23:40 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 627D841CB7; Tue, 24 Feb 2026 03:23:39 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 8F70541C4C; Tue, 24 Feb 2026 03:22:54 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 357B741B6C; Tue, 24 Feb 2026 03:22:49 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 8836F41B5C for ; Tue, 24 Feb 2026 03:22:48 -0500 (EST) Received: from mx-prod-mc-05.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-576-scmsLKqBP4igfZO761DrJQ-1; Tue, 24 Feb 2026 03:22:45 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 80E21195608A for ; Tue, 24 Feb 2026 08:22:44 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.82]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 26CAA1800465 for ; Tue, 24 Feb 2026 08:22:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771921368; 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=/gzKndvGrxni3fOV4sHjNyLjfogzFv/PDa+CXHPfFRU=; b=Jh4UtTemOM7oD/2ilPl9w124VIVpw6kOsJ6Ph8NBeMk+hpJrvqCTamZzwefE03EoIgSghh egSXa6LjbJCX4z39Jx5jCM/RxzobA60V6wkle3nGHy29qOaqxVbkF8RSgZzziijS86jNui DGwY6mQQ4bFvWrOjfZ6C6RVgsmrbrrI= X-MC-Unique: scmsLKqBP4igfZO761DrJQ-1 X-Mimecast-MFC-AGG-ID: scmsLKqBP4igfZO761DrJQ_1771921364 To: devel@lists.libvirt.org Subject: [PATCH 1/8] util: reduce scope/autofree-ify rundir in virDaemonUnixSocketPaths() Date: Tue, 24 Feb 2026 03:22:35 -0500 Message-ID: <20260224082242.274009-2-laine@redhat.com> In-Reply-To: <20260224082242.274009-1-laine@redhat.com> References: <20260224082242.274009-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: RgePvlDgrVtIdycrvi5A9jXs8ufnXNofcvyyQCtQDr8_1771921364 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: PJZISPVQYSFMWSJJHLXD6HQP3GAAWTXE X-Message-ID-Hash: PJZISPVQYSFMWSJJHLXD6HQP3GAAWTXE X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1771921421555158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/util/virdaemon.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/util/virdaemon.c b/src/util/virdaemon.c index 7a288f81e4..cb2c55d1bc 100644 --- a/src/util/virdaemon.c +++ b/src/util/virdaemon.c @@ -216,9 +216,6 @@ virDaemonUnixSocketPaths(const char *sock_prefix, char **rosockfile, char **admsockfile) { - int ret =3D -1; - char *rundir =3D NULL; - if (unix_sock_dir) { if (sockfile) *sockfile =3D g_strdup_printf("%s/%s-sock", unix_sock_dir, soc= k_prefix); @@ -244,13 +241,12 @@ virDaemonUnixSocketPaths(const char *sock_prefix, RUNSTATEDIR, sock_prefix); } else { mode_t old_umask; - - rundir =3D virGetUserRuntimeDirectory(); + g_autofree char *rundir =3D virGetUserRuntimeDirectory(); =20 old_umask =3D umask(077); if (g_mkdir_with_parents(rundir, 0777) < 0) { umask(old_umask); - goto cleanup; + return -1; } umask(old_umask); =20 @@ -261,10 +257,7 @@ virDaemonUnixSocketPaths(const char *sock_prefix, } } =20 - ret =3D 0; - cleanup: - VIR_FREE(rundir); - return ret; + return 0; } =20 #else /* WIN32 */ --=20 2.52.0 From nobody Tue Mar 3 03:06:30 2026 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=1771921888; cv=none; d=zohomail.com; s=zohoarc; b=DaQcuEHIIDpMMD2wtEDoAQi5CblrNUMIpuFVgYO3ot3+kt2ffjtNbBTMs/s+ZEHCU/fMKiPUZgnCfY6x0NucBkeq9nR0Tgk3+HBE44a0graVZPltev/CKZWP2sMXZSkocKfBEjyEpw6ZukdhhWzacBfcbdb0fSX66zg+03Psk80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771921888; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner: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=5+H6SmypLGycckt9B5/xkyn8tihIbeAhgidLlI6O45I=; b=RLP5HIagf2MmZM1/upISdIx3Jt3K5V/zhtecxdIgCZBvuaxSrKJF5jGOtuzipOs0572Ah7QWQfZ80uD4Vj6tHQxUodk7OEp8D4cb4HJ7ccw6bOOblZ82oR+YCl63jyeUCaxKdMTv5wbpqG6FQWGurp9eIYK1yqEL3HsaWq4uB/A= 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 1771921888170122.23836808280657; Tue, 24 Feb 2026 00:31:28 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 3F3A141B69; Tue, 24 Feb 2026 03:31:28 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 06B5043E0F; Tue, 24 Feb 2026 03:24:17 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 55FDC41C70; Tue, 24 Feb 2026 03:23:05 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3DE2C41BC1 for ; Tue, 24 Feb 2026 03:22:53 -0500 (EST) Received: from mx-prod-mc-01.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-664-Y_GftdxUOFaOrZ72Mvzqbg-1; Tue, 24 Feb 2026 03:22:45 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2245C19560A3 for ; Tue, 24 Feb 2026 08:22:45 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.82]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B367B1800465 for ; Tue, 24 Feb 2026 08:22:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771921372; 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=5+H6SmypLGycckt9B5/xkyn8tihIbeAhgidLlI6O45I=; b=UNpZWSAl5cvyqoP7BJmcJRrdW4Db4hl+hTRj1djCRPC5dSks+eLNaqFYuKcFD977Yu70p2 zA4rb7tXlnCdXbVlFArgTkIOWB+H311R0HFPFBQg2PB4rXVfNbavidhWbnJ7GBgMAS2vU0 qYFpdIpkTX7esT0aHzaSpffljxSnszg= X-MC-Unique: Y_GftdxUOFaOrZ72Mvzqbg-1 X-Mimecast-MFC-AGG-ID: Y_GftdxUOFaOrZ72Mvzqbg_1771921365 To: devel@lists.libvirt.org Subject: [PATCH 2/8] util: reduce scope of rundir in virPidFileConstructPath() Date: Tue, 24 Feb 2026 03:22:36 -0500 Message-ID: <20260224082242.274009-3-laine@redhat.com> In-Reply-To: <20260224082242.274009-1-laine@redhat.com> References: <20260224082242.274009-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: g-h7StqBgH-_0tYWCExyVbqKGiSn9Vjp1_x9vG6yIKA_1771921365 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 42VZGBUYQFV2PKZSCTOSY7LOUTJPDMRI X-Message-ID-Hash: 42VZGBUYQFV2PKZSCTOSY7LOUTJPDMRI X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1771921907014158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/util/virpidfile.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index f61caca2de..dacaffc929 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -526,8 +526,6 @@ virPidFileConstructPath(bool privileged, const char *progname, char **pidfile) { - g_autofree char *rundir =3D NULL; - if (privileged) { /* * This is here just to allow calling this function with @@ -540,7 +538,7 @@ virPidFileConstructPath(bool privileged, } *pidfile =3D g_strdup_printf("%s/%s.pid", runstatedir, progname); } else { - rundir =3D virGetUserRuntimeDirectory(); + g_autofree char *rundir =3D virGetUserRuntimeDirectory(); =20 if (g_mkdir_with_parents(rundir, 0700) < 0) { virReportSystemError(errno, --=20 2.52.0 From nobody Tue Mar 3 03:06:30 2026 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=1771921520; cv=none; d=zohomail.com; s=zohoarc; b=XajhQJP0NMRQbUt1HQDAjXv0MuiPPTu0SOaN/AkzIZgItIPcY9HhKD4jIF15kDOKarI8TYzh94GdHtOcGhIy8JhbmN0ImzILsXlcZ1wZjkFUqGWrsGH/3hEXqzI4wx6Gv67IDNprNK8unyH9mHzSQ3o58ocbrIZjUJm07KRDDrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771921520; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner: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=uFliRKV4eDPPNhegiT8XzfV55lrLrSeNB97R1WHRAnE=; b=EwnIffLSd37XvdcWhsd/JHU6SNPgO/C+Q6wxZdPggUYsSmaiwF9FnTlDF4l3VPNd/dg69rEZ9NteLNGWR2xCy7p6a0tA8zTOWYVvcGFHIZSgXUfDzQwkoISfYOGrcKV4jzBXMlfeb2lYoV85agxS1boKJ+wki9bIIvwnCWxmrhY= 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 1771921520617313.1388177776714; Tue, 24 Feb 2026 00:25:20 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 00C7641AE1; Tue, 24 Feb 2026 03:25:20 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id B22DF41D2F; Tue, 24 Feb 2026 03:23:02 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id A193941B48; Tue, 24 Feb 2026 03:22:49 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 9EFB841B66 for ; Tue, 24 Feb 2026 03:22:48 -0500 (EST) Received: from mx-prod-mc-05.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-531-tPG2j9FeOk6hgTnRcrYvAQ-1; Tue, 24 Feb 2026 03:22:46 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B8357195609F for ; Tue, 24 Feb 2026 08:22:45 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.82]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5520D1800465 for ; Tue, 24 Feb 2026 08:22:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771921368; 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=uFliRKV4eDPPNhegiT8XzfV55lrLrSeNB97R1WHRAnE=; b=LFrlOIadP2XWjQo/qaCuT4WSU3Ct+MLRTq24igMDOfgSrWNSpF9TnhQnGiLvw1KZSPipaq PSOmA46/RdnohKZSttrWKxmDvBHqPunK7iSjZb/AlFkiI4IcDpz0xzff2+7NQWiBGskYxL w0TYXDw62lSlMLnufThOnplTbbBxNeY= X-MC-Unique: tPG2j9FeOk6hgTnRcrYvAQ-1 X-Mimecast-MFC-AGG-ID: tPG2j9FeOk6hgTnRcrYvAQ_1771921365 To: devel@lists.libvirt.org Subject: [PATCH 3/8] remote: reduce scope of userdir in remoteGetUNIXSocketHelper() Date: Tue, 24 Feb 2026 03:22:37 -0500 Message-ID: <20260224082242.274009-4-laine@redhat.com> In-Reply-To: <20260224082242.274009-1-laine@redhat.com> References: <20260224082242.274009-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 5EpJ2GpTqQucO5L5DDp6SDK1a9VL5apChXt4EdrgQaA_1771921365 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: K3H23WKUHXOXVRVSDCSSKRXDN7CMKHQF X-Message-ID-Hash: K3H23WKUHXOXVRVSDCSSKRXDN7CMKHQF X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1771921546138158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/remote/remote_sockets.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/remote/remote_sockets.c b/src/remote/remote_sockets.c index b3f6cd6a42..13b760355b 100644 --- a/src/remote/remote_sockets.c +++ b/src/remote/remote_sockets.c @@ -126,10 +126,9 @@ remoteGetUNIXSocketHelper(remoteDriverTransport transp= ort, unsigned int flags) { char *sockname =3D NULL; - g_autofree char *userdir =3D NULL; =20 if (flags & REMOTE_DRIVER_OPEN_USER) { - userdir =3D virGetUserRuntimeDirectory(); + g_autofree char *userdir =3D virGetUserRuntimeDirectory(); =20 sockname =3D g_strdup_printf("%s/%s-sock", userdir, sock_prefix); } else { --=20 2.52.0 From nobody Tue Mar 3 03:06:30 2026 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=1771921622; cv=none; d=zohomail.com; s=zohoarc; b=SXcnzDk64iYuYo3Zx6d2lUI6J8eo0tiD8weORU7GtkCGBcA/6EyzaIJUa6gXK8zO9UJv7Lkwk5Bg3xfNOypNObUGDgIG6/qnrc5Rj9IRYqf4TmQjuBaiI+BKZ4Tdd1bPuMlr+5yzChr+4Cq1vw9GqkLtuwN+VFVRtVGfG7GOzM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771921622; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner: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=VJFria16XPcVDXc7byo5qTamn60eIYTjeSQF+I3BrgI=; b=jKAEQb7Nz726Xz2POrEyuH0+rCQf0gDJLNtdFnu1NqPZMsN4Q0wIKl0sHZsEuLbZyWXAhtn04Ng59ckPCBt9Jt7cZ1m+1wEdqxLAH+wjqCo1BdJ2OT2cfuQFbwxsBWkyB9ZXukHpw3Z6crd8YR+B89oBNQQtEFac/EGG9/AqtEk= 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 1771921622705468.38209581041815; Tue, 24 Feb 2026 00:27:02 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id D6CA841C19; Tue, 24 Feb 2026 03:27:01 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 5625741D26; Tue, 24 Feb 2026 03:23:20 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id AF1CC41B48; Tue, 24 Feb 2026 03:22:49 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 278BE41B68 for ; Tue, 24 Feb 2026 03:22:49 -0500 (EST) Received: from mx-prod-mc-06.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-628-u-4S5j3vOfq5eeLTF5yVHQ-1; Tue, 24 Feb 2026 03:22:47 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4F4961800464 for ; Tue, 24 Feb 2026 08:22:46 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.82]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EAB6D1800465 for ; Tue, 24 Feb 2026 08:22:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771921368; 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=VJFria16XPcVDXc7byo5qTamn60eIYTjeSQF+I3BrgI=; b=bwoKOo3sjbiEIwrkGMlgSbyGV9jMSOT+GYTIJ8NJS/DT3iv89N3Bt+DjkkcBqTQ1HwvtgJ A942aK81TCxah+gBa/Mzhh0a/GGBPDJWBu8QcbrzsX/VlBdQGtG0fKhOzm4DTtUimzWQo4 xZyRsb4LlDh/86ztvDfSsPZpGGsxUX0= X-MC-Unique: u-4S5j3vOfq5eeLTF5yVHQ-1 X-Mimecast-MFC-AGG-ID: u-4S5j3vOfq5eeLTF5yVHQ_1771921366 To: devel@lists.libvirt.org Subject: [PATCH 4/8] util: rename virGetUserDirectory(ByUID) to virGetUserHomeDirectory(ByUID) Date: Tue, 24 Feb 2026 03:22:38 -0500 Message-ID: <20260224082242.274009-5-laine@redhat.com> In-Reply-To: <20260224082242.274009-1-laine@redhat.com> References: <20260224082242.274009-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Wmz-7WysJbz2Nk8EbfnUU6iTxLX9jJbuF-oRKxyVr4s_1771921366 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BBMECDKHNMUWADCTUJ3YFSWKZUZPHDXJ X-Message-ID-Hash: BBMECDKHNMUWADCTUJ3YFSWKZUZPHDXJ X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1771921624342158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump All the other wrapper functions for glib g_get_user_*_dir() have the type of directory (the "*" in that wildcarded name) in the libvirt function name. These functions, on the other hand, call g_get_home_dir(), but the libvirt API is called virGetUserDirectory*(). Let's make it *a bit* closer to consistent (at least the libvirt API names will be consistent with each other, even if glib isn't). Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 4 ++-- src/qemu/qemu_interop_config.c | 2 +- src/rpc/virnetclient.c | 4 ++-- src/rpc/virnettlsconfig.c | 2 +- src/util/virutil.c | 10 +++++----- src/util/virutil.h | 4 ++-- src/vbox/vbox_storage.c | 2 +- tools/virt-login-shell-helper.c | 2 +- tools/vsh.c | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b200037189..a2636652ef 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3723,8 +3723,8 @@ virGetSystemPageSize; virGetSystemPageSizeKB; virGetUserCacheDirectory; virGetUserConfigDirectory; -virGetUserDirectory; -virGetUserDirectoryByUID; +virGetUserHomeDirectory; +virGetUserHomeDirectoryByUID; virGetUserID; virGetUserName; virGetUserRuntimeDirectory; diff --git a/src/qemu/qemu_interop_config.c b/src/qemu/qemu_interop_config.c index 08fb68c901..2280b8a2df 100644 --- a/src/qemu/qemu_interop_config.c +++ b/src/qemu/qemu_interop_config.c @@ -105,7 +105,7 @@ qemuInteropFetchConfigs(const char *name, xdgConfig =3D g_strdup(getenv("XDG_CONFIG_HOME")); =20 if (!xdgConfig) { - g_autofree char *home =3D virGetUserDirectory(); + g_autofree char *home =3D virGetUserHomeDirectory(); =20 xdgConfig =3D g_strdup_printf("%s/.config", home); } diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index ee729d5e62..3ad4655e6e 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -539,7 +539,7 @@ virNetClient *virNetClientNewLibSSH2(const char *host, if (privkeyPath) { privkey =3D g_strdup(privkeyPath); } else { - homedir =3D virGetUserDirectory(); + homedir =3D virGetUserHomeDirectory(); if (virNetClientFindDefaultSshKey(homedir, &privkey) < 0) return NULL; } @@ -604,7 +604,7 @@ virNetClient *virNetClientNewLibssh(const char *host, if (privkeyPath) { privkey =3D g_strdup(privkeyPath); } else { - homedir =3D virGetUserDirectory(); + homedir =3D virGetUserHomeDirectory(); if (virNetClientFindDefaultSshKey(homedir, &privkey) < 0) return NULL; } diff --git a/src/rpc/virnettlsconfig.c b/src/rpc/virnettlsconfig.c index eec20cf6b7..6ad7a02779 100644 --- a/src/rpc/virnettlsconfig.c +++ b/src/rpc/virnettlsconfig.c @@ -36,7 +36,7 @@ VIR_LOG_INIT("rpc.nettlsconfig"); =20 char *virNetTLSConfigUserPKIBaseDir(void) { - g_autofree char *userdir =3D virGetUserDirectory(); + g_autofree char *userdir =3D virGetUserHomeDirectory(); =20 return g_strdup_printf("%s/.pki/libvirt", userdir); } diff --git a/src/util/virutil.c b/src/util/virutil.c index fb64237692..3c0d04c3d7 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -589,7 +589,7 @@ virGetHostnameQuiet(void) =20 =20 char * -virGetUserDirectory(void) +virGetUserHomeDirectory(void) { return g_strdup(g_get_home_dir()); } @@ -753,7 +753,7 @@ static char *virGetGroupEnt(gid_t gid) =20 =20 char * -virGetUserDirectoryByUID(uid_t uid) +virGetUserHomeDirectoryByUID(uid_t uid) { char *ret; virGetUserEnt(uid, NULL, NULL, &ret, NULL, false); @@ -1091,7 +1091,7 @@ virDoesGroupExist(const char *name G_GNUC_UNUSED) =20 # ifdef WIN32 char * -virGetUserDirectoryByUID(uid_t uid G_GNUC_UNUSED) +virGetUserHomeDirectoryByUID(uid_t uid G_GNUC_UNUSED) { /* Since Windows lacks setuid binaries, and since we already fake * geteuid(), we can safely assume that this is only called when @@ -1111,10 +1111,10 @@ virGetUserShell(uid_t uid G_GNUC_UNUSED) =20 # else /* !WITH_GETPWUID_R && !WIN32 */ char * -virGetUserDirectoryByUID(uid_t uid G_GNUC_UNUSED) +virGetUserHomeDirectoryByUID(uid_t uid G_GNUC_UNUSED) { virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("virGetUserDirectory is not available")); + "%s", _("virGetUserHomeDirectory is not available")); =20 return NULL; } diff --git a/src/util/virutil.h b/src/util/virutil.h index 7e1705e7ce..2accb5777d 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -95,8 +95,8 @@ static inline int pthread_sigmask(int how, char *virGetHostname(void) ATTRIBUTE_MOCKABLE; char *virGetHostnameQuiet(void); =20 -char *virGetUserDirectory(void); -char *virGetUserDirectoryByUID(uid_t uid); +char *virGetUserHomeDirectory(void); +char *virGetUserHomeDirectoryByUID(uid_t uid); char *virGetUserConfigDirectory(void); char *virGetUserCacheDirectory(void); char *virGetUserRuntimeDirectory(void) ATTRIBUTE_MOCKABLE; diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index 56be618fb8..72c67d2143 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -445,7 +445,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, =20 /* If target.path isn't given, use default path ~/.VirtualBox/image_na= me */ if (!def->target.path) { - homedir =3D virGetUserDirectory(); + homedir =3D virGetUserHomeDirectory(); def->target.path =3D g_strdup_printf("%s/.VirtualBox/%s", homedir,= def->name); } VBOX_UTF8_TO_UTF16(def->target.path, &hddNameUtf16); diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helpe= r.c index cb59b5dec0..a1c68a1afa 100644 --- a/tools/virt-login-shell-helper.c +++ b/tools/virt-login-shell-helper.c @@ -253,7 +253,7 @@ main(int argc, char **argv) if (!name) goto cleanup; =20 - homedir =3D virGetUserDirectoryByUID(uid); + homedir =3D virGetUserHomeDirectoryByUID(uid); if (!homedir) goto cleanup; =20 diff --git a/tools/vsh.c b/tools/vsh.c index 69d3930e43..18914cc818 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -3333,7 +3333,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd) g_autofree char *dir_malloced =3D NULL; =20 if (vshCommandOptStringQuiet(ctl, cmd, "dir", &dir) <=3D 0) - dir =3D dir_malloced =3D virGetUserDirectory(); + dir =3D dir_malloced =3D virGetUserHomeDirectory(); if (!dir) dir =3D "/"; =20 --=20 2.52.0 From nobody Tue Mar 3 03:06:30 2026 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=1771921570; cv=none; d=zohomail.com; s=zohoarc; b=eZD0L8TNnl6R48UcjypMMQXW7Ur+6gooiavBx/CcXrnzOxVHdsXJa0U0lMI2dzzAvzltKfnq52eCP1j8NzWZPtLRoe0MW2dYUR80RsI8ZDO/+uIK8r1Am1clFr/LKCLQu26RWFn2Q907+0fUwznUIeRXBvtxBLVwit58lRiD1zo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771921570; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner: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=n85VE7GsO3HbebD7EZE9YVp4Gw/o3xWSMZZBEo7QMUU=; b=YWYw2jJq1kNR+LzlrcpJaX9SNMBpLCB+iqG8Ra592Zp4VSb+kxacRbwPR/0rOSR/ThtuCWCHqEse7eSckY3vtPKYHBYQeNN3U4zwmA+UabwIN5vlEx8VrlbOFCxUgKCxUgKvh5kA/UOvFfJLRrH4IYd+sT3Y93jKigZb/HNv+lQ= 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 1771921570443148.45385990518105; Tue, 24 Feb 2026 00:26:10 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id A82D041CDD; Tue, 24 Feb 2026 03:26:09 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 3173541D6D; Tue, 24 Feb 2026 03:23:08 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id A224B41B5A; Tue, 24 Feb 2026 03:22:49 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 379C341B5C for ; Tue, 24 Feb 2026 03:22:49 -0500 (EST) Received: from mx-prod-mc-01.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-628-yJcFWqO_O_2aOlUiG9OaUg-1; Tue, 24 Feb 2026 03:22:47 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DE2191956096 for ; Tue, 24 Feb 2026 08:22:46 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.82]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 839B21800465 for ; Tue, 24 Feb 2026 08:22:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771921368; 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=n85VE7GsO3HbebD7EZE9YVp4Gw/o3xWSMZZBEo7QMUU=; b=ifmyrOEPFxLtJy9bS64yPZmksE5gxswkNXWVzdATi0vwUafk6ZDiSn4IjIFsEVcmDZjUxu XuMgdmErm/FrouG954COW0BTIvS0eP/g3mvVikZIlnTudXSHrbQjY1Nh1jU4ltMsPEr627 JYggjDX0/LR3FzPDj++Tk8uKtvvlmGg= X-MC-Unique: yJcFWqO_O_2aOlUiG9OaUg-1 X-Mimecast-MFC-AGG-ID: yJcFWqO_O_2aOlUiG9OaUg_1771921367 To: devel@lists.libvirt.org Subject: [PATCH 5/8] util: make completely separate functions for WIN32 versions of virGetUser*Directory() Date: Tue, 24 Feb 2026 03:22:39 -0500 Message-ID: <20260224082242.274009-6-laine@redhat.com> In-Reply-To: <20260224082242.274009-1-laine@redhat.com> References: <20260224082242.274009-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: J02LUV3YqTyx0q6-PworI2pLo15PD3j0YugVrYYShww_1771921367 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QTSKT54WYVSMNTGYSXISUSERTJYMJ56Y X-Message-ID-Hash: QTSKT54WYVSMNTGYSXISUSERTJYMJ56Y X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1771921571944158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump This will make it easier to, e.g., add sanity checks to the Linux versions of these functions without potentially causing regressions on a platform that isn't widely tested Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/util/virutil.c | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/util/virutil.c b/src/util/virutil.c index 3c0d04c3d7..b40229c7cf 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -588,43 +588,64 @@ virGetHostnameQuiet(void) } =20 =20 + +#ifdef WIN32 + + char * virGetUserHomeDirectory(void) { return g_strdup(g_get_home_dir()); } =20 - char *virGetUserConfigDirectory(void) { -#ifdef WIN32 return g_strdup(g_get_user_config_dir()); -#else - return g_build_filename(g_get_user_config_dir(), "libvirt", NULL); -#endif } =20 =20 char *virGetUserCacheDirectory(void) { -#ifdef WIN32 return g_strdup(g_get_user_cache_dir()); -#else - return g_build_filename(g_get_user_cache_dir(), "libvirt", NULL); -#endif } =20 =20 char *virGetUserRuntimeDirectory(void) { -#ifdef WIN32 return g_strdup(g_get_user_runtime_dir()); -#else +} + + +#else /* !WIN32 */ + + +char * +virGetUserHomeDirectory(void) +{ + return g_strdup(g_get_home_dir()); +} + +char *virGetUserConfigDirectory(void) +{ + return g_build_filename(g_get_user_config_dir(), "libvirt", NULL); +} + + +char *virGetUserCacheDirectory(void) +{ + return g_build_filename(g_get_user_cache_dir(), "libvirt", NULL); +} + + +char *virGetUserRuntimeDirectory(void) +{ return g_build_filename(g_get_user_runtime_dir(), "libvirt", NULL); -#endif } =20 =20 +#endif /* !WIN32 */ + + #ifdef WITH_GETPWUID_R /* Look up fields from the user database for the given user. On * error, set errno, report the error if not instructed otherwise via @qui= et, --=20 2.52.0 From nobody Tue Mar 3 03:06:30 2026 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=1771921829; cv=none; d=zohomail.com; s=zohoarc; b=ZBdh6XU/ZYf9Q4Ot8Pw3ScgbpU4chdYQdQH/2tFLgsgqDvyDuDIUiFigF5vNtaZ5pqJjRFytA2jJkRzRWpJzLKo6F1WWbBcm6AM1DptjkbJT7/GJctDmrNzAq6zcOSDCQJM0idCe8rOSjcgOUUuGO/sb2XkGu76bYFCf7SHWZUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771921829; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner: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=Z+RmMBh7JT0NV7vnnnqiCzPBi2rgJdTEfBgl9nkwZGE=; b=j5/Ec1+Ykm1m8ta3fjIkNSMmRNYjRgHCeVL9j1yKDVWdyUdhGV7JFM/mgrlbXrW3mfCT70cI3RL2QG5ebEZnp5WUV6p32GItiTXu8byQJJFh1MqWOmJ9Hn0Mfb/oKgqY8rIl5SJmxIJBtXxjGMfo9FtCbPAFaQ2uKKFbSiSrJjM= 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 1771921829185943.7130169778873; Tue, 24 Feb 2026 00:30:29 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 1E58D41C9C; Tue, 24 Feb 2026 03:30:28 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id A629543DBB; Tue, 24 Feb 2026 03:23:56 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 4286641B54; Tue, 24 Feb 2026 03:22:52 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E329141B5C for ; Tue, 24 Feb 2026 03:22:50 -0500 (EST) Received: from mx-prod-mc-06.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-596-AaMKhvMmNwKK0B16BlfKGQ-1; Tue, 24 Feb 2026 03:22:48 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9376018003F6 for ; Tue, 24 Feb 2026 08:22:47 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.82]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1D9ED1800465 for ; Tue, 24 Feb 2026 08:22:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771921370; 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=Z+RmMBh7JT0NV7vnnnqiCzPBi2rgJdTEfBgl9nkwZGE=; b=gBJXE4yi0NQW4529+FRAnrL/QrhH3ZnBp0b1cLKsnPHQSu/yzM4p6Cowi+CTmq9QcQSoRz bUxv7uaXwufrXgwfMjvUln284l06eelc/bSx9+pKUk0R2xkt2zriiYNiJLIwtMidrYtWkS iRqVjJnlTZD3qao/0+b5kklVTS/HbCw= X-MC-Unique: AaMKhvMmNwKK0B16BlfKGQ-1 X-Mimecast-MFC-AGG-ID: AaMKhvMmNwKK0B16BlfKGQ_1771921367 To: devel@lists.libvirt.org Subject: [PATCH 6/8] consistently use glib g_getenv() instead of libc getenv() Date: Tue, 24 Feb 2026 03:22:40 -0500 Message-ID: <20260224082242.274009-7-laine@redhat.com> In-Reply-To: <20260224082242.274009-1-laine@redhat.com> References: <20260224082242.274009-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 7hWdi3-1vgL114TJALi-eP-U-gXd2SPRsUJDlLThSxQ_1771921367 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6RRU6EQOCGSF26N4UNQOF73HXWU4XC3R X-Message-ID-Hash: 6RRU6EQOCGSF26N4UNQOF73HXWU4XC3R X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1771921831163158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump We've been using glib g_setenv() since commit 2c3353242337bb50fe5abc9454fd5fc98236d4ef in December 2019 (switching away from the gnulib version of setenv()). Most (but not all) of the calls to get environment variables have remained using libc's getenv() though, even though there is a g_getenv() wrapper in glib to match the g_setenv() wrapper. While getenv() doesn't have the thread safety problems of setenv(), it's still recommended that users of g_setenv() also use g_getenv() (for consistency, and because the glib functions handle UTF-8 properly while libc getenv() may or may not depending on the setting of LANG in the environment). This patch changes all calls to getenv() to use g_getenv() instead, with the exceptions of: 1) the call to getenv() in virt-login-shell.c (because virt-login-shell runs setuid root, and we don't want glib or any other gigantic library anywhere near a setuid program). In a few cases a char * needs to be made const, and the return from getenv() needs to be g_strdup()ed if it must stick around for any amount of time (since the buffer returned from g_getenv() might be recycled/re-used if there is another call to g_getenv()/g_setenv()). 2) the call to getenv() in libvirt_nss_log.c because it is compiled into a loadable module that will be loaded into a process after the process's normal startup, and so any initialization that might be required for a glib function to operate properly may not be called. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- scripts/rpcgen/tests/test_demo.c | 2 +- src/admin/libvirt-admin.c | 2 +- src/hyperv/hyperv_driver.c | 2 +- src/libvirt.c | 2 +- src/network/leaseshelper.c | 14 +++++++------- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_interop_config.c | 2 +- src/remote/remote_sockets.c | 4 ++-- src/rpc/virnetlibsshsession.c | 2 +- src/rpc/virnettlscontext.c | 2 +- src/util/virauth.c | 2 +- src/util/vircommand.c | 2 +- src/util/virfile.c | 4 ++-- src/util/virlease.c | 4 ++-- src/util/virlog.c | 6 +++--- src/util/virsystemd.c | 8 ++++---- src/vbox/vbox_XPCOMCGlue.c | 2 +- src/vbox/vbox_common.c | 2 +- tests/eventtest.c | 2 +- tests/fdstreamtest.c | 2 +- tests/qemucpumock.c | 2 +- tests/qemusecuritymock.c | 16 ++++++++-------- tests/securityselinuxhelper.c | 10 +++++----- tests/testutils.c | 16 ++++++++-------- tests/testutils.h | 2 +- tests/testutilsqemu.c | 2 +- tests/vircgroupmock.c | 10 +++++----- tests/virfilemock.c | 8 ++++---- tests/virhostdevtest.c | 2 +- tests/virmockstathelpers.c | 2 +- tests/virnetdaemontest.c | 2 +- tests/virnettlshelpers.c | 2 +- tests/virpcimock.c | 2 +- tests/virportallocatormock.c | 4 ++-- tests/virscsitest.c | 2 +- tests/virsystemdtest.c | 14 +++++++------- tests/virtestmock.c | 6 +++--- tools/virsh.c | 2 +- tools/virt-login-shell-helper.c | 2 +- tools/vsh.c | 12 ++++++------ 40 files changed, 93 insertions(+), 93 deletions(-) diff --git a/scripts/rpcgen/tests/test_demo.c b/scripts/rpcgen/tests/test_d= emo.c index 82eda89592..bbf00e88a5 100644 --- a/scripts/rpcgen/tests/test_demo.c +++ b/scripts/rpcgen/tests/test_demo.c @@ -41,7 +41,7 @@ static void test_xdr(xdrproc_t proc, void *vorig, void *v= new, const char *testna =20 actlen =3D xdr_getpos(&xdr); =20 - if (getenv("VIR_TEST_REGENERATE_OUTPUT")) { + if (g_getenv("VIR_TEST_REGENERATE_OUTPUT")) { g_file_set_contents(expfile, buf, actlen, NULL); } =20 diff --git a/src/admin/libvirt-admin.c b/src/admin/libvirt-admin.c index d7efac025f..eebe701fae 100644 --- a/src/admin/libvirt-admin.c +++ b/src/admin/libvirt-admin.c @@ -163,7 +163,7 @@ getSocketPath(virURI *uri) static int virAdmGetDefaultURI(virConf *conf, char **uristr) { - const char *defname =3D getenv("LIBVIRT_ADMIN_DEFAULT_URI"); + const char *defname =3D g_getenv("LIBVIRT_ADMIN_DEFAULT_URI"); if (defname && *defname) { *uristr =3D g_strdup(defname); VIR_DEBUG("Using LIBVIRT_ADMIN_DEFAULT_URI '%s'", *uristr); diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index b01b4919fe..5f51644e52 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -2461,7 +2461,7 @@ hypervDomainScreenshot(virDomainPtr domain, ppmBuffer[i * 3 + 2] =3D (blueFive * 527 + 23) >> 6; } =20 - temporaryDirectory =3D getenv("TMPDIR"); + temporaryDirectory =3D g_getenv("TMPDIR"); if (!temporaryDirectory) temporaryDirectory =3D "/tmp"; temporaryFile =3D g_strdup_printf("%s/libvirt.hyperv.screendump.XXXXXX= ", temporaryDirectory); diff --git a/src/libvirt.c b/src/libvirt.c index 375d3fa7ef..b38d21575a 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -881,7 +881,7 @@ static int virConnectGetDefaultURI(virConf *conf, char **name) { - const char *defname =3D getenv("LIBVIRT_DEFAULT_URI"); + const char *defname =3D g_getenv("LIBVIRT_DEFAULT_URI"); if (defname && *defname) { VIR_DEBUG("Using LIBVIRT_DEFAULT_URI '%s'", defname); *name =3D g_strdup(defname); diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c index 8206712e12..66a1003785 100644 --- a/src/network/leaseshelper.c +++ b/src/network/leaseshelper.c @@ -84,10 +84,10 @@ main(int argc, char **argv) const char *ip =3D NULL; const char *mac =3D NULL; g_autofree char *leases_str =3D NULL; - const char *iaid =3D getenv("DNSMASQ_IAID"); - const char *clientid =3D getenv("DNSMASQ_CLIENT_ID"); - const char *interface =3D getenv("DNSMASQ_INTERFACE"); - const char *hostname =3D getenv("DNSMASQ_SUPPLIED_HOSTNAME"); + const char *iaid =3D g_getenv("DNSMASQ_IAID"); + const char *clientid =3D g_getenv("DNSMASQ_CLIENT_ID"); + const char *interface =3D g_getenv("DNSMASQ_INTERFACE"); + const char *hostname =3D g_getenv("DNSMASQ_SUPPLIED_HOSTNAME"); g_autofree char *server_duid =3D NULL; int action =3D -1; int pid_file_fd =3D -1; @@ -128,7 +128,7 @@ main(int argc, char **argv) * events for expired leases. So, libvirtd sets another env var for th= is * purpose */ if (!interface && - !(interface =3D getenv("VIR_BRIDGE_NAME"))) { + !(interface =3D g_getenv("VIR_BRIDGE_NAME"))) { fprintf(stderr, _("interface not set\n")); exit(EXIT_FAILURE); } @@ -147,11 +147,11 @@ main(int argc, char **argv) =20 /* Check if it is an IPv6 lease */ if (iaid) { - mac =3D getenv("DNSMASQ_MAC"); + mac =3D g_getenv("DNSMASQ_MAC"); clientid =3D argv[2]; } =20 - server_duid =3D g_strdup(getenv("DNSMASQ_SERVER_DUID")); + server_duid =3D g_strdup(g_getenv("DNSMASQ_SERVER_DUID")); =20 custom_lease_file =3D g_strdup_printf(LOCALSTATEDIR "/lib/libvirt/dnsm= asq/%s.status", interface); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a742998e4c..61e1c4b575 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8229,7 +8229,7 @@ qemuBuildAudioPipewireAudioEnv(virCommand *cmd, virCommandAddEnvPair(cmd, "PIPEWIRE_RUNTIME_DIR", runtimeDir); } else { for (i =3D 0; i < G_N_ELEMENTS(envVars); i++) { - const char *value =3D getenv(envVars[i]); + const char *value =3D g_getenv(envVars[i]); =20 if (!value) continue; diff --git a/src/qemu/qemu_interop_config.c b/src/qemu/qemu_interop_config.c index 2280b8a2df..3f7b30f8e0 100644 --- a/src/qemu/qemu_interop_config.c +++ b/src/qemu/qemu_interop_config.c @@ -102,7 +102,7 @@ qemuInteropFetchConfigs(const char *name, * much sense to parse files in root's home directory. It * makes sense only for session daemon which runs under * regular user. */ - xdgConfig =3D g_strdup(getenv("XDG_CONFIG_HOME")); + xdgConfig =3D g_strdup(g_getenv("XDG_CONFIG_HOME")); =20 if (!xdgConfig) { g_autofree char *home =3D virGetUserHomeDirectory(); diff --git a/src/remote/remote_sockets.c b/src/remote/remote_sockets.c index 13b760355b..b00705cd21 100644 --- a/src/remote/remote_sockets.c +++ b/src/remote/remote_sockets.c @@ -55,7 +55,7 @@ remoteGetDaemonPathEnv(void) * but if it is not set we will fallback to LIBVIRTD_PATH * for previous behaviour */ - if (getenv("VIRTD_PATH") !=3D NULL) { + if (g_getenv("VIRTD_PATH") !=3D NULL) { return "VIRTD_PATH"; } else { return "LIBVIRTD_PATH"; @@ -440,7 +440,7 @@ remoteGetURIDaemonInfo(virURI *uri, remoteDriverTransport transport, unsigned int *flags) { - const char *autostart_str =3D getenv("LIBVIRT_AUTOSTART"); + const char *autostart_str =3D g_getenv("LIBVIRT_AUTOSTART"); =20 *flags =3D 0; =20 diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index e496d3334e..2f590ec1c4 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -161,7 +161,7 @@ virNetLibsshSessionOnceInit(void) ssh_set_log_level(TRACE_LIBSSH); #endif =20 - dbgLevelStr =3D getenv("LIBVIRT_LIBSSH_DEBUG"); + dbgLevelStr =3D g_getenv("LIBVIRT_LIBSSH_DEBUG"); if (dbgLevelStr && virStrToLong_i(dbgLevelStr, NULL, 10, &dbgLevel) >=3D 0) ssh_set_log_level(dbgLevel); diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c index dfe793e5db..5fed5c71b5 100644 --- a/src/rpc/virnettlscontext.c +++ b/src/rpc/virnettlscontext.c @@ -827,7 +827,7 @@ void virNetTLSSessionDispose(void *obj) void virNetTLSInit(void) { const char *gnutlsdebug; - if ((gnutlsdebug =3D getenv("LIBVIRT_GNUTLS_DEBUG")) !=3D NULL) { + if ((gnutlsdebug =3D g_getenv("LIBVIRT_GNUTLS_DEBUG")) !=3D NULL) { int val; if (virStrToLong_i(gnutlsdebug, NULL, 10, &val) < 0) val =3D 10; diff --git a/src/util/virauth.c b/src/util/virauth.c index e7a5f7f010..fd4b13de7a 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -42,7 +42,7 @@ virAuthGetConfigFilePathURI(virURI *uri, char **path) { size_t i; - const char *authenv =3D getenv("LIBVIRT_AUTH_FILE"); + const char *authenv =3D g_getenv("LIBVIRT_AUTH_FILE"); g_autofree char *userdir =3D NULL; =20 *path =3D NULL; diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 1390c80a32..e871d572a6 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1429,7 +1429,7 @@ virCommandAddEnvPass(virCommand *cmd, const char *nam= e) if (virCommandHasError(cmd)) return; =20 - value =3D getenv(name); + value =3D g_getenv(name); if (value) virCommandAddEnvPair(cmd, name, value); } diff --git a/src/util/virfile.c b/src/util/virfile.c index 65b04beb8c..91d5853481 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1912,7 +1912,7 @@ virFileFindResourceFull(const char *filename, const char *envname) { char *ret =3D NULL; - const char *envval =3D envname ? getenv(envname) : NULL; + const char *envval =3D envname ? g_getenv(envname) : NULL; const char *path; g_autofree char *fullFilename =3D NULL; =20 @@ -1977,7 +1977,7 @@ virFileActivateDirOverrideForProg(const char *argv0) void virFileActivateDirOverrideForLib(void) { - if (getenv("LIBVIRT_DIR_OVERRIDE") !=3D NULL) + if (g_getenv("LIBVIRT_DIR_OVERRIDE") !=3D NULL) useDirOverride =3D true; } =20 diff --git a/src/util/virlease.c b/src/util/virlease.c index 6fd7b88d88..a8d53efe5b 100644 --- a/src/util/virlease.c +++ b/src/util/virlease.c @@ -208,13 +208,13 @@ virLeaseNew(virJSONValue **lease_ret, const char *server_duid) { g_autoptr(virJSONValue) lease_new =3D NULL; - const char *exptime_tmp =3D getenv("DNSMASQ_LEASE_EXPIRES"); + const char *exptime_tmp =3D g_getenv("DNSMASQ_LEASE_EXPIRES"); long long expirytime =3D 0; g_autofree char *exptime =3D NULL; =20 /* In case hostname is still unknown, use the last known one */ if (!hostname) - hostname =3D getenv("DNSMASQ_OLD_HOSTNAME"); + hostname =3D g_getenv("DNSMASQ_OLD_HOSTNAME"); =20 if (!mac) return 0; diff --git a/src/util/virlog.c b/src/util/virlog.c index 2d262d94f0..c24dfa83c4 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1214,18 +1214,18 @@ virLogSetFromEnv(void) if (virLogInitialize() < 0) return -1; =20 - debugEnv =3D getenv("LIBVIRT_DEBUG"); + debugEnv =3D g_getenv("LIBVIRT_DEBUG"); if (debugEnv && *debugEnv) { int priority =3D virLogParseDefaultPriority(debugEnv); if (priority < 0 || virLogSetDefaultPriority(priority) < 0) return -1; } - debugEnv =3D getenv("LIBVIRT_LOG_FILTERS"); + debugEnv =3D g_getenv("LIBVIRT_LOG_FILTERS"); if (debugEnv && *debugEnv && virLogSetFilters(debugEnv)) return -1; - debugEnv =3D getenv("LIBVIRT_LOG_OUTPUTS"); + debugEnv =3D g_getenv("LIBVIRT_LOG_OUTPUTS"); if (debugEnv && *debugEnv && virLogSetOutputs(debugEnv)) return -1; diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index bd174c683e..faac8b37e3 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -666,7 +666,7 @@ virSystemdNotify(const char *msg) =20 VIR_DEBUG("Notify '%s'", msg); =20 - if (!(path =3D getenv("NOTIFY_SOCKET"))) { + if (!(path =3D g_getenv("NOTIFY_SOCKET"))) { VIR_DEBUG("Skipping systemd notify, not requested"); return; } @@ -891,7 +891,7 @@ virSystemdGetListenFDs(void) =20 VIR_DEBUG("Setting up networking from caller"); =20 - if (!(pidstr =3D getenv("LISTEN_PID"))) { + if (!(pidstr =3D g_getenv("LISTEN_PID"))) { VIR_DEBUG("No LISTEN_PID from caller"); return 0; } @@ -907,7 +907,7 @@ virSystemdGetListenFDs(void) return 0; } =20 - if (!(fdstr =3D getenv("LISTEN_FDS"))) { + if (!(fdstr =3D g_getenv("LISTEN_FDS"))) { VIR_DEBUG("No LISTEN_FDS from caller"); return 0; } @@ -954,7 +954,7 @@ virSystemdActivationNew(int nfds) =20 act->fds =3D virHashNew(virSystemdActivationEntryFree); =20 - fdnames =3D getenv("LISTEN_FDNAMES"); + fdnames =3D g_getenv("LISTEN_FDNAMES"); if (!fdnames) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing LISTEN_FDNAMES env from systemd socket a= ctivation")); diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c index e625492173..a67ceb9a00 100644 --- a/src/vbox/vbox_XPCOMCGlue.c +++ b/src/vbox/vbox_XPCOMCGlue.c @@ -181,7 +181,7 @@ VBoxCGlueInit(unsigned int *version) "/usr/local/lib/VirtualBox", "/Applications/VirtualBox.app/Contents/MacOS" }; - const char *home =3D getenv("VBOX_APP_HOME"); + const char *home =3D g_getenv("VBOX_APP_HOME"); =20 /* If the user specifies the location, try only that. */ if (home !=3D NULL) { diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index d2a8cf8da4..882f9e1f01 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3578,7 +3578,7 @@ vboxDumpDisplay(virDomainDef *def, struct _vboxDriver= *data, IMachine *machine) graphics =3D g_new0(virDomainGraphicsDef, 1); =20 graphics->type =3D VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP; - graphics->data.desktop.display =3D g_strdup(getenv("DISPLAY")); + graphics->data.desktop.display =3D g_strdup(g_getenv("DISPLAY")); } =20 if (graphics) diff --git a/tests/eventtest.c b/tests/eventtest.c index 470de4c630..5f78e1fcfe 100644 --- a/tests/eventtest.c +++ b/tests/eventtest.c @@ -323,7 +323,7 @@ mymain(void) size_t i; pthread_t eventThread; char one =3D '1'; - char *debugEnv =3D getenv("LIBVIRT_DEBUG"); + const char *debugEnv =3D g_getenv("LIBVIRT_DEBUG"); =20 for (i =3D 0; i < NUM_FDS; i++) { if (virPipeQuiet(handles[i].pipeFD) < 0) { diff --git a/tests/fdstreamtest.c b/tests/fdstreamtest.c index 5e6b347949..9d244681f7 100644 --- a/tests/fdstreamtest.c +++ b/tests/fdstreamtest.c @@ -319,7 +319,7 @@ mymain(void) if (virTestRun("Stream write non-blocking ", testFDStreamWriteNonblock= , scratchdir) < 0) ret =3D -1; =20 - if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) + if (g_getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) virFileDeleteTree(scratchdir); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/qemucpumock.c b/tests/qemucpumock.c index 5a63308347..c85721f448 100644 --- a/tests/qemucpumock.c +++ b/tests/qemucpumock.c @@ -29,7 +29,7 @@ virCPUDef * virQEMUCapsProbeHostCPU(virArch hostArch G_GNUC_UNUSED, virDomainCapsCPUModels *models G_GNUC_UNUSED) { - const char *model =3D getenv("VIR_TEST_MOCK_FAKE_HOST_CPU"); + const char *model =3D g_getenv("VIR_TEST_MOCK_FAKE_HOST_CPU"); =20 return testUtilsHostCpusGetDefForModel(model); } diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c index d5c711b5d7..cbd928ab38 100644 --- a/tests/qemusecuritymock.c +++ b/tests/qemusecuritymock.c @@ -231,7 +231,7 @@ int virFileRemoveXAttr(const char *path, =20 #define VIR_MOCK_STAT_HOOK \ do { \ - if (getenv(ENVVAR)) { \ + if (g_getenv(ENVVAR)) { \ uint32_t *val; \ \ virMutexLock(&m); \ @@ -303,7 +303,7 @@ chown(const char *path, uid_t uid, gid_t gid) =20 init_syms(); =20 - if (getenv(ENVVAR)) + if (g_getenv(ENVVAR)) ret =3D mock_chown(path, uid, gid); else ret =3D real_chown(path, uid, gid); @@ -319,7 +319,7 @@ open(const char *path, int flags, ...) =20 init_syms(); =20 - if (getenv(ENVVAR)) { + if (g_getenv(ENVVAR)) { ret =3D 42; /* Some dummy FD */ } else if (flags & O_CREAT) { va_list ap; @@ -344,7 +344,7 @@ __open_2(const char *path, int flags) =20 init_syms(); =20 - if (getenv(ENVVAR)) { + if (g_getenv(ENVVAR)) { ret =3D 42; /* Some dummy FD */ } else { ret =3D real___open_2(path, flags); @@ -361,7 +361,7 @@ close(int fd) =20 init_syms(); =20 - if (fd =3D=3D 42 && getenv(ENVVAR)) + if (fd =3D=3D 42 && g_getenv(ENVVAR)) ret =3D 0; else ret =3D real_close(fd); @@ -392,7 +392,7 @@ bool virFileExists(const char *path) { VIR_LOCK_GUARD lock =3D virLockGuardLock(&m); =20 - if (getenv(ENVVAR) =3D=3D NULL) { + if (g_getenv(ENVVAR) =3D=3D NULL) { init_syms(); =20 return real_virFileExists(path); @@ -640,7 +640,7 @@ setfilecon_raw(const char *path, =20 init_syms(); =20 - if (getenv(ENVVAR)) + if (g_getenv(ENVVAR)) ret =3D mock_setfilecon_raw(path, context); else ret =3D real_setfilecon_raw(path, context); @@ -657,7 +657,7 @@ getfilecon_raw(const char *path, =20 init_syms(); =20 - if (getenv(ENVVAR)) + if (g_getenv(ENVVAR)) ret =3D mock_getfilecon_raw(path, context); else ret =3D real_getfilecon_raw(path, context); diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c index e5ded96485..be9d03e815 100644 --- a/tests/securityselinuxhelper.c +++ b/tests/securityselinuxhelper.c @@ -92,12 +92,12 @@ int getcon_raw(char **context) errno =3D EINVAL; return -1; } - if (getenv("FAKE_SELINUX_CONTEXT") =3D=3D NULL) { + if (g_getenv("FAKE_SELINUX_CONTEXT") =3D=3D NULL) { *context =3D NULL; errno =3D EINVAL; return -1; } - *context =3D g_strdup(getenv("FAKE_SELINUX_CONTEXT")); + *context =3D g_strdup(g_getenv("FAKE_SELINUX_CONTEXT")); return 0; } =20 @@ -117,12 +117,12 @@ int getpidcon_raw(pid_t pid, char **context) errno =3D ESRCH; return -1; } - if (getenv("FAKE_SELINUX_CONTEXT") =3D=3D NULL) { + if (g_getenv("FAKE_SELINUX_CONTEXT") =3D=3D NULL) { *context =3D NULL; errno =3D EINVAL; return -1; } - *context =3D g_strdup(getenv("FAKE_SELINUX_CONTEXT")); + *context =3D g_strdup(g_getenv("FAKE_SELINUX_CONTEXT")); return 0; } =20 @@ -191,7 +191,7 @@ int statfs(const char *path, struct statfs *buf) =20 int is_selinux_enabled(void) { - return getenv("FAKE_SELINUX_DISABLED") =3D=3D NULL; + return g_getenv("FAKE_SELINUX_DISABLED") =3D=3D NULL; } =20 int security_getenforce(void) diff --git a/tests/testutils.c b/tests/testutils.c index 3c5c298293..814391b804 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -73,10 +73,10 @@ static int virTestUseTerminalColors(void) static unsigned int virTestGetFlag(const char *name) { - char *flagStr; + const char *flagStr; unsigned int flag; =20 - if ((flagStr =3D getenv(name)) =3D=3D NULL) + if ((flagStr =3D g_getenv(name)) =3D=3D NULL) return 0; =20 if (virStrToLong_ui(flagStr, NULL, 10, &flag) < 0) @@ -123,7 +123,7 @@ virTestRun(const char *title, =20 /* Some test are fragile about environ settings. If that's * the case, don't poison it. */ - if (getenv("VIR_TEST_MOCK_PROGNAME")) + if (g_getenv("VIR_TEST_MOCK_PROGNAME")) g_setenv("VIR_TEST_MOCK_TESTNAME", title, TRUE); =20 if (testCounter =3D=3D 0 && !virTestGetVerbose()) @@ -760,7 +760,7 @@ virTestHasRangeBitmap(void) static int virTestSetEnvPath(void) { - const char *path =3D getenv("PATH"); + const char *path =3D g_getenv("PATH"); g_autofree char *new_path =3D NULL; =20 if (path) { @@ -813,7 +813,7 @@ int virTestMain(int argc, const char *lib; va_list ap; int ret; - char *testRange =3D NULL; + const char *testRange =3D NULL; size_t noutputs =3D 0; virLogOutput *output =3D NULL; virLogOutput **outputs =3D NULL; @@ -823,7 +823,7 @@ int virTestMain(int argc, g_autofree char *mock =3D NULL; g_autofree char *fakerootdir =3D NULL; =20 - if (getenv("VIR_TEST_FILE_ACCESS")) { + if (g_getenv("VIR_TEST_FILE_ACCESS")) { preloads =3D g_renew(const char *, preloads, npreloads + 2); preloads[npreloads++] =3D VIR_TEST_MOCK("virtest"); preloads[npreloads] =3D NULL; @@ -884,7 +884,7 @@ int virTestMain(int argc, if (virLogSetFromEnv() < 0) return EXIT_FAILURE; =20 - if (!getenv("LIBVIRT_DEBUG") && !virLogGetNbOutputs()) { + if (!g_getenv("LIBVIRT_DEBUG") && !virLogGetNbOutputs()) { if (!(output =3D virLogOutputNew(virtTestLogOutput, virtTestLogClo= se, &testLog, VIR_LOG_DEBUG, VIR_LOG_TO_STDERR, NULL))) @@ -898,7 +898,7 @@ int virTestMain(int argc, } } =20 - if ((testRange =3D getenv("VIR_TEST_RANGE")) !=3D NULL) { + if ((testRange =3D g_getenv("VIR_TEST_RANGE")) !=3D NULL) { if (!(testBitmap =3D virBitmapParseUnlimited(testRange))) { fprintf(stderr, "Cannot parse range %s\n", testRange); return EXIT_FAILURE; diff --git a/tests/testutils.h b/tests/testutils.h index e22324e06d..e60876bd9e 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -137,7 +137,7 @@ int virTestMain(int argc, =20 #define VIR_TEST_PRELOAD(libs) \ do { \ - const char *preload =3D getenv(PRELOAD_VAR); \ + const char *preload =3D g_getenv(PRELOAD_VAR); \ if (preload =3D=3D NULL || strstr(preload, libs) =3D=3D NULL) { \ char *newenv; \ char *new_library_path; \ diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 78ec521266..dbff601ce4 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -63,7 +63,7 @@ bool qemuRdpAvailable(const char *helper G_GNUC_UNUSED) bool virTPMSwtpmSetupCapsGet(virTPMSwtpmSetupFeature cap) { - const char *tpmver =3D getenv(TEST_TPM_ENV_VAR); + const char *tpmver =3D g_getenv(TEST_TPM_ENV_VAR); =20 switch (cap) { case VIR_TPM_SWTPM_SETUP_FEATURE_TPM_1_2: diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c index a5c18bd7b0..1aa6f047ce 100644 --- a/tests/vircgroupmock.c +++ b/tests/vircgroupmock.c @@ -321,7 +321,7 @@ static int make_controller(const char *path, mode_t mod= e) bool unified =3D false; bool hybrid =3D false; =20 - mock =3D getenv("VIR_CGROUP_MOCK_MODE"); + mock =3D g_getenv("VIR_CGROUP_MOCK_MODE"); if (mock) { if (STREQ(mock, "unified")) { unified =3D true; @@ -344,11 +344,11 @@ static int make_controller(const char *path, mode_t m= ode) static void init_sysfs(void) { const char *mock; - char *newfakerootdir; + const char *newfakerootdir; bool unified =3D false; bool hybrid =3D false; =20 - if (!(newfakerootdir =3D getenv("LIBVIRT_FAKE_ROOT_DIR"))) { + if (!(newfakerootdir =3D g_getenv("LIBVIRT_FAKE_ROOT_DIR"))) { fprintf(stderr, "Missing LIBVIRT_FAKE_ROOT_DIR env variable\n"); abort(); } @@ -359,7 +359,7 @@ static void init_sysfs(void) VIR_FREE(fakerootdir); fakerootdir =3D g_strdup(newfakerootdir); =20 - mock =3D getenv("VIR_CGROUP_MOCK_MODE"); + mock =3D g_getenv("VIR_CGROUP_MOCK_MODE"); if (mock) { if (STREQ(mock, "unified")) { unified =3D true; @@ -421,7 +421,7 @@ FILE *fopen(const char *path, const char *mode) char *filepath =3D NULL; const char *type =3D NULL; FILE *rc =3D NULL; - const char *filename =3D getenv("VIR_CGROUP_MOCK_FILENAME"); + const char *filename =3D g_getenv("VIR_CGROUP_MOCK_FILENAME"); =20 init_syms(); =20 diff --git a/tests/virfilemock.c b/tests/virfilemock.c index 5a09cce855..49538dcb71 100644 --- a/tests/virfilemock.c +++ b/tests/virfilemock.c @@ -56,7 +56,7 @@ setmntent(const char *filename, const char *type) =20 init_syms(); =20 - if ((mtab =3D getenv("LIBVIRT_MTAB"))) + if ((mtab =3D g_getenv("LIBVIRT_MTAB"))) filename =3D mtab; =20 return real_setmntent(filename, type); @@ -170,7 +170,7 @@ statfs(const char *path, struct statfs *buf) =20 init_syms(); =20 - if ((mtab =3D getenv("LIBVIRT_MTAB"))) + if ((mtab =3D g_getenv("LIBVIRT_MTAB"))) return statfs_mock(mtab, path, buf); =20 return real_statfs(path, buf); @@ -183,7 +183,7 @@ realpath(const char *path, char *resolved) =20 init_syms(); =20 - if (getenv("LIBVIRT_MTAB")) { + if (g_getenv("LIBVIRT_MTAB")) { const char *p; =20 if ((p =3D STRSKIP(path, "/some/symlink"))) { @@ -208,7 +208,7 @@ realpath(const char *path, char *resolved) int access(const char *path, int mode) { - const char *mtab =3D getenv("LIBVIRT_MTAB"); + const char *mtab =3D g_getenv("LIBVIRT_MTAB"); =20 init_syms(); =20 diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index a35c1d9402..b0fb94e197 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -104,7 +104,7 @@ myCleanup(void) virDomainDiskDefFree(disks[i]); =20 if (mgr) { - if (!getenv("LIBVIRT_SKIP_CLEANUP")) + if (!g_getenv("LIBVIRT_SKIP_CLEANUP")) virFileDeleteTree(mgr->stateDir); =20 virObjectUnref(mgr->activePCIHostdevs); diff --git a/tests/virmockstathelpers.c b/tests/virmockstathelpers.c index 8a76c5e369..5b1319cedc 100644 --- a/tests/virmockstathelpers.c +++ b/tests/virmockstathelpers.c @@ -171,7 +171,7 @@ static void virMockStatInit(void) return; =20 init =3D true; - debug =3D getenv("VIR_MOCK_STAT_DEBUG"); + debug =3D g_getenv("VIR_MOCK_STAT_DEBUG"); =20 #ifdef MOCK_STAT # if defined(__APPLE__) && defined(__x86_64__) diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c index 1a5c5f32e1..f2c3ae70ed 100644 --- a/tests/virnetdaemontest.c +++ b/tests/virnetdaemontest.c @@ -377,7 +377,7 @@ mymain(void) * the generated JSON, and replace the file descriptor * numbers with 100, 101, 102, 103. */ - if (getenv("VIR_GENERATE_JSON")) { + if (g_getenv("VIR_GENERATE_JSON")) { char *json =3D testGenerateJSON(server_names[0]); if (!json) return EXIT_FAILURE; diff --git a/tests/virnettlshelpers.c b/tests/virnettlshelpers.c index ca293eb6d6..620068e495 100644 --- a/tests/virnettlshelpers.c +++ b/tests/virnettlshelpers.c @@ -430,7 +430,7 @@ void testTLSDiscardCert(struct testTLSCertReq *req) =20 g_clear_pointer(&req->crt, gnutls_x509_crt_deinit); =20 - if (getenv("VIRT_TEST_DEBUG_CERTS") =3D=3D NULL) + if (g_getenv("VIRT_TEST_DEBUG_CERTS") =3D=3D NULL) unlink(req->filename); } =20 diff --git a/tests/virpcimock.c b/tests/virpcimock.c index ca345f37a3..a5cf0acfc7 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -981,7 +981,7 @@ init_env(void) .vpd_len =3D G_N_ELEMENTS(fullVPDExampleData), }; =20 - if (!(fakerootdir =3D getenv("LIBVIRT_FAKE_ROOT_DIR"))) { + if (!(fakerootdir =3D g_strdup(g_getenv("LIBVIRT_FAKE_ROOT_DIR")))) { GError *err =3D NULL; =20 fakerootdir =3D g_dir_make_tmp(NULL, &err); diff --git a/tests/virportallocatormock.c b/tests/virportallocatormock.c index 964f475944..5fd80c67a0 100644 --- a/tests/virportallocatormock.c +++ b/tests/virportallocatormock.c @@ -57,7 +57,7 @@ int socket(int domain, { init_syms(); =20 - if (getenv("LIBVIRT_TEST_IPV4ONLY") && domain =3D=3D AF_INET6) { + if (g_getenv("LIBVIRT_TEST_IPV4ONLY") && domain =3D=3D AF_INET6) { errno =3D EAFNOSUPPORT; return -1; } @@ -73,7 +73,7 @@ int bind(int sockfd G_GNUC_UNUSED, =20 memcpy(&saddr, addr, sizeof(saddr)); =20 - if (host_has_ipv6 && !getenv("LIBVIRT_TEST_IPV4ONLY")) { + if (host_has_ipv6 && !g_getenv("LIBVIRT_TEST_IPV4ONLY")) { if (saddr.sin_port =3D=3D htons(5900) || (saddr.sin_family =3D=3D AF_INET && saddr.sin_port =3D=3D htons(5904)) || diff --git a/tests/virscsitest.c b/tests/virscsitest.c index 2c3b599c7a..5cd127807f 100644 --- a/tests/virscsitest.c +++ b/tests/virscsitest.c @@ -211,7 +211,7 @@ mymain(void) ret =3D -1; =20 cleanup: - if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) + if (g_getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) virFileDeleteTree(tmpdir); VIR_FREE(virscsi_prefix); return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c index 24c118a409..b93462ae52 100644 --- a/tests/virsystemdtest.c +++ b/tests/virsystemdtest.c @@ -61,7 +61,7 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync); =20 if (STREQ(bus_name, "org.freedesktop.machine1")) { - if (getenv("FAIL_BAD_SERVICE")) { + if (g_getenv("FAIL_BAD_SERVICE")) { *error =3D g_dbus_error_new_for_dbus_error( "org.freedesktop.systemd.badthing", "Something went wrong creating the machine"); @@ -90,11 +90,11 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, } else if (STREQ(bus_name, "org.freedesktop.resolve1")) { g_autofree char *actual =3D NULL; =20 - if (getenv("FAIL_BAD_SERVICE")) { + if (g_getenv("FAIL_BAD_SERVICE")) { *error =3D g_dbus_error_new_for_dbus_error("org.freedesktop.sy= stemd.badthing", "Contacting resolved = failed"); } else if (STREQ(method_name, "SetLinkDomains")) { - const char *expected =3D getenv("TEST_RESOLVED_LINK_DOMAINS"); + const char *expected =3D g_getenv("TEST_RESOLVED_LINK_DOMAINS"= ); actual =3D g_variant_print(params, FALSE); =20 if (virTestCompareToString(expected, actual) < 0) @@ -103,7 +103,7 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, else reply =3D g_variant_new("()"); } else if (STREQ(method_name, "SetLinkDNS")) { - const char *expected =3D getenv("TEST_RESOLVED_LINK_DNS"); + const char *expected =3D g_getenv("TEST_RESOLVED_LINK_DNS"); actual =3D g_variant_print(params, FALSE); =20 if (virTestCompareToString(expected, actual) < 0) @@ -116,7 +116,7 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, "Unknown resolved met= hod"); } } else if (STREQ(bus_name, "org.freedesktop.login1")) { - reply =3D g_variant_new("(s)", getenv("RESULT_SUPPORT")); + reply =3D g_variant_new("(s)", g_getenv("RESULT_SUPPORT")); } else if (STREQ(bus_name, "org.freedesktop.DBus") && STREQ(method_name, "ListActivatableNames")) { GVariantBuilder builder; @@ -125,7 +125,7 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, =20 g_variant_builder_add(&builder, "s", "org.foo.bar.wizz"); =20 - if (!getenv("FAIL_NO_SERVICE")) { + if (!g_getenv("FAIL_NO_SERVICE")) { g_variant_builder_add(&builder, "s", "org.freedesktop.machine1= "); g_variant_builder_add(&builder, "s", "org.freedesktop.login1"); g_variant_builder_add(&builder, "s", "org.freedesktop.resolve1= "); @@ -140,7 +140,7 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, =20 g_variant_builder_add(&builder, "s", "org.foo.bar.wizz"); =20 - if (!getenv("FAIL_NO_SERVICE") && !getenv("FAIL_NOT_REGISTERED")) { + if (!g_getenv("FAIL_NO_SERVICE") && !g_getenv("FAIL_NOT_REGISTERED= ")) { g_variant_builder_add(&builder, "s", "org.freedesktop.systemd1= "); g_variant_builder_add(&builder, "s", "org.freedesktop.login1"); g_variant_builder_add(&builder, "s", "org.freedesktop.resolve1= "); diff --git a/tests/virtestmock.c b/tests/virtestmock.c index a5c3b29f39..5610ef46f6 100644 --- a/tests/virtestmock.c +++ b/tests/virtestmock.c @@ -64,15 +64,15 @@ printFile(const char *file, const char *func) { FILE *fp; - const char *testname =3D getenv("VIR_TEST_MOCK_TESTNAME"); + const char *testname =3D g_getenv("VIR_TEST_MOCK_TESTNAME"); =20 if (!progname) { - progname =3D getenv("VIR_TEST_MOCK_PROGNAME"); + progname =3D g_getenv("VIR_TEST_MOCK_PROGNAME"); =20 if (!progname) return; =20 - output =3D getenv("VIR_TEST_FILE_ACCESS_OUTPUT"); + output =3D g_getenv("VIR_TEST_FILE_ACCESS_OUTPUT"); if (!output) output =3D VIR_FILE_ACCESS_DEFAULT; } diff --git a/tools/virsh.c b/tools/virsh.c index 643ef6b453..fdce3220b3 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -894,7 +894,7 @@ main(int argc, char **argv) } =20 if (!ctl->connname) - ctl->connname =3D g_strdup(getenv("VIRSH_DEFAULT_CONNECT_URI")); + ctl->connname =3D g_strdup(g_getenv("VIRSH_DEFAULT_CONNECT_URI")); =20 if (!ctl->imode) { ret =3D vshCommandRun(ctl, ctl->cmd); diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helpe= r.c index a1c68a1afa..9fe34f55f1 100644 --- a/tools/virt-login-shell-helper.c +++ b/tools/virt-login-shell-helper.c @@ -357,7 +357,7 @@ main(int argc, char **argv) /* We're duping the string because the clearenv() * call will shortly release the pointer we get * back from getenv() right here */ - term =3D g_strdup(getenv("TERM")); + term =3D g_strdup(g_getenv("TERM")); =20 /* A fork is required to create new process in correct pid namespace. = */ if ((cpid =3D virFork()) < 0) diff --git a/tools/vsh.c b/tools/vsh.c index 18914cc818..74016c0043 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2567,7 +2567,7 @@ vshEditWriteToTempFile(vshControl *ctl, const char *d= oc) const char *tmpdir; VIR_AUTOCLOSE fd =3D -1; =20 - tmpdir =3D getenv("TMPDIR"); + tmpdir =3D g_getenv("TMPDIR"); if (!tmpdir) tmpdir =3D "/tmp"; filename =3D g_strdup_printf("%s/virshXXXXXX.xml", tmpdir); @@ -2611,9 +2611,9 @@ vshEditFile(vshControl *ctl, const char *filename) int outfd =3D STDOUT_FILENO; int errfd =3D STDERR_FILENO; =20 - editor =3D getenv("VISUAL"); + editor =3D g_getenv("VISUAL"); if (!editor) - editor =3D getenv("EDITOR"); + editor =3D g_getenv("EDITOR"); if (!editor) editor =3D DEFAULT_EDITOR; =20 @@ -3044,7 +3044,7 @@ vshReadlineInit(vshControl *ctl) histsize_env =3D g_strdup_printf("%s_HISTSIZE", ctl->env_prefix); =20 /* Limit the total size of the history buffer */ - if ((histsize_str =3D getenv(histsize_env))) { + if ((histsize_str =3D g_getenv(histsize_env))) { if (virStrToLong_i(histsize_str, NULL, 10, &max_history) < 0) { vshError(ctl, _("Bad $%1$s value."), histsize_env); return -1; @@ -3157,7 +3157,7 @@ vshInitDebug(vshControl *ctl) g_autofree char *env =3D g_strdup_printf("%s_DEBUG", ctl->env_pref= ix); =20 /* log level not set from commandline, check env variable */ - debugEnv =3D getenv(env); + debugEnv =3D g_getenv(env); if (debugEnv) { int debug; if (virStrToLong_i(debugEnv, NULL, 10, &debug) < 0 || @@ -3174,7 +3174,7 @@ vshInitDebug(vshControl *ctl) g_autofree char *env =3D g_strdup_printf("%s_LOG_FILE", ctl->env_p= refix); =20 /* log file not set from cmdline */ - debugEnv =3D getenv(env); + debugEnv =3D g_getenv(env); if (debugEnv && *debugEnv) { ctl->logfile =3D g_strdup(debugEnv); vshOpenLogFile(ctl); --=20 2.52.0 From nobody Tue Mar 3 03:06:30 2026 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=1771921673; cv=none; d=zohomail.com; s=zohoarc; b=Cz/r3dJhM/5wMMLDwekSecDWCLLoQKo62p6gn1++lOzU62oIVdThctD8Vmb3ABt/w8PXv1ZUajJMRTWgaTIiiFsTblAFBQufBCkA4viHqp7/hB0jgJhBUi44YyP2hhnMOGSGXjWQVdN+y5kc2D0Dl2M/LyGI06Om0yU3apv4o+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771921673; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner: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=p1EvBG4ZOsuskyQk2IJ5WFUfr9gmL0pRH0VUzVf3JuA=; b=Vr5jmks9uUEfYUPw73DBGed1DEP62keAi7c1sUlaDmhx5xSbRrkbvBniRUlW4p1+qTU0xoeMHwIRp1x8f6puBe+6j/MOdzXMtuv00T6cDa1qr7U/2puWiFC+1KtAh2JLcMo8u9i5jhbgdnn9ZO+R6D8sBj4tlNQfzGpj+Gzyv7U= 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 1771921673651866.2884031703697; Tue, 24 Feb 2026 00:27:53 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id D06DB41C92; Tue, 24 Feb 2026 03:27:52 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id E83D741B8E; Tue, 24 Feb 2026 03:23:25 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 304FD41B69; Tue, 24 Feb 2026 03:22:51 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B141341B54 for ; Tue, 24 Feb 2026 03:22:50 -0500 (EST) Received: from mx-prod-mc-05.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-571-6dX7ZzYCMkqBIwEoi-Il3A-1; Tue, 24 Feb 2026 03:22:48 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 28F5619560A6 for ; Tue, 24 Feb 2026 08:22:48 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.82]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C59071800465 for ; Tue, 24 Feb 2026 08:22:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771921370; 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=p1EvBG4ZOsuskyQk2IJ5WFUfr9gmL0pRH0VUzVf3JuA=; b=MnqKkhz+Jfq4oIwORcZ0e9GtBU+34Ne0F5fTBYppyInucFI90/K03C8HzDY7GcRXbwnU+R WDm2akEtveJhvf2fQzsC5mQ2/Zmkc6vHA0M3/3ZDs+5WU3Hc7Q9KTwcBAcI4zFexShSCuO qs2M7NBaZM70JlCnfQKqx0gz5+l9BAA= X-MC-Unique: 6dX7ZzYCMkqBIwEoi-Il3A-1 X-Mimecast-MFC-AGG-ID: 6dX7ZzYCMkqBIwEoi-Il3A_1771921368 To: devel@lists.libvirt.org Subject: [PATCH 7/8] tests: point $HOME and $XDG_* into usable fake root directory Date: Tue, 24 Feb 2026 03:22:41 -0500 Message-ID: <20260224082242.274009-8-laine@redhat.com> In-Reply-To: <20260224082242.274009-1-laine@redhat.com> References: <20260224082242.274009-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 5gRBbBCGHqaSL3JPDP7RfshO2ORZZ_8eU1srzPNNd6M_1771921368 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ACNZCJQPJA77IET2AP4QNB33VC6AYTIL X-Message-ID-Hash: ACNZCJQPJA77IET2AP4QNB33VC6AYTIL X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1771921674373158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump A long time ago we added some lines to "poison" the environment of test programs (specifically $HOME and $XDG_*) with nonexisting unusable paths so that any test program attempting to use the normal settings of those variables (which point into the filesystem of the system running the test) would fail (rather than silently messing up the test system). At some later time, someone wrote tests for hostdev devices that required that virGetUserRuntimeDirectory() (which normally uses either $XDG_RUNTIME_DIR or $HOME) return a directory that could actually be used as a part of the test; this was solved by mocking virGetUserRuntimeDirectory() to return a path underneath $LIBVIRT_FAKE_ROOT_DIR (which is created each time a test starts). Much much later, I wanted to add validation of the directory returned by virGetUserRuntimeDirectory(), but when this validation was added, the poisoned values that had been set (back in paragraph one "a long time ago") caused this validation to fail. My first attempt to fix this was to make the mocked virGetUserRuntimeDirectory() more generally available, and turn it on for all the tests that failed. But then I realized that a better solution would be to instead "nourish" (rather than "poison" - get it?) $HOME and $XDG_* with directories created under $LIBVIRT_FAKE_ROOT_DIR. This way we are actually testing the real virGetUserRuntimeDirectory() and any future validation, and also make some other tests cover more actual code in the future. In this patch the poisoning of the environment is removed, the call to the function creating the fake root dir is moved up to that location, and as a part of creating the fake root dir, we also set the aforementioned environment variables and create the directories associated with them (since the tests assume that they already exist). The now-redundant original mock of virGetUserRuntimeDirectory() will be removed in another patch. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- tests/testutils.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index 814391b804..c984f66d0e 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -779,6 +779,20 @@ virTestSetEnvPath(void) =20 #define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" =20 +static int +virTestFakeEnvSubDirInit(const char *envName, const char *fakeRootName, co= nst char *fakeSubDirName) +{ + g_autofree char *envVal =3D g_build_filename(fakeRootName, fakeSubDirN= ame, NULL); + + if (g_mkdir(envVal, 0777) < 0) { + fprintf(stderr, "Cannot create fake %s directory at %s", envName, = envVal); + return -1; + } + + g_setenv(envName, envVal, TRUE); + return 0; +} + char* virTestFakeRootDirInit(void) { @@ -791,6 +805,22 @@ virTestFakeRootDirInit(void) =20 g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE); =20 + /* the glib g_get_user_*_dir() functions use these environment variabl= es to + * determine locations for various data/log/config files. Setting them= here + * will assure that code under test that is using those directories wo= n't pollute + * the system under test. + */ + if (virTestFakeEnvSubDirInit("HOME", fakerootdir, "home") < 0) + return NULL; + if (virTestFakeEnvSubDirInit("XDG_RUNTIME_DIR", fakerootdir, "user-run= time-dir") < 0) + return NULL; + if (virTestFakeEnvSubDirInit("XDG_DATA_HOME", fakerootdir, "user-data-= home") < 0) + return NULL; + if (virTestFakeEnvSubDirInit("XDG_CACHE_HOME", fakerootdir, "user-cach= e-home") < 0) + return NULL; + if (virTestFakeEnvSubDirInit("XDG_CONFIG_HOME", fakerootdir, "user-con= fig-home") < 0) + return NULL; + return g_steal_pointer(&fakerootdir); } =20 @@ -829,11 +859,8 @@ int virTestMain(int argc, preloads[npreloads] =3D NULL; } =20 - g_setenv("HOME", "/bad-test-used-env-home", TRUE); - g_setenv("XDG_RUNTIME_DIR", "/bad-test-used-env-xdg-runtime-dir", TRUE= ); - g_setenv("XDG_DATA_HOME", "/bad-test-used-env-xdg-data-home", TRUE); - g_setenv("XDG_CACHE_HOME", "/bad-test-used-env-xdg-cache-home", TRUE); - g_setenv("XDG_CONFIG_HOME", "/bad-test-used-env-xdg-config-home", TRUE= ); + if (!(fakerootdir =3D virTestFakeRootDirInit())) + return EXIT_FAILURE; =20 va_start(ap, func); while ((lib =3D va_arg(ap, const char *))) { @@ -907,9 +934,6 @@ int virTestMain(int argc, =20 failedTests =3D virBitmapNew(1); =20 - if (!(fakerootdir =3D virTestFakeRootDirInit())) - return EXIT_FAILURE; - ret =3D (func)(); =20 virResetLastError(); --=20 2.52.0 From nobody Tue Mar 3 03:06:30 2026 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=1771921709; cv=none; d=zohomail.com; s=zohoarc; b=CZzKOckxm3P5dC3MU2a9Q6tPxJUnKRM+0tmbMa2kUorReM2OsQWvBn6iEnz+EE/iAHaWjn6otDEWf9dObGK+6Ua+TM41ynFxajLx0xH3DQkDoCDoAliQVVxpq+DaVpa5GR2YzIPzlESzpaGm9odf7W60ZtPAK8a7Uu14OEW1mYs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771921709; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner: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=+vGZ3WndCRI8R6fueuTQV71t5cc5iVEor0Sa03mPjCE=; b=joIoa7aY22f2B27GyWwpK8lUn9rh52JtWL+DKv+U7cGW+0Lwm2qM/anUVkgTbgpIbe05HBcR7PDOQWTq9ddGe90V57biQ1RPTxmOceLrDDbBCGLVdmUqclmpzXQURtWl/5ZRoEB7LogTlhikQdzYbYDnlWwChd4pQ4Hdi6Y2Jpg= 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 1771921709391551.0527104160193; Tue, 24 Feb 2026 00:28:29 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id A168641CC6; Tue, 24 Feb 2026 03:28:28 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id DA05B41E4F; Tue, 24 Feb 2026 03:23:40 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 6F93541B48; Tue, 24 Feb 2026 03:22:51 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 19C1341B66 for ; Tue, 24 Feb 2026 03:22:51 -0500 (EST) Received: from mx-prod-mc-05.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-640-chxFuWRHNf2YbD3Be_mv5g-1; Tue, 24 Feb 2026 03:22:49 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B3796195609D for ; Tue, 24 Feb 2026 08:22:48 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.82]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5C1E41800465 for ; Tue, 24 Feb 2026 08:22:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771921370; 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=+vGZ3WndCRI8R6fueuTQV71t5cc5iVEor0Sa03mPjCE=; b=C6VSDcwIZ/lRgA1HLjwRUx9dr7seiRCYh77tX0X7DKhzS2VM/cjfQkL2TqSYkRDKcC0V4g d4nFXjZaP+AOi3+VacZRfmLufz1ENC/AdP1PxmGuUFYsLZn4McUemjf8I8VzcTr5cDNNfN tPdri2Z/04VcdYj7wAPRSG1xPXNnMKE= X-MC-Unique: chxFuWRHNf2YbD3Be_mv5g-1 X-Mimecast-MFC-AGG-ID: chxFuWRHNf2YbD3Be_mv5g_1771921368 To: devel@lists.libvirt.org Subject: [PATCH 8/8] tests: stop mocking virGetUserRuntimeDirectory() Date: Tue, 24 Feb 2026 03:22:42 -0500 Message-ID: <20260224082242.274009-9-laine@redhat.com> In-Reply-To: <20260224082242.274009-1-laine@redhat.com> References: <20260224082242.274009-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Bvj1ZUKR3_U8d8nRGVT8wzlzWDUPGaDa3O-wpBKBOas_1771921368 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QH2JEXH6AMBZ2HKFN4WLG2YGKVBR2IGX X-Message-ID-Hash: QH2JEXH6AMBZ2HKFN4WLG2YGKVBR2IGX X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1771921710415158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump The same functionality has been achieved by setting the XDG_RUNTIME_DIR environment variable during the setup of the "fake root" directory in testutils.c Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- tests/meson.build | 1 - tests/qemuhotplugtest.c | 1 - tests/virhostdevmock.c | 15 --------------- tests/virhostdevtest.c | 1 - 4 files changed, 18 deletions(-) delete mode 100644 tests/virhostdevmock.c diff --git a/tests/meson.build b/tests/meson.build index b28ad4a65b..847538d2e4 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -78,7 +78,6 @@ mock_libs =3D [ { 'name': 'virfilecachemock' }, { 'name': 'virfirewallmock' }, { 'name': 'virhostcpumock' }, - { 'name': 'virhostdevmock' }, { 'name': 'virnetdaemonmock' }, { 'name': 'virnetdevmock' }, { 'name': 'virnetserverclientmock' }, diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 58413b6e0d..0cd738ae3d 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -799,7 +799,6 @@ mymain(void) } =20 VIR_TEST_MAIN_PRELOAD(mymain, - VIR_TEST_MOCK("virhostdev"), VIR_TEST_MOCK("virpci"), VIR_TEST_MOCK("domaincaps"), VIR_TEST_MOCK("virprocess"), diff --git a/tests/virhostdevmock.c b/tests/virhostdevmock.c deleted file mode 100644 index 9b0e4dc2b0..0000000000 --- a/tests/virhostdevmock.c +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (C) 2020 Red Hat, Inc. - * SPDX-License-Identifier: LGPL-2.1-or-later - */ - -#include - -#include "virutil.h" - -char * -virGetUserRuntimeDirectory(void) -{ - return g_build_filename(g_getenv("LIBVIRT_FAKE_ROOT_DIR"), - "user-runtime-directory", NULL); -} diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index b0fb94e197..d52d549feb 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -613,7 +613,6 @@ mymain(void) } =20 VIR_TEST_MAIN_PRELOAD(mymain, - VIR_TEST_MOCK("virhostdev"), VIR_TEST_MOCK("virpci")) #else int --=20 2.52.0