From nobody Wed Oct 30 22:17:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683741995; cv=none; d=zohomail.com; s=zohoarc; b=gmvHs8rt1aGSR0HnHGFW5Fqen5hoe3yDouUgy6qYeVKt9E97xH45yAt21W9EtA2GmtfOTUZ02xaEeGYPA2hhcoSS3m2ZpuEu7u3nb9EzkFFbMeTOLvSavHhMgMBF+JngIoixoNSvOfRQgIbj5XiGvep61Rqm62YYZb4nSpcwe6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683741995; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WcrUb9cordU7x4P2PBEyjaUoi2yhEsvS3V+ST9lLmE4=; b=kMv68Jm+/lJkz0IqCHgGGN4loYqGcPvspTPhDskdn3noQOM3JaCUg7KnughsZ8GRHpHNhAtjj8x2sjrOPz+oOfrGP7EzBRJYdC2+UqsVJz6q91YAZ2quZI80NtRfMYmkvhbevwGdrhxqbsEgVp8wrJR4Lk6gW+Z9pisnlsJWQNw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1683741995372879.6973824652412; Wed, 10 May 2023 11:06:35 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-384-PV1zdLBbO9WhLcypvVxk0g-1; Wed, 10 May 2023 14:06:32 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C4F4580253B; Wed, 10 May 2023 18:06:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B02E21121314; Wed, 10 May 2023 18:06:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7660B19452C6; Wed, 10 May 2023 18:06:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 093FD19452C8 for ; Wed, 10 May 2023 18:06:06 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8B3FC2026D16; Wed, 10 May 2023 18:06:06 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1638B2026DFD for ; Wed, 10 May 2023 18:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683741994; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=WcrUb9cordU7x4P2PBEyjaUoi2yhEsvS3V+ST9lLmE4=; b=HuVsCr3vacvE7SY/pQlTGiHvN73aAL2xDt7gxF6JiCK3mwN2p6WV+OdI7LmbxDl8wSC7Vw Rq2E/X3fSintrnvAykI2quDRpufxnF1EvzfM/LMkpHLF5mih97xTkCLL8A6smqOAfZ/mor 4RiAIvwUBidEalpxH1uz2lu/n8cwopA= X-MC-Unique: PV1zdLBbO9WhLcypvVxk0g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 1/3] qemu: Find dbus-daemon at runtime Date: Wed, 10 May 2023 20:06:01 +0200 Message-Id: <20230510180603.127819-2-abologna@redhat.com> In-Reply-To: <20230510180603.127819-1-abologna@redhat.com> References: <20230510180603.127819-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683741996323100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Don't bother looking at /usr/libexec, since every distro ships dbus-daemon in $PATH. Note that it's still possible for the administrator to prevent this lookup and use an arbitrary binary by setting the appropriate key in qemu.conf. Signed-off-by: Andrea Bolognani --- src/qemu/qemu_dbus.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c index 7a7af2850e..06b655d870 100644 --- a/src/qemu/qemu_dbus.c +++ b/src/qemu/qemu_dbus.c @@ -175,6 +175,7 @@ qemuDBusStart(virQEMUDriver *driver, g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(virCommand) cmd =3D NULL; + g_autofree char *dbusDaemonPath =3D NULL; g_autofree char *shortName =3D NULL; g_autofree char *pidfile =3D NULL; g_autofree char *configfile =3D NULL; @@ -188,13 +189,16 @@ qemuDBusStart(virQEMUDriver *driver, if (priv->dbusDaemonRunning) return 0; =20 - if (!virFileIsExecutable(cfg->dbusDaemonName)) { + dbusDaemonPath =3D virFindFileInPath(cfg->dbusDaemonName); + if (!dbusDaemonPath) { virReportSystemError(errno, _("'%1$s' is not a suitable dbus-daemon"), cfg->dbusDaemonName); return -1; } =20 + VIR_DEBUG("Using dbus-daemon: %s", dbusDaemonPath); + if (!(shortName =3D virDomainDefGetShortName(vm->def))) return -1; =20 @@ -210,7 +214,7 @@ qemuDBusStart(virQEMUDriver *driver, if (qemuSecurityDomainSetPathLabel(driver, vm, configfile, false) < 0) goto cleanup; =20 - cmd =3D virCommandNew(cfg->dbusDaemonName); + cmd =3D virCommandNew(dbusDaemonPath); virCommandClearCaps(cmd); virCommandSetPidFile(cmd, pidfile); virCommandSetErrorFD(cmd, &errfd); @@ -223,7 +227,7 @@ qemuDBusStart(virQEMUDriver *driver, if (virPidFileReadPath(pidfile, &cpid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("dbus-daemon %1$s didn't show up"), - cfg->dbusDaemonName); + dbusDaemonPath); goto cleanup; } =20 @@ -241,7 +245,7 @@ qemuDBusStart(virQEMUDriver *driver, if (saferead(errfd, errbuf, sizeof(errbuf) - 1) < 0) { virReportSystemError(errno, _("dbus-daemon %1$s died unexpectedly"), - cfg->dbusDaemonName); + dbusDaemonPath); } else { virReportError(VIR_ERR_OPERATION_FAILED, _("dbus-daemon died and reported: %1$s"), errbu= f); @@ -253,7 +257,7 @@ qemuDBusStart(virQEMUDriver *driver, if (!virFileExists(sockpath)) { virReportError(VIR_ERR_OPERATION_TIMEOUT, _("dbus-daemon %1$s didn't show up"), - cfg->dbusDaemonName); + dbusDaemonPath); goto cleanup; } =20 --=20 2.40.1