From nobody Sun Feb 8 19:25:29 2026 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=1637449837; cv=none; d=zohomail.com; s=zohoarc; b=dQItQJFqOvcm59Cmatkhr3TFVStwiaCw2KGVfYWOxHvkvCmB9JMaBxCoTZBgpFnAB8rOxgHbYp4PYs3HbcYEf0RC/rNyBai8EUK83i0YjCvYkC1QRHNZlrte8iWiLXUluQSZ7A6/wItBf8sp9H1dwbkPWHYzKfuELUqy6pJccxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637449837; 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=hrBmkzJ/2lma2k2SGabZH5rhYZvhIvpFQKWdMG+qU0w=; b=HcWdx1lMmMmsmHJOPzr2QRGNG3jq0sicpE3pRPJSE2/lCM8goPosvQlGW+nGyVOXcOwMT8blhGga7HsuFEPGdlc5XPigj559XWB/cWaMclvnt0lB95B6+XX4DB9mBlIRX3GY9GjJS97FJS00rkSA+6MQeeeg87sBfp+LxAkR8Q0= 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 1637449837911477.3714077866381; Sat, 20 Nov 2021 15:10:37 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-56-l5jhdHelNFWAowlJtHf9-Q-1; Sat, 20 Nov 2021 18:10:33 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 948A3102CB2E; Sat, 20 Nov 2021 23:10:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 72BA719C79; Sat, 20 Nov 2021 23:10:28 +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 45F941832DF2; Sat, 20 Nov 2021 23:10:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AKNANs8001726 for ; Sat, 20 Nov 2021 18:10:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6BBAE51E4; Sat, 20 Nov 2021 23:10:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64F2C51E2 for ; Sat, 20 Nov 2021 23:10:20 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A44F185A7B2 for ; Sat, 20 Nov 2021 23:10:20 +0000 (UTC) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-399-NHVmE85yMzGKplHMwRcLhA-1; Sat, 20 Nov 2021 18:10:19 -0500 Received: by mail-ed1-f71.google.com with SMTP id a3-20020a05640213c300b003e7d12bb925so11555884edx.9 for ; Sat, 20 Nov 2021 15:10:18 -0800 (PST) Received: from carol.localdomain (k8r.cz. [95.82.177.71]) by smtp.gmail.com with ESMTPSA id f17sm1763284edq.39.2021.11.20.15.10.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Nov 2021 15:10:16 -0800 (PST) Received: from carol.redhat.com (carol.k8r.cz [IPv6:::1]) by carol.localdomain (Postfix) with ESMTP id 2782EC20054 for ; Sun, 21 Nov 2021 00:10:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637449836; 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=hrBmkzJ/2lma2k2SGabZH5rhYZvhIvpFQKWdMG+qU0w=; b=fm4CiDbf96TvuwYwsPi5kTRae9Okidh9etmGRJbfW4qRN0t5aWQZjDAIGYJ5aG11bgvRU6 3rZ1ERk99HY554cSozqRKPjY5kYmgRwpQj+A+sFEOiGn13XspYSwAX3x46QqeIP0KTXj5h wpGXraaZYWr8eq8Hlk1q0qtWYJeHFhA= X-MC-Unique: l5jhdHelNFWAowlJtHf9-Q-1 X-MC-Unique: NHVmE85yMzGKplHMwRcLhA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hrBmkzJ/2lma2k2SGabZH5rhYZvhIvpFQKWdMG+qU0w=; b=k8L3pUSDwsA+k+FUbi4jvzjyT7xZoc0L0gdlhyKhAtL8F9MowIF9aM5VAF5H8bn0Ax cYRjk1Z8vTOXnPEN7be8GTdT/wPsYjGUwS+ZE1OVLolW9VWaX9K8JfwbdmUafk/zFIHj 37wbqO9zt0WWMGWX4t8V6gJKBuHAteKD9b4IZAPmVTLhhdGLisCjEqwy5GFtnc327VGj tPaTDu6X7dXds8cvesWG1XlPoOlVcWKbjt2165esGW0c5/GVTZF7KeFUEHN+Moe1nTjV aJtCQZAwHUFUiG0n5Ulv/ZxQI5d9ASIENOJJmu3QyIvRYWFzcqb7KdssIXwHWtqi0y1k 46gQ== X-Gm-Message-State: AOAM530Ea+Gog/LKWmMtOezFB4uBGFSXt/rq961jgIseHQg+Dzw0h2z6 McB5LWrhnRHkjlHUiIhUHbJJD7Vh3WPIBZgLl7I70J6+Stev0oh+5q9XugbqiweSVSxBRkY315N d+0X4N4IMDziNOJ9qxTiLAlMz3tpN0PhDyMjzIV0aNvxcOxOBKSZn7PIbDDqM8QJrV9MYeAk= X-Received: by 2002:a05:6402:4251:: with SMTP id g17mr44362968edb.89.1637449817856; Sat, 20 Nov 2021 15:10:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOeMI7hedcgWu7Gn6D8BTy5qxusxFI832TAKfYliNNNw+XlEz1eLr+Lg3spUGGVtfIoP1FvQ== X-Received: by 2002:a05:6402:4251:: with SMTP id g17mr44362932edb.89.1637449817655; Sat, 20 Nov 2021 15:10:17 -0800 (PST) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 4/7] virsh: Do not try connecting first time without polkit agent Date: Sun, 21 Nov 2021 00:10:05 +0100 Message-Id: <6fd5217210dc8b5747b65ec1c7629dfe1827b8ac.1637449540.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1637449838782100001 Content-Type: text/plain; charset="utf-8" Trying to connect once without a polkit agent will generate an error on the server side which seems too rough given it only serves the purpose of the c= lient (virsh in this case) to figure out that an agent is needed. Thankfully we = can just try running the agent. It does not break anything as we are running it with `--fallback`, which makes sure it does not replace an existing agent in case there is one already registered. The second piece of code trying to start the polkit text agent is kept in o= rder to _really_ try out starting the agent (and error out when failing to do so) just in case the agent was not available the first time it was ran. Even t= hough it should not happen it avoids a very rare race condition and really does n= ot add much complexity. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1945501 Signed-off-by: Martin Kletzander Reviewed-by: J=C3=A1n Tomko --- tools/virsh.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/virsh.c b/tools/virsh.c index da35c5c2b9c1..5234a3decb22 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -129,6 +129,10 @@ virshConnect(vshControl *ctl, const char *uri, bool re= adonly) keepalive_forced =3D true; } =20 + if (virPolkitAgentAvailable() && + !(pkagent =3D virPolkitAgentCreate())) + virResetLastError(); + do { virErrorPtr err; =20 @@ -140,6 +144,10 @@ virshConnect(vshControl *ctl, const char *uri, bool re= adonly) goto cleanup; =20 err =3D virGetLastError(); + /* + * If polkit agent failed starting the first time, then retry once= more + * now when we know it really is needed. + */ if (!pkagent && err && err->domain =3D=3D VIR_FROM_POLKIT && err->code =3D=3D VIR_ERR_AUTH_UNAVAILABLE) { --=20 2.34.0