From nobody Fri Mar 29 08:12:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1637450039; cv=none; d=zohomail.com; s=zohoarc; b=jHN+zRtZfOSwcYFexOtQksWctm6lLhu9SGUZJJgM+zGsdNmu6aRTahbIT6HQxBxZvh7iEsGMqhD55URQnD/poklRh0ikGfGN0o52Gacsl4L9pSxQ0VCXkWfOcp/8rn66t9wv50mgehwXMnThd/PEekLJCeiaz1bUzr8jiNVtdRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637450039; 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=AMpV93v3PMewnmAoO22z0KwJXStWwjnZw+S/yGgY3Hc=; b=BsPSMbNMAsg5CMVzWPhIu/xGyHszUzyAYlYa4Bu608x1+AqjtN5lPnYNJPi9kSmIZ4w8W3kLwmrigCOR++fanQGgrbYq4YJ/rLq4sEgOpXxCMz1Sflm7aTXNpwURMZb0pk+T+GFo7Ru63vCwlCaDncTnT0A4Ju1dt3SBR8elV5g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1637450039922429.93143244659245; Sat, 20 Nov 2021 15:13:59 -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-45-_GsyxWNIM7-XDeBwCOMC9A-1; Sat, 20 Nov 2021 18:13:57 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 788E018125C2; Sat, 20 Nov 2021 23:13:52 +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 583965C1A1; Sat, 20 Nov 2021 23:13:52 +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 298391832E85; Sat, 20 Nov 2021 23:13:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AKNAPmv001756 for ; Sat, 20 Nov 2021 18:10:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 234F82026D5D; Sat, 20 Nov 2021 23:10:25 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E3DB2026D48 for ; Sat, 20 Nov 2021 23:10:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 A7750811E76 for ; Sat, 20 Nov 2021 23:10:19 +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-533-oSLky6pJNDqDIQB47Qud3Q-1; Sat, 20 Nov 2021 18:10:18 -0500 Received: by mail-ed1-f71.google.com with SMTP id m12-20020a056402430c00b003e9f10bbb7dso4069346edc.18 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 gn26sm1735271ejc.14.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 25D09C20040 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=1637450038; 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=AMpV93v3PMewnmAoO22z0KwJXStWwjnZw+S/yGgY3Hc=; b=IDTvV0ush07zLmbdrSrD6mnzlQ1affN9och/i5DdqN5OUh8PUFHZAjPtFbi7cuWkk2TUf4 7YH+lc38pawF+aYbeVoGLrg2iovuFXfAsWveoQYNxA8rnPDL3lVf76Ocsj+WeDX+GMHIAB 6R6diodCNhucsPghUTqNSuAcmVWChHk= X-MC-Unique: _GsyxWNIM7-XDeBwCOMC9A-1 X-MC-Unique: oSLky6pJNDqDIQB47Qud3Q-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=AMpV93v3PMewnmAoO22z0KwJXStWwjnZw+S/yGgY3Hc=; b=7W7KetiOE0m1je465CjCaOgJa/D4z3QnTvIJ5cHlpuGrZ3Y1DLIh9sCcE2pSJBwxTf N9IH4WWsHABw/fp2vuquOSsA2dr0zvIt2RB8LuuqNLFZ7ulXc9C+VKm6hSpN1o/zdue7 hus97nlDS5WEFzBNCOmNLtPX6qX14e4QPybO5ollASpV2keuZnYWj8q371RidJEPMqVo aFxx9bph7t2DfTMnlod6Gwy3rg+Emr5eVZst7L9r0Xdqk32O0Dv9Y+DNN8cUhjoNwgi+ 8vAx9tl61p7K2q4qMOth03BJCI17tvZbF4iBOCxE4dymfFL7f6sNgIv1xUzCq6XfgRvu cy2w== X-Gm-Message-State: AOAM530b07Bdr5sz55xtHSfrkf7bO/YShMZwF7ttTIjyBs6vkpb4GrW5 a+z9rI50EaL1BwKo3sH6Mo96EJ5cEkC37adKjAg+eG7q3dgdPJbvWP239T3s09qnj3lkEi/b4pY za10k/6VUD30M6MUkPCeDe0EP5wNRWMEDR3lq8lK60CoKZKmXSdvYQzQ/ntCscwQqHTpd2qk= X-Received: by 2002:a17:907:961d:: with SMTP id gb29mr23918905ejc.102.1637449817108; Sat, 20 Nov 2021 15:10:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxH7p2kRKYFlH5W2X4wGUd+hQOUMsRFkMDIr44VLn1V2PLLAw7E9qLc6cgY9oNm4teO5u+M4Q== X-Received: by 2002:a17:907:961d:: with SMTP id gb29mr23918861ejc.102.1637449816842; Sat, 20 Nov 2021 15:10:16 -0800 (PST) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 1/7] virsh: Remove needless variable Date: Sun, 21 Nov 2021 00:10:02 +0100 Message-Id: <2d199135785369a174bff4f12a0cf5a20f541861.1637449540.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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.79 on 10.5.11.16 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: 1637450041864100003 Content-Type: text/plain; charset="utf-8" It only redundantly reflects whether pkagent !=3D NULL. Signed-off-by: Martin Kletzander Reviewed-by: J=C3=A1n Tomko --- tools/virsh.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index b9f3f851d3ec..da35c5c2b9c1 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -119,7 +119,6 @@ virshConnect(vshControl *ctl, const char *uri, bool rea= donly) bool keepalive_forced =3D false; virPolkitAgent *pkagent =3D NULL; int authfail =3D 0; - bool agentCreated =3D false; =20 if (ctl->keepalive_interval >=3D 0) { interval =3D ctl->keepalive_interval; @@ -141,12 +140,11 @@ virshConnect(vshControl *ctl, const char *uri, bool r= eadonly) goto cleanup; =20 err =3D virGetLastError(); - if (!agentCreated && + if (!pkagent && err && err->domain =3D=3D VIR_FROM_POLKIT && err->code =3D=3D VIR_ERR_AUTH_UNAVAILABLE) { - if (!pkagent && !(pkagent =3D virPolkitAgentCreate())) + if (!(pkagent =3D virPolkitAgentCreate())) goto cleanup; - agentCreated =3D true; } else if (err && err->domain =3D=3D VIR_FROM_POLKIT && err->code =3D=3D VIR_ERR_AUTH_FAILED) { authfail++; --=20 2.34.0 From nobody Fri Mar 29 08:12:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1637449838; cv=none; d=zohomail.com; s=zohoarc; b=fN19jrmHjHKzyya2IUzgd0iI8+HdaKLTQClB89ScNKpLpr5Jrb+fIYrcjlvBXvuDvE010W4w5zU+6dNt9SEMfHLVjWTJH4n1fNr7PhfVmaE6EPqxQDEG3wj4u4orDy/Bcc9AAkgbOTUwL9GVLyY9kU85z0oALNxjwwX5vjW98E8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637449838; 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=6WakroVvQttvtIblbrf842KEy6L9aJq+NPJytiL7nR4=; b=g8gR/yUbEn9ksO7qanifG5GMNT2Nj3EhSiSu48YRS2iZuquyGyuYM6AYr4PA4W15ueTRKe+jN63jBig5Gg/eNU7rZkrDfHJceFViy2y3YjqJ3EruBztzPfSI3Hazz5N9Hug9jfl5ns4kN7aDz13zW5vpiIB/qLxZNhzcxbdDcKk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1637449838745300.597835208276; Sat, 20 Nov 2021 15:10:38 -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-303-DKcvVvNiOZSGXXZRP848BQ-1; Sat, 20 Nov 2021 18:10:36 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 26D07871807; Sat, 20 Nov 2021 23:10:31 +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 093615D9DE; Sat, 20 Nov 2021 23:10:31 +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 D0D914E9F5; Sat, 20 Nov 2021 23:10:30 +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 1AKNANC9001727 for ; Sat, 20 Nov 2021 18:10:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6B48351E3; Sat, 20 Nov 2021 23:10:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64BF851E1 for ; Sat, 20 Nov 2021 23:10:20 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 79F65800141 for ; Sat, 20 Nov 2021 23:10:20 +0000 (UTC) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-540-uLzGKVSeN12taJFNR3_d1Q-1; Sat, 20 Nov 2021 18:10:19 -0500 Received: by mail-ed1-f69.google.com with SMTP id d11-20020a50cd4b000000b003da63711a8aso11445382edj.20 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 d3sm1747984edx.79.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 2641DC2004E 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=1637449837; 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=6WakroVvQttvtIblbrf842KEy6L9aJq+NPJytiL7nR4=; b=LGkXf+FMxtZ8IhjGE3WwixTHMrVuGwkei4XsMqOwUNVoCy1E4PBzrLOOYeDGpZ/nJnEkdw IjauScQIxiWCHJcVI4lwfbz9UGAfoRgXpTVVejERX+uQCKy2pmrvj7PAH7RTRTmXfHjxqZ z8SASj0xLwVY/ahtRMA5LlZzroVTi8w= X-MC-Unique: DKcvVvNiOZSGXXZRP848BQ-1 X-MC-Unique: uLzGKVSeN12taJFNR3_d1Q-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=6WakroVvQttvtIblbrf842KEy6L9aJq+NPJytiL7nR4=; b=T2huUxhZbHzeb/fcC62/6vbO2zcKSlRBpFas6OglGiVx8isdjuKHb9JkGUQ0/vquvA VZOQgm+uTEBCG3pzUw6W2QEN1/u1wcV6D3ykMvErVmhFhmuLKi6XIw8GIaYmG5Td8P6v M/h8LCGgo3OtasS501knD84MiTVqn5lDsP1KEZoPaY4DdNogA+YSM96InjNhff01Eu/P K3Ga4YSWxVFYmes+Pvo+VeORcCOby8pR1feu7Rj2dF0gBNUSKUrkZ47XMvFL+8sIAsTJ GwQfnrHfhT1ZJEkhKfejdS08h9IagHzh5HOR6sBmLH1+WI0xRjNTUSZoHNOYVyN60YPc LasQ== X-Gm-Message-State: AOAM533B2wnUoqxqNk74SmtbUezqIL156c111MNSubGT/g2Fk4UQjS4Y cKbRtAQSjR1Bo4ZiE3hIWaJG8O6dYfwfOFfb1fWnSlcc1heGPoYJQ1y/gWaBoeiBDRxpAesWZQG 0N6JgBNkQ3mluC28sdCdXhD2u453hiWfpI3vmOAKf9SytjpGo6TdvKaPZuBFoYFldALgspf0= X-Received: by 2002:a17:907:7fa9:: with SMTP id qk41mr10085657ejc.422.1637449817751; Sat, 20 Nov 2021 15:10:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBVI+kYaoSF+kQcZC8A0WCUDWcnB40GGAo3/Yq77nvebbzwGH+qdR5JC5JEMeZzSlXeX4Qxw== X-Received: by 2002:a17:907:7fa9:: with SMTP id qk41mr10085613ejc.422.1637449817447; Sat, 20 Nov 2021 15:10:17 -0800 (PST) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 2/7] util: Tiny reword fix in comment Date: Sun, 21 Nov 2021 00:10:03 +0100 Message-Id: <1e9a31e45b47afa4a4705663b7cef746acce11f5.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.79 on 10.5.11.14 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: 1637449840796100003 Content-Type: text/plain; charset="utf-8" Automatic "Ptr " -> " *" also wreaked havoc in comments. Fix it and while = at it reword the sentence so it is clear that the object is newly allocated. Signed-off-by: Martin Kletzander Reviewed-by: J=C3=A1n Tomko --- src/util/virpolkit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virpolkit.c b/src/util/virpolkit.c index e90b3b871d15..86255a96760f 100644 --- a/src/util/virpolkit.c +++ b/src/util/virpolkit.c @@ -168,7 +168,7 @@ virPolkitAgentDestroy(virPolkitAgent *agent) * * Allocate and setup a polkit agent * - * Returns a virCommand *on success and NULL on failure + * Returns newly allocated virPolkitAgent * on success and NULL on failure */ virPolkitAgent * virPolkitAgentCreate(void) --=20 2.34.0 From nobody Fri Mar 29 08:12:29 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=1637449834; cv=none; d=zohomail.com; s=zohoarc; b=QsM40ZyNmVuT/TcuiV2Ml4qrhdyN1BNwZM4JVcF3huC2UcmDCJW/XgkVYh1bhrMIOIGQNYaUwJTP0CEunj3e4N0LNJV0AywfGg4DeVDmrovPnoZ6wSHwtoFncOJPm+zWuNWyBT7rGlfTiE0WQB8oW/sdz9olAkHFbFHmp+J/a7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637449834; 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=5d+HmZnIDt/Xboc95t1lhO1qiEHkWUiIrUnZhoszi1M=; b=E4Q01aZLfQKRy+VvUf7cdaQwnauGmpgI5V5ZSBxIESaW9wsLegLT6sjRP+EDk6LLmib46EH1r+usRrIsC26F7TJsStshBh/ajHfc8Q2uW01UqwWch2FWjj6o1HO1xnpcynD/7KporybYgWIX78Y0kZGWpUaHnA40/U4gU02sw+8= 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 1637449834614766.4764795632393; Sat, 20 Nov 2021 15:10:34 -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-132-8-S1hfaCPJyRQ4QuAk626g-1; Sat, 20 Nov 2021 18:10:30 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F17018125C1; Sat, 20 Nov 2021 23:10:25 +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 61B2018A8F; Sat, 20 Nov 2021 23:10:25 +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 091544E590; Sat, 20 Nov 2021 23:10:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AKNAM5U001715 for ; Sat, 20 Nov 2021 18:10:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id B6BB02166B3F; Sat, 20 Nov 2021 23:10:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B0C362166B2D for ; Sat, 20 Nov 2021 23:10:19 +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 C540485A5A8 for ; Sat, 20 Nov 2021 23:10:19 +0000 (UTC) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-205--TOuyU4QM-iIKdniP2wQnA-1; Sat, 20 Nov 2021 18:10:18 -0500 Received: by mail-ed1-f69.google.com with SMTP id w18-20020a056402071200b003e61cbafdb4so11494015edx.4 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 e15sm1769031edq.46.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 26B82C2004F 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=1637449833; 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=5d+HmZnIDt/Xboc95t1lhO1qiEHkWUiIrUnZhoszi1M=; b=JrtDs7JiOH1XUq4Zu56O4SkqTdtNy9yOC9Z2nSLvJgfOcgx+y0ICE1rQ2lJlMXYzPSoDU+ QUFVpvul791pUEgM48MMbom+4yWQuOpJFMPwuT9yrb/jRRJpH5X/V9OoiUgT3fLacl/v1w MAgWoATUepJOSYLqqa37mXbhK3RxoKA= X-MC-Unique: 8-S1hfaCPJyRQ4QuAk626g-1 X-MC-Unique: -TOuyU4QM-iIKdniP2wQnA-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=5d+HmZnIDt/Xboc95t1lhO1qiEHkWUiIrUnZhoszi1M=; b=4jXBDsHLj/jkRWGx7NQMnuv0LAUL1r4Q2KdRV5HNwUd7oSqfRQz8M6KW+/wJFpoRVu F1/LyWh1GVMznPn3I9adVfh+HMgwFQ0x+wbtSX1cP+7gbSL9Q0uRpy0JRFq4fZEpe6Ou CANyRolBnPuuREAi+rMLtg1Q9Zb/KADZoZyvlp89Gngr9x84V0oVZ8M+Rf3wggqCra0/ +5+rdeOy1QhsniYdjE6h5rHQ/U6cc32akI6zbmHo595TntPBW8BMnpvAlgNQ145H0Ocm 581kNLBIk8/4lG/N66L2FC9tAYPBNWA16qrwdGJBhAPa2KvqBtFc7zyB2RyzbcPxMxkI wReg== X-Gm-Message-State: AOAM531JYRkNbuNVd5fjiQYTxZ7ABYYiUg9jTTub1rtelF1Yq1T5290f M8mStmnbMkK1zQSiQz22EFFW0eTZ8ez/480xmLBHSnLOVu3pKWDMKfPDEYKBXZxAoiovas6SPKT tcXm2CkBJOrv+076WaPk6zUnWoOJd15EdHNyo+DmiMVtgFH5o+1NEBtj19xg6Bb1q2uIMcwQ= X-Received: by 2002:a17:907:2da3:: with SMTP id gt35mr23900576ejc.314.1637449817316; Sat, 20 Nov 2021 15:10:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3nozkVmw12wA/auo8rIl+CTqeZ3N5lrlTf+xmW+aGpg31dkXQspqdkvlKl8ml3l+nBHXf8w== X-Received: by 2002:a17:907:2da3:: with SMTP id gt35mr23900533ejc.314.1637449817045; Sat, 20 Nov 2021 15:10:17 -0800 (PST) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 3/7] util: Add virPolkitAgentAvailable Date: Sun, 21 Nov 2021 00:10:04 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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.79 on 10.5.11.11 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: 1637449836644100003 Content-Type: text/plain; charset="utf-8" With this function we can decide whether to try running the polkit text age= nt only if it is available, removing a potential needless error saying that the agent binary does not exist, which is useful especially when running the ag= ent before knowing whether it is going to be needed. Signed-off-by: Martin Kletzander --- src/libvirt_private.syms | 1 + src/util/virpolkit.c | 44 ++++++++++++++++++++++++++++++++++++++++ src/util/virpolkit.h | 1 + 3 files changed, 46 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a7bc50a4d16d..c11be4eafa19 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3078,6 +3078,7 @@ virPidFileWritePath; =20 =20 # util/virpolkit.h +virPolkitAgentAvailable; virPolkitAgentCreate; virPolkitAgentDestroy; virPolkitCheckAuth; diff --git a/src/util/virpolkit.c b/src/util/virpolkit.c index 86255a96760f..3b333547d70b 100644 --- a/src/util/virpolkit.c +++ b/src/util/virpolkit.c @@ -20,6 +20,7 @@ */ =20 #include +#include #include =20 #include "virpolkit.h" @@ -217,6 +218,42 @@ virPolkitAgentCreate(void) } =20 =20 +/* + * virPolkitAgentAvailable + * + * This function does some preliminary checking that the pkttyagent does n= ot + * fail starting so that it can be started without waiting for first failed + * connection with VIR_ERR_AUTH_UNAVAILABLE. + */ +bool +virPolkitAgentAvailable(void) +{ + const char *termid =3D ctermid(NULL); + VIR_AUTOCLOSE fd =3D -1; + + if (!virFileExists(PKTTYAGENT)) + return false; + + if (!termid) + return false; + + /* + *The pkttyagent needs to open the controlling terminal. + * + * Just in case we are running without a ctty make sure this open() do= es not + * change that. + * + * We could check if our session has a controlling terminal available + * instead, but it would require parsing `/proc/self/stat` on Linux, w= hich + * is not portable and moreover requires way more work than just open(= ). + */ + fd =3D open(termid, O_RDWR | O_NOCTTY); + if (fd < 0) + return false; + + return true; +} + #else /* ! WITH_POLKIT */ =20 int virPolkitCheckAuth(const char *actionid G_GNUC_UNUSED, @@ -247,4 +284,11 @@ virPolkitAgentCreate(void) _("polkit text authentication agent unavailable")); return NULL; } + +bool +virPolkitAgentAvailable(void) +{ + return false; +} + #endif /* WITH_POLKIT */ diff --git a/src/util/virpolkit.h b/src/util/virpolkit.h index a577d59452ba..7bcd040e5e06 100644 --- a/src/util/virpolkit.h +++ b/src/util/virpolkit.h @@ -37,3 +37,4 @@ typedef struct _virPolkitAgent virPolkitAgent; =20 void virPolkitAgentDestroy(virPolkitAgent *cmd); virPolkitAgent *virPolkitAgentCreate(void); +bool virPolkitAgentAvailable(void); --=20 2.34.0 From nobody Fri Mar 29 08:12:29 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=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 From nobody Fri Mar 29 08:12:29 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=1637450038; cv=none; d=zohomail.com; s=zohoarc; b=bToP6kT9s9/K9yt/tLAb4avi35qj4TZmYHogDZ1dQakY/L5q9Xb96pplWqG9vhm5Lon11Fk9x8gpcoXGAOdOni4LJhA+nFidNPV37b/mU5zTx24mi+lyZjt5EhGwRpLMzUhcWkezx9dyZBfN1pptAwEN5ZYHhCtHsFc+6Ez//aU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637450038; 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=gbXsv+RkfKA9GZXz7q8C7z7HG9FgrPY77CwyaeInTL8=; b=Ti7S24uh8o+zzIkMUc5cjCCemNPKZqBYkxONNp7mO4pd30/6ZK/2rfGoZH+u9tgVVQVuKueOCaR2QFuyY7eGOFGCgg1ZdBehFdvz1O+1vwk8HVWzJH1q+VRYwUTBRAE//9hwZXZ5sfs4dMuL3HIv9aD0cXLaRklbj4toj+0Ihoc= 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 1637450038142379.915452114677; Sat, 20 Nov 2021 15:13:58 -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-166-dbuU0ZyxOAGEAlPFjb-BsQ-1; Sat, 20 Nov 2021 18:13:53 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC3E51006AA0; Sat, 20 Nov 2021 23:13:48 +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 9EB6960BF1; Sat, 20 Nov 2021 23:13:48 +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 6FB541832E80; Sat, 20 Nov 2021 23:13:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AKNAMdn001714 for ; Sat, 20 Nov 2021 18:10:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id B67DF2166B2F; Sat, 20 Nov 2021 23:10:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B0BB62166B26 for ; Sat, 20 Nov 2021 23:10:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 7738E80122B for ; Sat, 20 Nov 2021 23:10:21 +0000 (UTC) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-431-CgPG7fmCN3WoTLijDz1JHQ-1; Sat, 20 Nov 2021 18:10:19 -0500 Received: by mail-ed1-f69.google.com with SMTP id f4-20020a50e084000000b003db585bc274so11453327edl.17 for ; Sat, 20 Nov 2021 15:10:19 -0800 (PST) Received: from carol.localdomain (k8r.cz. [95.82.177.71]) by smtp.gmail.com with ESMTPSA id mc3sm1719188ejb.24.2021.11.20.15.10.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Nov 2021 15:10:17 -0800 (PST) Received: from carol.redhat.com (carol.k8r.cz [IPv6:::1]) by carol.localdomain (Postfix) with ESMTP id 280C9C20055 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=1637450037; 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=gbXsv+RkfKA9GZXz7q8C7z7HG9FgrPY77CwyaeInTL8=; b=dVQsa3lnDUX3vkPxLvj7VSYnz/6d+ALXrplB6ei1ayW32tm0w7Op/LN7bXgTW5Y+T8h1d0 xzQO2mLKhbV8ElhuMkw44UkLcG0nmEyqA0i8uG6Am5yzBPywOlQojvDDthIz2/nTe+OSmr xZtxmde2GD0QJMOtoUglbzKE5bMB9pg= X-MC-Unique: dbuU0ZyxOAGEAlPFjb-BsQ-1 X-MC-Unique: CgPG7fmCN3WoTLijDz1JHQ-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=gbXsv+RkfKA9GZXz7q8C7z7HG9FgrPY77CwyaeInTL8=; b=WxnfBeD88/uIeO+njRAIpXzPBsgpI1XjUTEcLucz1ZJ0cVaEDx51XvVha/AnAHup12 eQy9kbnKIg/ISWO1T7fy5D/4w8MGeey+l9Q8xV00fXrk7WYYMfeoV90VW2ePXFd5LS+a Lt0SuVWO5dZSjJAQjGSI6frOS42pF9st4XzbtugPNJBeo9RqgRfFJHGDfB54kxu/zqi5 sa/MCCIYffIKXKpvmQD7lTHUVl2mXHEm23/G9U/9EXuhK4uf7uo3qX+mPZKiGZQetaor h5sglUFxJTTY0NS6lFs7whgpmnjsAH+bGlB+PExWwUFjIfSfKCSHptXfsg9PbSJBVpt9 VPXQ== X-Gm-Message-State: AOAM532ymh+kHaEoJeUApOHO6735gn/DOgM8exBLYWFtn3IqIz9LKqck /p2sJoUNiXV4a1VjwdfLKoraRFgaHOkovjAc23B8DXozXYkvEGLikVctRjtW6kYMtw0aPq0KWml dIOjWz/SxACNA8blacLsAUxykc3S4gNI6kkkQygb+EaMR0loWyuUbmxTFB/wlI+lCK/uK14A= X-Received: by 2002:a17:906:4c56:: with SMTP id d22mr22957722ejw.1.1637449818392; Sat, 20 Nov 2021 15:10:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzy3dGx9TCaqXRpGWAuEu/55ulpcJgWRZJ3xvQ04GD2+uIFaXIn4XMjsDPxOnnUKD5jSI7E1Q== X-Received: by 2002:a17:906:4c56:: with SMTP id d22mr22957679ejw.1.1637449818056; Sat, 20 Nov 2021 15:10:18 -0800 (PST) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 5/7] util: Report errors in all code paths in virPolkitAgentCreate Date: Sun, 21 Nov 2021 00:10:06 +0100 Message-Id: <0a0bca6d66ada0f67c5e733c49e688b7a69879ea.1637449540.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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.79 on 10.5.11.12 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: 1637450039832100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Martin Kletzander Reviewed-by: J=C3=A1n Tomko --- src/util/virpolkit.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/util/virpolkit.c b/src/util/virpolkit.c index 3b333547d70b..63bb8133a8aa 100644 --- a/src/util/virpolkit.c +++ b/src/util/virpolkit.c @@ -180,8 +180,11 @@ virPolkitAgentCreate(void) int outfd =3D STDOUT_FILENO; int errfd =3D STDERR_FILENO; =20 - if (!isatty(STDIN_FILENO)) + if (!isatty(STDIN_FILENO)) { + virReportError(VIR_ERR_SYSTEM_ERROR, "%s", + _("Cannot start polkit text agent without a tty")); goto error; + } =20 if (virPipe(pipe_fd) < 0) goto error; @@ -205,8 +208,11 @@ virPolkitAgentCreate(void) pollfd.fd =3D pipe_fd[0]; pollfd.events =3D POLLHUP; =20 - if (poll(&pollfd, 1, -1) < 0) + if (poll(&pollfd, 1, -1) < 0) { + virReportSystemError(errno, "%s", + _("error in poll call")); goto error; + } =20 return agent; =20 --=20 2.34.0 From nobody Fri Mar 29 08:12:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1637450068; cv=none; d=zohomail.com; s=zohoarc; b=JBVtkbw5WpEoSsQDwCqKiV1GbwbT0i1JJjX4BpdZbnoKbuDdIUhqoTH9MMt8Uf0YDeT1bLkmF7dcXzzwbd7SQLI7ykANPX5kw57i5ggjKCGj6wUoOeGkJIYJidFm/wba8W5Ym8fn4dBlrS6dD0YfvZnwV6DkUDRNwJGLfzGZw8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637450068; 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=yc3Dd5k6TeCI0E/JxxxZ44aG3ZXjTcNQ/BuuFKmr6Fc=; b=hSJm5D2S47vY2CaMl/T8mouCW9pUNvifVKj6J9+RcB6o94LH7viOS9vqVpYLlpz6iRMc/y53k2PyPMKfSt4AmTKLp6hRQISvYK7eMwLgwwhGClA5xI8RwHe6KAxKbBs/W5qGv3kWr42gF+DGl0DITG6mdLMYL9CrGZ73eC2LAFQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 163745006812024.006291298132396; Sat, 20 Nov 2021 15:14:28 -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-401-b6Kho8nINjyWkaugQ4EZag-1; Sat, 20 Nov 2021 18:14:23 -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 74E4518125C2; Sat, 20 Nov 2021 23:14:18 +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 500CA19D9D; Sat, 20 Nov 2021 23:14:18 +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 24B1F1832E86; Sat, 20 Nov 2021 23:14:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AKNAOUW001743 for ; Sat, 20 Nov 2021 18:10:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6881D112131B; Sat, 20 Nov 2021 23:10:24 +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 635D11121315 for ; Sat, 20 Nov 2021 23:10:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 6C92A185A7B4 for ; Sat, 20 Nov 2021 23:10:21 +0000 (UTC) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-107-kMiJjuI2PIq6BeuMyvgFGQ-1; Sat, 20 Nov 2021 18:10:19 -0500 Received: by mail-ed1-f72.google.com with SMTP id v1-20020aa7cd41000000b003e80973378aso9951503edw.14 for ; Sat, 20 Nov 2021 15:10:19 -0800 (PST) Received: from carol.localdomain (k8r.cz. [95.82.177.71]) by smtp.gmail.com with ESMTPSA id nd36sm1718024ejc.17.2021.11.20.15.10.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Nov 2021 15:10:17 -0800 (PST) Received: from carol.redhat.com (carol.k8r.cz [IPv6:::1]) by carol.localdomain (Postfix) with ESMTP id 288C6C20056 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=1637450067; 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=yc3Dd5k6TeCI0E/JxxxZ44aG3ZXjTcNQ/BuuFKmr6Fc=; b=gLf95f6dJtecGfPBXKAQRJGF7qcP/wi9EH8IreTG9G2BeeZHA0EggVAgCiKQJNSio7/Mmx F4x0Ga0kVq5BlraODWksxE3s+ooNre+F0LoQgrRG82Y5KtUqWI9taPWhKUNjXrFXbNZ8SL YAnCvyQI/QqxPY6CqmWTj8cWw2JnsD4= X-MC-Unique: b6Kho8nINjyWkaugQ4EZag-1 X-MC-Unique: kMiJjuI2PIq6BeuMyvgFGQ-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=yc3Dd5k6TeCI0E/JxxxZ44aG3ZXjTcNQ/BuuFKmr6Fc=; b=uduFOxhwIMh6Xc96XvJ86L8ovRpoUVRb4qfTKGZgZ3PuRmeEq25dq9Ftaq+ZeMRMzf TZ0QMCYNaHV9sQnULGa4FOQwBro2wCOd8O1e5mWoSjc1+lYRC6q0AiyqL3bi+QOqdds4 Uvho8ZWcg+wK/z7Us/AXUxL2uSh33EZ8YgxluTMOuYLn6SoNOw9uCGs3JN/ZF/k1nayd 0rrUBFxZE+/ELGeVYA8bQntMpyjs14PH8nmCdOpRCtW8VVdlHMZp8DA2PhFcHVPZXr0g CLLYg7A1EdejUDTfM+O8wlCu6FySz/V6jmAfz3gdwej69S4Stq9OuoF+ezF9rcn28uWa 2XVg== X-Gm-Message-State: AOAM532hLuwvn4wpSQIZaWyDUkcv3Oi9cOfXXPlsmdH33X7CtEsY8FXu hGSzmn9yTLchQyHD/v9lo9wj+Xkrl/q/M7ze57NdbBUs7Om/fj7DY61kD5XtaqWi0B7XY77fhiT dTUIHHJHwJ2drlcP3jtZn5eEZ0pWaTEoRRjcQie54Aplv5tw0a8PZUYUNFnQAvYlZM/i9g2w= X-Received: by 2002:a50:d88a:: with SMTP id p10mr42938328edj.274.1637449818444; Sat, 20 Nov 2021 15:10:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJztks/niJeCKH3CsGRom3rE4cPAsuUlAMCrUHooUB4Hh1mk690D5p3O/ZywCuzf2gfOw2KG0g== X-Received: by 2002:a50:d88a:: with SMTP id p10mr42938293edj.274.1637449818267; Sat, 20 Nov 2021 15:10:18 -0800 (PST) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 6/7] util: Check for pkttyagent availability properly Date: Sun, 21 Nov 2021 00:10:07 +0100 Message-Id: <6498ff1c90e21df99e46cd021adf1244d45b926c.1637449540.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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: 1637450069021100001 Content-Type: text/plain; charset="utf-8" It does not need a tty to work, it opens its controlling terminal for user interaction and with this patch even crazy things like this work: echo 'list --name' | virsh -q >/dev/null Signed-off-by: Martin Kletzander Reviewed-by: J=C3=A1n Tomko --- src/util/virpolkit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/virpolkit.c b/src/util/virpolkit.c index 63bb8133a8aa..7156adc10c0a 100644 --- a/src/util/virpolkit.c +++ b/src/util/virpolkit.c @@ -180,9 +180,9 @@ virPolkitAgentCreate(void) int outfd =3D STDOUT_FILENO; int errfd =3D STDERR_FILENO; =20 - if (!isatty(STDIN_FILENO)) { + if (!virPolkitAgentAvailable()) { virReportError(VIR_ERR_SYSTEM_ERROR, "%s", - _("Cannot start polkit text agent without a tty")); + _("polkit text authentication agent unavailable")); goto error; } =20 --=20 2.34.0 From nobody Fri Mar 29 08:12:29 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=1637449833; cv=none; d=zohomail.com; s=zohoarc; b=liPK8a6Z4EnEF8dtnP/l6IXIyxcR7lRLGcjWGU3lSe1Up55tcatmq4DVXlRa8+0ar9eAp1iCw4KEBNOgOxW1lo6wRFQFKN7s/0CKk5qb3yjRLS775LpwRYcBOrdCOvBZoKQ+ZcZ/OypNo72DWWoveMCNAwzJjzB+9Q0mFFZT6s4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637449833; 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=h43M5erneZU2TxEIura1GfgN4isEeJCyDCR6yXs0+6Q=; b=QdDpGwA0Idh3++v0xj5Dx6ObH8VGmKpOYqnWpJpo2rdEEnQao27B+sA+Co8vs2B0lpQLZkoz3PyTFbzbbJB3LszJCvr2baoUj1f/EuZMWHoRljPb1dmYS/w+r7o1H7TGUxce4kci+HmHxpvQjGhE6JWSDTQIjIE1E07RKHuu9fI= 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 1637449833620327.1456792077121; Sat, 20 Nov 2021 15:10:33 -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-564-SnLJ--sAMUCcdMVWgdWYWA-1; Sat, 20 Nov 2021 18:10:29 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4D8751006AA0; Sat, 20 Nov 2021 23:10:24 +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 14F2779455; Sat, 20 Nov 2021 23:10:23 +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 51D5F4A704; Sat, 20 Nov 2021 23:10:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AKNALAm001705 for ; Sat, 20 Nov 2021 18:10:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6209640CFD15; Sat, 20 Nov 2021 23:10:21 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5CADA40CFD0C for ; Sat, 20 Nov 2021 23:10:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 40AF480122B for ; Sat, 20 Nov 2021 23:10:21 +0000 (UTC) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-261-c6vIE7UTPu6uV2AEyiYlTw-1; Sat, 20 Nov 2021 18:10:19 -0500 Received: by mail-ed1-f70.google.com with SMTP id q17-20020aa7da91000000b003e7c0641b9cso11509801eds.12 for ; Sat, 20 Nov 2021 15:10:19 -0800 (PST) Received: from carol.localdomain (k8r.cz. [95.82.177.71]) by smtp.gmail.com with ESMTPSA id c11sm1839089ede.32.2021.11.20.15.10.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Nov 2021 15:10:17 -0800 (PST) Received: from carol.redhat.com (carol.k8r.cz [IPv6:::1]) by carol.localdomain (Postfix) with ESMTP id 291B3C20059 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=1637449832; 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=h43M5erneZU2TxEIura1GfgN4isEeJCyDCR6yXs0+6Q=; b=Ox+NhbENJ0z8C0ULWlehAhQ7cgJrkvZZyvb99KvBiHDWRRHjfsBpBX8BY7nO799H5jd7N5 wZmusyumHqMN9ogKtZjSZxesPfq3UUNJ7eKVAqrlQablCfNkaioaP9r6oJLGB1gk1bNEEH IEpQjVbSJNoWM7Atr+/D6If+twxOUzg= X-MC-Unique: SnLJ--sAMUCcdMVWgdWYWA-1 X-MC-Unique: c6vIE7UTPu6uV2AEyiYlTw-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=h43M5erneZU2TxEIura1GfgN4isEeJCyDCR6yXs0+6Q=; b=RCs+rKLx5BkloQBy5IoRuAa9h7CiHZ9SY8urFtHmP7zYr0GCVhxbccPEsLqI2CVhD7 BqLEnkTz+SXtm6u3+LoYih3wpnLNCNKeqSA1ukAFYCC9rZh0nV4OUKLfPFkwjn+WWrt8 6Nqn9VZyeCQ7Qh6v4uMWDrdLy6SP6BSiMJNxlW1uxbqaDYfVdcq84VTZ7Vv7Hk1n+1mU uvuzzIi47hJr4lgkKFfoFyxGz8XRnPGO3ZO7JcUmohY5kep+Rq9AqVjX2VgeBEsHIQLp NdKPRT6h9Kc+gkeq3Vl3XoFrkJMNcM8IRRXnQibZA7BtLH6Uei2EhaYDgLQpc4AIYWNF WfZA== X-Gm-Message-State: AOAM533JrBamn3EmXMTxxpbai56LveYL4HWWxxiUgw1Lr73fXS2InTen Uyuk7M/2YBpNl1lgerAyRuYiLrSMe4aFZnBZ9uW41ArwFipT31C6ojUDeH4WJZbPIWFyzKhrqhg QhOXxUNA2f78AeOuEzdSAOu397am3U76bu6SNsg0Ty8mEOmvUH+ZSVPLFzLuX2xJEwuoaEAU= X-Received: by 2002:a17:906:58c9:: with SMTP id e9mr23758881ejs.181.1637449818738; Sat, 20 Nov 2021 15:10:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXl8H9O4HkPNSzdnbzx+2z30v5FifoaB1Yi88i94ft6gbfjw7ayDJx7FB6Mzvy/W/Eliqxlw== X-Received: by 2002:a17:906:58c9:: with SMTP id e9mr23758838ejs.181.1637449818472; Sat, 20 Nov 2021 15:10:18 -0800 (PST) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 7/7] util: Make client-side polkit work even with polkit disabled Date: Sun, 21 Nov 2021 00:10:08 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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.79 on 10.5.11.16 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: 1637449834678100001 Content-Type: text/plain; charset="utf-8" The reason for this is twofold: - the polkit build option is documented for UNIX socket access checks - there is no server-side change or dbus call done when enabling this as it= only starts a polkit agent on the client-side (actually only in virsh) and doe= s not need any requirements (starting is skipped if pkttyagent is not installed) Also move the conditional implementation to the bottom of the file so that = it does not look like the whole file is build conditionally and the common functions are at the top. Signed-off-by: Martin Kletzander --- src/util/virpolkit.c | 240 ++++++++++++++++++++----------------------- 1 file changed, 109 insertions(+), 131 deletions(-) diff --git a/src/util/virpolkit.c b/src/util/virpolkit.c index 7156adc10c0a..b51104100796 100644 --- a/src/util/virpolkit.c +++ b/src/util/virpolkit.c @@ -21,6 +21,7 @@ =20 #include #include +#include #include =20 #include "virpolkit.h" @@ -37,119 +38,10 @@ =20 VIR_LOG_INIT("util.polkit"); =20 -#if WITH_POLKIT -# include - struct _virPolkitAgent { virCommand *cmd; }; =20 -/* - * virPolkitCheckAuth: - * @actionid: permission to check - * @pid: client process ID - * @startTime: process start time, or 0 - * @uid: client process user ID - * @details: NULL terminated (key, value) pair list - * @allowInteraction: true if auth prompts are allowed - * - * Check if a client is authenticated with polkit - * - * Returns 0 on success, -1 on failure, -2 on auth denied - */ -int virPolkitCheckAuth(const char *actionid, - pid_t pid, - unsigned long long startTime, - uid_t uid, - const char **details, - bool allowInteraction) -{ - GDBusConnection *sysbus; - GVariantBuilder builder; - GVariant *gprocess =3D NULL; - GVariant *gdetails =3D NULL; - g_autoptr(GVariant) message =3D NULL; - g_autoptr(GVariant) reply =3D NULL; - g_autoptr(GVariantIter) iter =3D NULL; - char *retkey; - char *retval; - gboolean is_authorized; - gboolean is_challenge; - bool is_dismissed =3D false; - const char **next; - - if (!(sysbus =3D virGDBusGetSystemBus())) - return -1; - - VIR_INFO("Checking PID %lld running as %d", - (long long) pid, uid); - - g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}")); - g_variant_builder_add(&builder, "{sv}", "pid", g_variant_new_uint32(pi= d)); - g_variant_builder_add(&builder, "{sv}", "start-time", g_variant_new_ui= nt64(startTime)); - g_variant_builder_add(&builder, "{sv}", "uid", g_variant_new_int32(uid= )); - gprocess =3D g_variant_builder_end(&builder); - - g_variant_builder_init(&builder, G_VARIANT_TYPE("a{ss}")); - - if (details) { - for (next =3D details; *next; next++) { - const char *detail1 =3D *(next++); - const char *detail2 =3D *next; - g_variant_builder_add(&builder, "{ss}", detail1, detail2); - } - } - - gdetails =3D g_variant_builder_end(&builder); - - message =3D g_variant_new("((s@a{sv})s@a{ss}us)", - "unix-process", - gprocess, - actionid, - gdetails, - allowInteraction, - "" /* cancellation ID */); - - if (virGDBusCallMethod(sysbus, - &reply, - G_VARIANT_TYPE("((bba{ss}))"), - NULL, - "org.freedesktop.PolicyKit1", - "/org/freedesktop/PolicyKit1/Authority", - "org.freedesktop.PolicyKit1.Authority", - "CheckAuthorization", - message) < 0) - return -1; - - g_variant_get(reply, "((bba{ss}))", &is_authorized, &is_challenge, &it= er); - - while (g_variant_iter_loop(iter, "{ss}", &retkey, &retval)) { - if (STREQ(retkey, "polkit.dismissed") && STREQ(retval, "true")) - is_dismissed =3D true; - } - - VIR_DEBUG("is auth %d is challenge %d", - is_authorized, is_challenge); - - if (is_authorized) - return 0; - - if (is_dismissed) { - virReportError(VIR_ERR_AUTH_CANCELLED, "%s", - _("user cancelled authentication process")); - } else if (is_challenge) { - virReportError(VIR_ERR_AUTH_UNAVAILABLE, - _("no polkit agent available to authenticate action= '%s'"), - actionid); - } else { - virReportError(VIR_ERR_AUTH_FAILED, "%s", - _("access denied by policy")); - } - - return -2; -} - - /* virPolkitAgentDestroy: * @cmd: Pointer to the virCommand * created during virPolkitAgentCreate * @@ -260,6 +152,114 @@ virPolkitAgentAvailable(void) return true; } =20 + +#if WITH_POLKIT + +/* + * virPolkitCheckAuth: + * @actionid: permission to check + * @pid: client process ID + * @startTime: process start time, or 0 + * @uid: client process user ID + * @details: NULL terminated (key, value) pair list + * @allowInteraction: true if auth prompts are allowed + * + * Check if a client is authenticated with polkit + * + * Returns 0 on success, -1 on failure, -2 on auth denied + */ +int virPolkitCheckAuth(const char *actionid, + pid_t pid, + unsigned long long startTime, + uid_t uid, + const char **details, + bool allowInteraction) +{ + GDBusConnection *sysbus; + GVariantBuilder builder; + GVariant *gprocess =3D NULL; + GVariant *gdetails =3D NULL; + g_autoptr(GVariant) message =3D NULL; + g_autoptr(GVariant) reply =3D NULL; + g_autoptr(GVariantIter) iter =3D NULL; + char *retkey; + char *retval; + gboolean is_authorized; + gboolean is_challenge; + bool is_dismissed =3D false; + const char **next; + + if (!(sysbus =3D virGDBusGetSystemBus())) + return -1; + + VIR_INFO("Checking PID %lld running as %d", + (long long) pid, uid); + + g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&builder, "{sv}", "pid", g_variant_new_uint32(pi= d)); + g_variant_builder_add(&builder, "{sv}", "start-time", g_variant_new_ui= nt64(startTime)); + g_variant_builder_add(&builder, "{sv}", "uid", g_variant_new_int32(uid= )); + gprocess =3D g_variant_builder_end(&builder); + + g_variant_builder_init(&builder, G_VARIANT_TYPE("a{ss}")); + + if (details) { + for (next =3D details; *next; next++) { + const char *detail1 =3D *(next++); + const char *detail2 =3D *next; + g_variant_builder_add(&builder, "{ss}", detail1, detail2); + } + } + + gdetails =3D g_variant_builder_end(&builder); + + message =3D g_variant_new("((s@a{sv})s@a{ss}us)", + "unix-process", + gprocess, + actionid, + gdetails, + allowInteraction, + "" /* cancellation ID */); + + if (virGDBusCallMethod(sysbus, + &reply, + G_VARIANT_TYPE("((bba{ss}))"), + NULL, + "org.freedesktop.PolicyKit1", + "/org/freedesktop/PolicyKit1/Authority", + "org.freedesktop.PolicyKit1.Authority", + "CheckAuthorization", + message) < 0) + return -1; + + g_variant_get(reply, "((bba{ss}))", &is_authorized, &is_challenge, &it= er); + + while (g_variant_iter_loop(iter, "{ss}", &retkey, &retval)) { + if (STREQ(retkey, "polkit.dismissed") && STREQ(retval, "true")) + is_dismissed =3D true; + } + + VIR_DEBUG("is auth %d is challenge %d", + is_authorized, is_challenge); + + if (is_authorized) + return 0; + + if (is_dismissed) { + virReportError(VIR_ERR_AUTH_CANCELLED, "%s", + _("user cancelled authentication process")); + } else if (is_challenge) { + virReportError(VIR_ERR_AUTH_UNAVAILABLE, + _("no polkit agent available to authenticate action= '%s'"), + actionid); + } else { + virReportError(VIR_ERR_AUTH_FAILED, "%s", + _("access denied by policy")); + } + + return -2; +} + #else /* ! WITH_POLKIT */ =20 int virPolkitCheckAuth(const char *actionid G_GNUC_UNUSED, @@ -275,26 +275,4 @@ int virPolkitCheckAuth(const char *actionid G_GNUC_UNU= SED, return -1; } =20 - -void -virPolkitAgentDestroy(virPolkitAgent *agent G_GNUC_UNUSED) -{ - return; /* do nothing */ -} - - -virPolkitAgent * -virPolkitAgentCreate(void) -{ - virReportError(VIR_ERR_AUTH_FAILED, "%s", - _("polkit text authentication agent unavailable")); - return NULL; -} - -bool -virPolkitAgentAvailable(void) -{ - return false; -} - #endif /* WITH_POLKIT */ --=20 2.34.0