From nobody Mon Feb 9 17:24:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552046465698747.2466674574381; Fri, 8 Mar 2019 04:01:05 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7BC6630D78C7; Fri, 8 Mar 2019 12:01:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3836A614FE; Fri, 8 Mar 2019 12:01:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B8F953FB12; Fri, 8 Mar 2019 12:01:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x28C10Dh008494 for ; Fri, 8 Mar 2019 07:01:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id EE22917DE5; Fri, 8 Mar 2019 12:01:00 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 456015D9CD; Fri, 8 Mar 2019 12:01:00 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Fri, 8 Mar 2019 13:00:48 +0100 Message-Id: <6ff142adbeb43bc568768a76a79312bedb3bc472.1552045608.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v2 2/3] qemu: command: Enforce setting XDG variables for system QEMU X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 08 Mar 2019 12:01:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" For session mode, only XDG_CACHE_HOME is set, because we want to remain integrating with services in user session, but for system mode, this would have become reading/writing to '/' which carries the obvious issue with permissions (also, '/' is the wrong location in 99.9% cases anyway). Signed-off-by: Erik Skultety Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_command.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3a2ec7f26c..23be0d8554 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10658,6 +10658,22 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, =20 virCommandAddEnvPassCommon(cmd); =20 + /* For system QEMU we want to set both HOME and all the XDG variables = to + * libDir/qemu otherwise apps QEMU links to might try to access the de= fault + * home dir '/' which would always result in a permission issue. + * + * For session QEMU, we only want to set XDG_CACHE_HOME as cache data + * may be purged at any time and that should not affect any app. We + * do want VMs to integrate with services in user's session so we're + * not re-setting any other env variables + */ + if (!driver->privileged) { + virCommandAddEnvFormat(cmd, "XDG_CACHE_HOME=3D%s/%s", + priv->libDir, ".cache"); + } else { + virCommandAddEnvXDG(cmd, priv->libDir); + } + if (qemuBuildNameCommandLine(cmd, cfg, def, qemuCaps) < 0) goto error; =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list