From nobody Fri Nov 1 00:38:24 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=1644601476; cv=none; d=zohomail.com; s=zohoarc; b=LLKcmVVpAMx6T2EJnE/MwwlddF+3Hknw5djFq7FG/ZluRihw92a3KYGC1eUDdUWMN91DeRmxQ+a3vhuAZx2Jp5/zqJYgUK0xxTm5X8P9LHn7fjivXAWpdFKPVDOK/tGLkQgk+K07wMOO1lEIfkgFAoToiJwNizenmh5Hee9xC00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644601476; 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=s5ZrRqXrOvYZLXTw/6mOlV22QXhl32GY72HCqIWiKDI=; b=AG32+oMVUM4Qz1PirjznGJxgFfwhLe8RwDnslXY2uNC3fMEOSEOZWsRugJ063bsFJP/YXrB9tYIeADHZnxiS6Uwx21SvRyCpUPdKuEmAkfgmhHSTneTwFbZcihR71nhzVBeINkQHw/2eDhrnYPmmeASsN65yXyAF/pYSe2pZpuQ= 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 164460147646922.75097494338945; Fri, 11 Feb 2022 09:44:36 -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-272-Ql55vz-SOyOabrG-YLOzJw-1; Fri, 11 Feb 2022 12:44: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 B0E42344B0; Fri, 11 Feb 2022 17:44: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 63F942E17C; Fri, 11 Feb 2022 17:44: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 0CC1E180B617; Fri, 11 Feb 2022 17:44:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21BHdY7J006585 for ; Fri, 11 Feb 2022 12:39:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 001C934D41; Fri, 11 Feb 2022 17:39:34 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.194.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F86934D40 for ; Fri, 11 Feb 2022 17:39:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644601475; 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=s5ZrRqXrOvYZLXTw/6mOlV22QXhl32GY72HCqIWiKDI=; b=PWGwHZJRBWYX1YCCMvRA79CU3OdX/yoV/8qSMhZu4HbU/gdbal7RV6BNNKRhVId+eieN20 9BhpbMpzLKJ1Yfv3i+eaTvlKo3hq2WrgwabHa8QeFPGS+OhRX1/5METTsq45U5fKuCOcE7 WaWnslG5kxmtZakTcZQcxMJ7P9ZS034= X-MC-Unique: Ql55vz-SOyOabrG-YLOzJw-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 01/11] virbuftest: Increase coverage Date: Fri, 11 Feb 2022 18:39:09 +0100 Message-Id: <20220211173919.112353-2-abologna@redhat.com> In-Reply-To: <20220211173919.112353-1-abologna@redhat.com> References: <20220211173919.112353-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644601477604100001 Content-Type: text/plain; charset="utf-8" Test the behavior of virBufferEscapeShell for different types of quotes as well as the empty string. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- tests/virbuftest.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/virbuftest.c b/tests/virbuftest.c index 977e0883a6..79bd0cae8e 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -20,7 +20,8 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUS= ED) g_auto(virBuffer) bufinit =3D VIR_BUFFER_INITIALIZER; virBuffer *buf =3D &bufinit; const char expected[] =3D - " 1\n 2\n 3\n 4\n 5\n 6\n 7\n &\n 8\n 9\n 10\n ' 1= 1'\n"; + " 1\n 2\n 3\n 4\n 5\n 6\n 7\n &\n 8\n 9\n 10\n" + " ' 11'\n ''\\''12'\n '\"13'\n ''\n"; g_autofree char *result =3D NULL; int ret =3D 0; =20 @@ -85,6 +86,12 @@ static int testBufAutoIndent(const void *data G_GNUC_UNU= SED) virBufferAddChar(buf, '\n'); virBufferEscapeShell(buf, " 11"); virBufferAddChar(buf, '\n'); + virBufferEscapeShell(buf, "'12"); + virBufferAddChar(buf, '\n'); + virBufferEscapeShell(buf, "\"13"); + virBufferAddChar(buf, '\n'); + virBufferEscapeShell(buf, ""); + virBufferAddChar(buf, '\n'); =20 result =3D virBufferContentAndReset(buf); if (!result || STRNEQ(result, expected)) { --=20 2.34.1 From nobody Fri Nov 1 00:38:24 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=1644601716; cv=none; d=zohomail.com; s=zohoarc; b=W+YIOSxEJidmCE0yPMy+BUJMTO1P9IIZZATEEz5LZnh+VwdTWft58w/lx9XOWXkkZ+/lzk9T3rkmQAMASGK4SOCPB5ZfJaonrAKQdxawAO6VZJPc6rkgb3NUmn/qa3AOZe+JLfnD7nsFsn+xDE/RpEvshoyAb3ULSRTshkKzyF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644601716; 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=BKmq0bYmku7QPQhkxwVxZWAUTBciXFQVCPV3yhEk/Wo=; b=evNddUuC6Lt/wuRncVUuLTidGQXXWO+OvAyrWpskrzz35sT/6fiYiX9xs9rDqnSDHcws62sLwUw3DTn6WqpSdjIGe+4AEj/IOqD5iMUVGxDRUmN0N80Dlrd6Q08D2Van55/aqHOiXsNVLh92YfQMwBVIU5s908eC7XxMUXe40Xk= 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 1644601716327258.95886826213564; Fri, 11 Feb 2022 09:48:36 -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-326--0kJpByIPTyK3De7KANL_w-1; Fri, 11 Feb 2022 12:48: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 3F0181091DA7; Fri, 11 Feb 2022 17:48: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 BC8992DE99; Fri, 11 Feb 2022 17:48:27 +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 79D8D1806D1C; Fri, 11 Feb 2022 17:48:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21BHdc9F006596 for ; Fri, 11 Feb 2022 12:39:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9783134D41; Fri, 11 Feb 2022 17:39:38 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.194.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DF25034D3E for ; Fri, 11 Feb 2022 17:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644601715; 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=BKmq0bYmku7QPQhkxwVxZWAUTBciXFQVCPV3yhEk/Wo=; b=SKHXmOAn0O2EbGrASiJQSPYxIxVCw3T7bBcXjhyWpi0LdJni0B1fCvwMxRzdMevuURlk65 BIvXba5a1I2YmgK4m3Wj2NZ7cOCGHblKpAzpE28ZevXL+Rwl53tu/Y5OurdNDdQt3DeIe9 RBQCO6mtkSCIpfk2/qWc8KvKZYHN+Ws= X-MC-Unique: -0kJpByIPTyK3De7KANL_w-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 02/11] virbuffer: Simplify virBufferEscapeShell() Date: Fri, 11 Feb 2022 18:39:10 +0100 Message-Id: <20220211173919.112353-3-abologna@redhat.com> In-Reply-To: <20220211173919.112353-1-abologna@redhat.com> References: <20220211173919.112353-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644601717075100001 Content-Type: text/plain; charset="utf-8" We can exit early when the input is an empty string, and we can avoid storing the string length in a variable since we only use that information once. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/util/virbuffer.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c index a4834174a1..19cf775a8c 100644 --- a/src/util/virbuffer.c +++ b/src/util/virbuffer.c @@ -552,7 +552,6 @@ virBufferURIEncodeString(virBuffer *buf, const char *st= r) void virBufferEscapeShell(virBuffer *buf, const char *str) { - int len; g_autofree char *escaped =3D NULL; char *out; const char *cur; @@ -560,21 +559,19 @@ virBufferEscapeShell(virBuffer *buf, const char *str) if ((buf =3D=3D NULL) || (str =3D=3D NULL)) return; =20 - /* Only quote if str includes shell metacharacters. */ - if (*str && !strpbrk(str, "\r\t\n !\"#$&'()*;<>?[\\]^`{|}~")) { - virBufferAdd(buf, str, -1); + if (!*str) { + virBufferAddLit(buf, "''"); return; } =20 - if (*str) { - len =3D strlen(str); - - escaped =3D g_malloc0_n(len + 1, 4); - } else { - virBufferAddLit(buf, "''"); + /* Only quote if str includes shell metacharacters. */ + if (!strpbrk(str, "\r\t\n !\"#$&'()*;<>?[\\]^`{|}~")) { + virBufferAdd(buf, str, -1); return; } =20 + escaped =3D g_malloc0_n(strlen(str) + 1, 4); + cur =3D str; out =3D escaped; =20 --=20 2.34.1 From nobody Fri Nov 1 00:38:24 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=1644601334; cv=none; d=zohomail.com; s=zohoarc; b=Uz5X1diHpPzdZbF+jdG7jum13DrswKWAZCszLfT1ienM/cVKn4JAJZs3+n/EhezgkFQHKDCh9dTBzxWLqsBwhgQWon2GkMvUNuYe32exw+sn90J7yuhQbiBSlcjxZx80nXx7AmZqXFr3xdgSW71WVCaNR9gvUepyizctY2mFfcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644601334; 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=N008KdezTZ/h4OBTiexmeIh4GJmigfHgM9GDnmXmqQ4=; b=hsaDiRTEn21VGiXFGY/O9o9XMQFIQINiY6DCKgtDUH21Za8o07zxZWxyJfFT+TlTisAcmMe2hBx2oowp3j3939XJZrNOPkdaTgIm1cILaRcfvREw1zENWwuOxsIa2yzl02o0vANtCjMSjaM5xqdI/cgDITLUg8/75qEKEw9GnXI= 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 1644601334091754.5580682630599; Fri, 11 Feb 2022 09:42:14 -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-370-zMFNt3rUOPC8w3yaQOuW_A-1; Fri, 11 Feb 2022 12:42:11 -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 7AD7994EE1; Fri, 11 Feb 2022 17:42:04 +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 5485462D40; Fri, 11 Feb 2022 17:42:04 +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 EC0F64BB7C; Fri, 11 Feb 2022 17:42:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21BHddhH006605 for ; Fri, 11 Feb 2022 12:39:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id A7A4F34D3E; Fri, 11 Feb 2022 17:39:39 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.194.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B5EB34D43 for ; Fri, 11 Feb 2022 17:39:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644601332; 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=N008KdezTZ/h4OBTiexmeIh4GJmigfHgM9GDnmXmqQ4=; b=QGTfMhQ6dkTuursh5WZnhd8IbElxpfDUF9rH5+mqgj8H6TR7Cc/3IrhaYZnqSHj4QV5ILV OzBuFzOjwmuJbxzMXx2F3rIuUhcykA35WXhNMyJAaIIFfH/eus3B40ggjqxf4SBmjdKLiF cZMSCn1AfGcjJQ0yXOrkZyxdu6O9/QU= X-MC-Unique: zMFNt3rUOPC8w3yaQOuW_A-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 03/11] virnetsockettest: Drop unnecessary backslash Date: Fri, 11 Feb 2022 18:39:11 +0100 Message-Id: <20220211173919.112353-4-abologna@redhat.com> In-Reply-To: <20220211173919.112353-1-abologna@redhat.com> References: <20220211173919.112353-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644601336692100001 Content-Type: text/plain; charset="utf-8" No need to escape a single quote. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- tests/virnetsockettest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 447cbee89c..0928f7056a 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -664,7 +664,7 @@ mymain(void) .netcat =3D "/tmp/fo o/nc", .path =3D "/tmp/socket", .expectOut =3D "-T -e none -- somehost sh -c '" - "if \'''\\''/tmp/fo o/nc'\\'''' -q 2>&1 | grep \"requ= ires an argument\" >/dev/null 2>&1; then " + "if '''\\''/tmp/fo o/nc'\\'''' -q 2>&1 | grep \"requi= res an argument\" >/dev/null 2>&1; then " "ARG=3D-q0;" "else " "ARG=3D;" --=20 2.34.1 From nobody Fri Nov 1 00:38:24 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=1644601483; cv=none; d=zohomail.com; s=zohoarc; b=LyZmJ10bQ3BPca9JDLm8DTbstQZlm99LwplnWPgydLzUL49Q7Yda+tYPNmEsavCZUOiq3GaUS9MAjPzmLKnzfn/Edq0sZ4N4iLXpgd0EQMDYpMXnFKM/xWtEnqW71txY+CEAyIG0SWkDj1fm9kjc1ET99Hcu0wmfumDno1QE69o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644601483; 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=FLZOgGYey6ANYyYnn9pWi0+vMa85+w+Tq51dbZJePwA=; b=dGox20UnR2EmdjSf5i0X6QqcFTjxdxGwnRPJq5aqRRkIw76TbmfbDwpBGP9LxvwgAGwawvZTDwtc+Det0iPvsv3qLtCDzYFnEiTkAQp+UGk5QOdkGtM7z5MAWsah3LV/GESkmVseRCH/X47XWh0pQc3UIWw7LMtvmutQrKAugvQ= 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 1644601483939734.6429592155764; Fri, 11 Feb 2022 09:44:43 -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-249-TXpsLQ9gMIa-0BnZAnSOjg-1; Fri, 11 Feb 2022 12:44:41 -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 0599C84DA40; Fri, 11 Feb 2022 17:44:36 +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 D94697E114; Fri, 11 Feb 2022 17:44:35 +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 84DAC1806D1D; Fri, 11 Feb 2022 17:44:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21BHdePI006612 for ; Fri, 11 Feb 2022 12:39:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id B155634D3E; Fri, 11 Feb 2022 17:39:40 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.194.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 14C8734D43 for ; Fri, 11 Feb 2022 17:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644601482; 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=FLZOgGYey6ANYyYnn9pWi0+vMa85+w+Tq51dbZJePwA=; b=fDnEqpQp3YDTfVq7He5HgbL5YbMIq/+IeLPXdbnINL1XbB3Dti5ybbmNVIzXJl++IUQQzc c4rH4sbUmVnHfN1uB/BcY7q1sr/C3kpytMQBs+lFgTnlV2wSQ1oyb2Wc3ejb2M8vYTpaz6 +iVtyKrPVVMXdYosbCHKtCOWhujlqyw= X-MC-Unique: TXpsLQ9gMIa-0BnZAnSOjg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 04/11] virnetsockettest: Move opening quote Date: Fri, 11 Feb 2022 18:39:12 +0100 Message-Id: <20220211173919.112353-5-abologna@redhat.com> In-Reply-To: <20220211173919.112353-1-abologna@redhat.com> References: <20220211173919.112353-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644601485678100001 Content-Type: text/plain; charset="utf-8" Make this test case consistent with all the other ones. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- tests/virnetsockettest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 0928f7056a..429c4e5f9d 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -630,8 +630,8 @@ mymain(void) .nodename =3D "crashyhost", .path =3D "/tmp/socket", .netcat =3D "nc", - .expectOut =3D "-T -e none -- crashyhost sh -c " - "'if 'nc' -q 2>&1 | grep \"requires an argument\" >/d= ev/null 2>&1; then " + .expectOut =3D "-T -e none -- crashyhost sh -c '" + "if 'nc' -q 2>&1 | grep \"requires an argument\" >/de= v/null 2>&1; then " "ARG=3D-q0;" "else " "ARG=3D;" --=20 2.34.1 From nobody Fri Nov 1 00:38:24 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=1644601337; cv=none; d=zohomail.com; s=zohoarc; b=bvxjKYlOC3nX9aiI61TFijkhoPAZ8P2H1LPZUFRoTEvlV3gMYTN0xJt1ZHhz8AI/yGpAICQcsQnoNbN2g89/JXrQBCy6i4t/Xme+/W0IFnF1m+fIKpySdC2NYkoB6IlN6w9mMv8coeWD9AQV4NoJt7oX7dTt45Pgc1+fCA+h+08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644601337; 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=RZN0n6wh+JYBBHHskKxYC4uOfxNa7p6fqeFEiwZUWg4=; b=iaNabAKzDaEkisReQ8ZCm0N8cRp1IEcfmQZ5bmavEYRSslhCZm6q6uIkZXIjrawmUaRtiSSUhUUIu0+sRWGja9mlk2LGn1Mjo5TL4yR3ozSwrOhUExL0oFmKV8UjFcumYBt6RB2O3B7PfNGil4zOMn+/iSG6wOvWGCl22WLksAE= 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 1644601337500920.6884562355413; Fri, 11 Feb 2022 09:42:17 -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-644-YP3IfT7MOxW_maG0_AJ7fQ-1; Fri, 11 Feb 2022 12:42:14 -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 397231006AA0; Fri, 11 Feb 2022 17:42:09 +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 1AE377D490; Fri, 11 Feb 2022 17:42:09 +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 DC2201809CB8; Fri, 11 Feb 2022 17:42:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21BHeGav006711 for ; Fri, 11 Feb 2022 12:40:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id F295A34B4B; Fri, 11 Feb 2022 17:40:15 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.194.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53C4034B21 for ; Fri, 11 Feb 2022 17:39:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644601336; 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=RZN0n6wh+JYBBHHskKxYC4uOfxNa7p6fqeFEiwZUWg4=; b=CKFX8m0ZB5m0HqLje3z2tRWlU+GGhkIr39ux9xaUuJkMQaXwAuLwyu/xzE6TAdvpP0d9iF PTXF5wsRLNT4AcnogpBvyu9KsacWPCgiq4Ag/eB5wQGtd8MysNHJXhG0Ebj/UT1NpWQA+z Pj0t3LlpyDCelAbbo7YWgK6lJDsXY0M= X-MC-Unique: YP3IfT7MOxW_maG0_AJ7fQ-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 05/11] virnetsockettest: Improve indentation Date: Fri, 11 Feb 2022 18:39:13 +0100 Message-Id: <20220211173919.112353-6-abologna@redhat.com> In-Reply-To: <20220211173919.112353-1-abologna@redhat.com> References: <20220211173919.112353-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644601338668100003 Content-Type: text/plain; charset="utf-8" Having the actual script indented and the closing quote on a separate line, like sh -c ' if foo; then bar; fi ' makes things more readable and easier to scan visually. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- tests/virnetsockettest.c | 78 +++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 429c4e5f9d..d6bcfc93d1 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -570,12 +570,13 @@ mymain(void) .path =3D "/tmp/socket", .netcat =3D "nc", .expectOut =3D "-T -e none -- somehost sh -c '" - "if 'nc' -q 2>&1 | grep \"requires an argument\" >/de= v/null 2>&1; then " - "ARG=3D-q0;" - "else " - "ARG=3D;" - "fi;" - "'nc' $ARG -U /tmp/socket'\n", + "if 'nc' -q 2>&1 | grep \"requires an argument\" = >/dev/null 2>&1; then " + "ARG=3D-q0;" + "else " + "ARG=3D;" + "fi;" + "'nc' $ARG -U /tmp/socket" + "'\n", }; if (virTestRun("SSH test 1", testSocketSSH, &sshData1) < 0) ret =3D -1; @@ -589,12 +590,13 @@ mymain(void) .noVerify =3D false, .path =3D "/tmp/socket", .expectOut =3D "-p 9000 -l fred -T -e none -o BatchMode=3Dyes -- s= omehost sh -c '" - "if 'netcat' -q 2>&1 | grep \"requires an argument\" = >/dev/null 2>&1; then " - "ARG=3D-q0;" - "else " - "ARG=3D;" - "fi;" - "'netcat' $ARG -U /tmp/socket'\n", + "if 'netcat' -q 2>&1 | grep \"requires an argumen= t\" >/dev/null 2>&1; then " + "ARG=3D-q0;" + "else " + "ARG=3D;" + "fi;" + "'netcat' $ARG -U /tmp/socket" + "'\n", }; if (virTestRun("SSH test 2", testSocketSSH, &sshData2) < 0) ret =3D -1; @@ -608,12 +610,13 @@ mymain(void) .noVerify =3D true, .path =3D "/tmp/socket", .expectOut =3D "-p 9000 -l fred -T -e none -o StrictHostKeyCheckin= g=3Dno -- somehost sh -c '" - "if 'netcat' -q 2>&1 | grep \"requires an argument\" = >/dev/null 2>&1; then " - "ARG=3D-q0;" - "else " - "ARG=3D;" - "fi;" - "'netcat' $ARG -U /tmp/socket'\n", + "if 'netcat' -q 2>&1 | grep \"requires an argumen= t\" >/dev/null 2>&1; then " + "ARG=3D-q0;" + "else " + "ARG=3D;" + "fi;" + "'netcat' $ARG -U /tmp/socket" + "'\n", }; if (virTestRun("SSH test 3", testSocketSSH, &sshData3) < 0) ret =3D -1; @@ -631,12 +634,13 @@ mymain(void) .path =3D "/tmp/socket", .netcat =3D "nc", .expectOut =3D "-T -e none -- crashyhost sh -c '" - "if 'nc' -q 2>&1 | grep \"requires an argument\" >/de= v/null 2>&1; then " - "ARG=3D-q0;" - "else " - "ARG=3D;" - "fi;" - "'nc' $ARG -U /tmp/socket'\n", + "if 'nc' -q 2>&1 | grep \"requires an argument\" = >/dev/null 2>&1; then " + "ARG=3D-q0;" + "else " + "ARG=3D;" + "fi;" + "'nc' $ARG -U /tmp/socket" + "'\n", .dieEarly =3D true, }; if (virTestRun("SSH test 5", testSocketSSH, &sshData5) < 0) @@ -649,12 +653,13 @@ mymain(void) .keyfile =3D "/root/.ssh/example_key", .noVerify =3D true, .expectOut =3D "-i /root/.ssh/example_key -T -e none -o StrictHost= KeyChecking=3Dno -- example.com sh -c '" - "if 'nc' -q 2>&1 | grep \"requires an argument\" >/de= v/null 2>&1; then " - "ARG=3D-q0;" - "else " - "ARG=3D;" - "fi;" - "'nc' $ARG -U /tmp/socket'\n", + "if 'nc' -q 2>&1 | grep \"requires an argument\" = >/dev/null 2>&1; then " + "ARG=3D-q0;" + "else " + "ARG=3D;" + "fi;" + "'nc' $ARG -U /tmp/socket" + "'\n", }; if (virTestRun("SSH test 6", testSocketSSH, &sshData6) < 0) ret =3D -1; @@ -664,12 +669,13 @@ mymain(void) .netcat =3D "/tmp/fo o/nc", .path =3D "/tmp/socket", .expectOut =3D "-T -e none -- somehost sh -c '" - "if '''\\''/tmp/fo o/nc'\\'''' -q 2>&1 | grep \"requi= res an argument\" >/dev/null 2>&1; then " - "ARG=3D-q0;" - "else " - "ARG=3D;" - "fi;" - "'''\\''/tmp/fo o/nc'\\'''' $ARG -U /tmp/socket'\n", + "if '''\\''/tmp/fo o/nc'\\'''' -q 2>&1 | grep \"r= equires an argument\" >/dev/null 2>&1; then " + "ARG=3D-q0;" + "else " + "ARG=3D;" + "fi;" + "'''\\''/tmp/fo o/nc'\\'''' $ARG -U /tmp/socket" + "'\n", }; VIR_WARNINGS_RESET if (virTestRun("SSH test 7", testSocketSSH, &sshData7) < 0) --=20 2.34.1 From nobody Fri Nov 1 00:38:24 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=1644601727; cv=none; d=zohomail.com; s=zohoarc; b=m0wRlRkihQdf9nAObVNCKuGnyZco+1+Diq6zuRM62ZMRSBaWAAU1hHqXpTm6WVPFRXFbqi4zLFC/eKJLGZd7nYOSjSDG8aCi0OoO6HgdWn211M3Rty3Eu6JddqABbXxTiNL2yuT1FTDlxkZnd/EvYl7xgoSYYdPly/IHA9PcL/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644601727; 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=KZxW2jHEJj0+Map8HHx+Z5YB51XHOP5bdyTk+fU2bUE=; b=b3PlcSsX0okcEu84jZyD5uscx3wNRdzENTPcPX4+IN0938cRbAYk6tlK1bDSz39MB3akn4PdpLvSI1wtIIEd66n9tKcz5KoZoJhPIpZvVxxSk7yMzMqWlp2+spPrVQsUPLBvYP/S0wZOCHAgDiGmNLcnesvYojlQhZKgTBRnUHU= 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 1644601727015479.96283225324476; Fri, 11 Feb 2022 09:48:47 -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-637-6GcyiSpTMkqpIFTA4m5hYg-1; Fri, 11 Feb 2022 12:48:37 -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 9E77C1091DA6; Fri, 11 Feb 2022 17:48:32 +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 7C42634D3A; Fri, 11 Feb 2022 17:48:32 +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 4F9214A7C8; Fri, 11 Feb 2022 17:48:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21BHeHZs006720 for ; Fri, 11 Feb 2022 12:40:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 258D234B21; Fri, 11 Feb 2022 17:40:17 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.194.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 78F9534D56 for ; Fri, 11 Feb 2022 17:40:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644601726; 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=KZxW2jHEJj0+Map8HHx+Z5YB51XHOP5bdyTk+fU2bUE=; b=feFt5SLbTbXtOFS1wzekHRv8Z6qlHhQUXdpN5eKitvxSVZU1R4HjEcc/IV0hQIGQFVs8gG 75kYUQmjPwLUy9qDdI9CjW8+kAMCntETMLkR4w1UX2NwdDN03RydK8YxAsZ6tlmF+5EN6R Y5f5yHY7Wu86mZGaO7gG6sZXk+Jg0EI= X-MC-Unique: 6GcyiSpTMkqpIFTA4m5hYg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 06/11] virnetclient: Improve spacing of ssh script Date: Fri, 11 Feb 2022 18:39:14 +0100 Message-Id: <20220211173919.112353-7-abologna@redhat.com> In-Reply-To: <20220211173919.112353-1-abologna@redhat.com> References: <20220211173919.112353-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644601729332100001 Content-Type: text/plain; charset="utf-8" This results in the generated script having consistent spacing throughout, instead of having repeated whitespace in some parts and commands that are separated by a semicolon and no spacing at all in others. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/rpc/virnetclient.c | 12 ++++++------ tests/virnetsockettest.c | 36 ++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 2998551cd8..cbefa8f11f 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -436,10 +436,10 @@ virNetClientSSHHelperCommand(virNetClientProxy proxy, =20 nccmd =3D g_strdup_printf( "if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; = then " - "ARG=3D-q0;" + "ARG=3D-q0; " "else " - "ARG=3D;" - "fi;" + "ARG=3D; " + "fi; " "'%s' $ARG -U %s", netcatPathSafe, netcatPathSafe, socketPath); =20 @@ -451,9 +451,9 @@ virNetClientSSHHelperCommand(virNetClientProxy proxy, case VIR_NET_CLIENT_PROXY_AUTO: return g_strdup_printf("sh -c 'which virt-ssh-helper 1>/dev/null 2= >&1; " "if test $? =3D 0; then " - " %s; " - "else" - " %s; " + "%s; " + "else " + "%s; " "fi'", helpercmd, nccmd); =20 case VIR_NET_CLIENT_PROXY_NETCAT: diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index d6bcfc93d1..c1d3e39856 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -571,10 +571,10 @@ mymain(void) .netcat =3D "nc", .expectOut =3D "-T -e none -- somehost sh -c '" "if 'nc' -q 2>&1 | grep \"requires an argument\" = >/dev/null 2>&1; then " - "ARG=3D-q0;" + "ARG=3D-q0; " "else " - "ARG=3D;" - "fi;" + "ARG=3D; " + "fi; " "'nc' $ARG -U /tmp/socket" "'\n", }; @@ -591,10 +591,10 @@ mymain(void) .path =3D "/tmp/socket", .expectOut =3D "-p 9000 -l fred -T -e none -o BatchMode=3Dyes -- s= omehost sh -c '" "if 'netcat' -q 2>&1 | grep \"requires an argumen= t\" >/dev/null 2>&1; then " - "ARG=3D-q0;" + "ARG=3D-q0; " "else " - "ARG=3D;" - "fi;" + "ARG=3D; " + "fi; " "'netcat' $ARG -U /tmp/socket" "'\n", }; @@ -611,10 +611,10 @@ mymain(void) .path =3D "/tmp/socket", .expectOut =3D "-p 9000 -l fred -T -e none -o StrictHostKeyCheckin= g=3Dno -- somehost sh -c '" "if 'netcat' -q 2>&1 | grep \"requires an argumen= t\" >/dev/null 2>&1; then " - "ARG=3D-q0;" + "ARG=3D-q0; " "else " - "ARG=3D;" - "fi;" + "ARG=3D; " + "fi; " "'netcat' $ARG -U /tmp/socket" "'\n", }; @@ -635,10 +635,10 @@ mymain(void) .netcat =3D "nc", .expectOut =3D "-T -e none -- crashyhost sh -c '" "if 'nc' -q 2>&1 | grep \"requires an argument\" = >/dev/null 2>&1; then " - "ARG=3D-q0;" + "ARG=3D-q0; " "else " - "ARG=3D;" - "fi;" + "ARG=3D; " + "fi; " "'nc' $ARG -U /tmp/socket" "'\n", .dieEarly =3D true, @@ -654,10 +654,10 @@ mymain(void) .noVerify =3D true, .expectOut =3D "-i /root/.ssh/example_key -T -e none -o StrictHost= KeyChecking=3Dno -- example.com sh -c '" "if 'nc' -q 2>&1 | grep \"requires an argument\" = >/dev/null 2>&1; then " - "ARG=3D-q0;" + "ARG=3D-q0; " "else " - "ARG=3D;" - "fi;" + "ARG=3D; " + "fi; " "'nc' $ARG -U /tmp/socket" "'\n", }; @@ -670,10 +670,10 @@ mymain(void) .path =3D "/tmp/socket", .expectOut =3D "-T -e none -- somehost sh -c '" "if '''\\''/tmp/fo o/nc'\\'''' -q 2>&1 | grep \"r= equires an argument\" >/dev/null 2>&1; then " - "ARG=3D-q0;" + "ARG=3D-q0; " "else " - "ARG=3D;" - "fi;" + "ARG=3D; " + "fi; " "'''\\''/tmp/fo o/nc'\\'''' $ARG -U /tmp/socket" "'\n", }; --=20 2.34.1 From nobody Fri Nov 1 00:38:24 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=1644601342; cv=none; d=zohomail.com; s=zohoarc; b=Bnz+8nizNMjOsbOBv3UFCnnY6mFaGjSA7K2yookanOJoJ0LdIzcV/s2bjRMyfWrMhdITI4ngi9zekdT1/b995maOH/i8JWC11vGdLVJRmyl71iNUCgBg4sA0fG5qeAf1Dar4oc/eVWEwkeWpDg0PoC47PupCPjic6Lr+WRV9V9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644601342; 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=U4/72q+54ZSSjYY0kYjhJsKZqdHKZMGm5kygXrWDESw=; b=Ef/cJsqsFPjMBHkalZcbcAqqI5vwW8sUUexPqbxRbuQPsXYGow5ARWSeUd8FIt0uC731Ns3aux4VR+1BtzEe8PJdlaRh9yLPS1+RcJgaE42IwbqG0clf6vbEoxIRyOM54LnDqM4BBAIGQDnvIC1vLZfkvMMgF20FV4O2e2CxDIc= 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 1644601342432289.77790066971056; Fri, 11 Feb 2022 09:42:22 -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-203-BTQGmCyXM_G23YiJgoM50Q-1; Fri, 11 Feb 2022 12:42:19 -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 3FB3E801B32; Fri, 11 Feb 2022 17:42:14 +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 12C502ED9C; Fri, 11 Feb 2022 17:42:14 +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 D71191809CB9; Fri, 11 Feb 2022 17:42:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21BHeI3n006737 for ; Fri, 11 Feb 2022 12:40:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 35E7C34B21; Fri, 11 Feb 2022 17:40:18 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.194.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 881732DE99 for ; Fri, 11 Feb 2022 17:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644601341; 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=U4/72q+54ZSSjYY0kYjhJsKZqdHKZMGm5kygXrWDESw=; b=M6r0HLvMJA6RugWep0Z5AuEWzgnjiBnCyUPpa8ZFmZN6Xcl0x3EzuKXKD/15gK7hDENXXQ IYQbIQ3OYCTzfbyZ+9NCmd5+EjSmjRViTKqbk2/EQ509WFG1z9rmcJqB1oWwLJn4FzklZa Jo7lDUOIuClHH+iY2ftFtYM0JbmJ5R0= X-MC-Unique: BTQGmCyXM_G23YiJgoM50Q-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 07/11] virnetclient: Use 'if' consistently Date: Fri, 11 Feb 2022 18:39:15 +0100 Message-Id: <20220211173919.112353-8-abologna@redhat.com> In-Reply-To: <20220211173919.112353-1-abologna@redhat.com> References: <20220211173919.112353-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644601344606100001 Content-Type: text/plain; charset="utf-8" This makes the generated script a bit shorter and removes an unnecessary call to test. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/rpc/virnetclient.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index cbefa8f11f..7e7e9d52a6 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -449,8 +449,7 @@ virNetClientSSHHelperCommand(virNetClientProxy proxy, =20 switch (proxy) { case VIR_NET_CLIENT_PROXY_AUTO: - return g_strdup_printf("sh -c 'which virt-ssh-helper 1>/dev/null 2= >&1; " - "if test $? =3D 0; then " + return g_strdup_printf("sh -c 'if which virt-ssh-helper >/dev/null= 2>&1; then " "%s; " "else " "%s; " --=20 2.34.1 From nobody Fri Nov 1 00:38:24 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=1644601490; cv=none; d=zohomail.com; s=zohoarc; b=bN0yNQweQCjgnxGn3mBrpkAW0xO1zZSFueQMrwzkAFYxZj3ZH0yi0BQpbu55mgsfoAr19jQH6p5dWy1KGKtupO8bZ2P9IoaEKIJ8WxIKQENIq57Mq5J6M7RouSnVeiNngyTCML3t3dGd+AacEd7XYqdL4oGioDQW2wjIqe/72Bw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644601490; 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=ymSQeEmgUU5NGxe6pT3Wmbn5IBBCMvBTc9rFt5/nTVs=; b=P29nHVveH27Gg98Oq8TUoZFVAY+EhU07cZ239r/+ZerjxVPLltvu5mtg/O1rEjzYzAH3MtuHg+U36EgR33d9WD/FdNMe9xmc83F+MlmHC81ByfU/H2yCSyL0/1jQHzEiNRAuk+p+4H+fawgeuLWcUmgIPTQJVXznKI5IYWgLD8E= 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 1644601490075665.5255301163447; Fri, 11 Feb 2022 09:44:50 -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-557-Ed90SGRTPTK_UnbFlT04tg-1; Fri, 11 Feb 2022 12:44:45 -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 BBBC684DA4A; Fri, 11 Feb 2022 17:44:40 +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 9B2F58477D; Fri, 11 Feb 2022 17:44:40 +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 6DE351806D03; Fri, 11 Feb 2022 17:44:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21BHeJmO006750 for ; Fri, 11 Feb 2022 12:40:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 73D032DE99; Fri, 11 Feb 2022 17:40:19 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.194.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F66B34D44 for ; Fri, 11 Feb 2022 17:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644601489; 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=ymSQeEmgUU5NGxe6pT3Wmbn5IBBCMvBTc9rFt5/nTVs=; b=cjfUlaNECOAgXN74ovFLGDuQN0MQzF/t3HjU1K7BYiKqjFXdgXyeMSjxNurlT66JApe8Hq qlppU1Fc/zsLAMAaZoLscAgvInIPpdYFrvtdW+FaTEgAUfINmReadL0TX2jjW8jpXBYhMB 72UNgB4Qr4YovWjvV3eNFtl1+LwRdE4= X-MC-Unique: Ed90SGRTPTK_UnbFlT04tg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 08/11] virnetsockettest: Tweak input for test 7 Date: Fri, 11 Feb 2022 18:39:16 +0100 Message-Id: <20220211173919.112353-9-abologna@redhat.com> In-Reply-To: <20220211173919.112353-1-abologna@redhat.com> References: <20220211173919.112353-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644601491670100003 Content-Type: text/plain; charset="utf-8" The important part of the value we assign to "netcat" is that it contains whitespace, so drop everything else to highlight this fact. Change the path to the socket so that it also contains whitespace: this will not actually work outside of the test suite at the moment, but we're going to fix that in an upcoming commit. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- tests/virnetsockettest.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index c1d3e39856..557d781605 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -666,15 +666,15 @@ mymain(void) =20 struct testSSHData sshData7 =3D { .nodename =3D "somehost", - .netcat =3D "/tmp/fo o/nc", - .path =3D "/tmp/socket", + .netcat =3D "n c", + .path =3D "/tmp/sock et", .expectOut =3D "-T -e none -- somehost sh -c '" - "if '''\\''/tmp/fo o/nc'\\'''' -q 2>&1 | grep \"r= equires an argument\" >/dev/null 2>&1; then " + "if '''\\''n c'\\'''' -q 2>&1 | grep \"requires a= n argument\" >/dev/null 2>&1; then " "ARG=3D-q0; " "else " "ARG=3D; " "fi; " - "'''\\''/tmp/fo o/nc'\\'''' $ARG -U /tmp/socket" + "'''\\''n c'\\'''' $ARG -U /tmp/sock et" "'\n", }; VIR_WARNINGS_RESET --=20 2.34.1 From nobody Fri Nov 1 00:38:24 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=1644601723; cv=none; d=zohomail.com; s=zohoarc; b=nXEWh9PRYHJTK2KubsQS5IYmv+YShpC30J9fGvGSYPXw9/CDwWDpOOWkvZA/MxadruxGLm/n/3Eufe1U2SxbmJ/tSb3MZSjwi6ig8UAHrGu17T1qonPAYbWytE48qG8h9K4kVJ6rDUF6soPKFDlkRxvTSjvlJfpRpKmlM3Tw088= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644601723; 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=oAdnsDK4cSk5I5g24nIXu6/yzdip02IlTXGVVBiFV3U=; b=DyEZn7vhCJmDVbCn1cxCk+/QFfzgyw1+J2iE3GMtz7IhVZ+LLOPmDEHKq+wOm8mePaQA6aLbqPtKnaGB8Af5pleEWlj7JrURvc9IEnaklCAE+frXBVf2Uwo1MPDM63caxR35yRFP/GZPSx+0wd5J/itUum0JPr62IHI0SbMGhfU= 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 1644601723019299.1726881303779; Fri, 11 Feb 2022 09:48:43 -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-360-o94_3eJuN22AM3alRjcSGA-1; Fri, 11 Feb 2022 12:48:40 -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 B895B19253E9; Fri, 11 Feb 2022 17:48:35 +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 96F452DE99; Fri, 11 Feb 2022 17:48:35 +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 676C61806D1C; Fri, 11 Feb 2022 17:48:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21BHeK6k006760 for ; Fri, 11 Feb 2022 12:40:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6C3192DE99; Fri, 11 Feb 2022 17:40:20 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.194.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C63FF34B21 for ; Fri, 11 Feb 2022 17:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644601721; 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=oAdnsDK4cSk5I5g24nIXu6/yzdip02IlTXGVVBiFV3U=; b=B718EiS/E5F1QcnJ/EiFPN6sSFRq+itZKr5FZqKnWd0rHEQvJKIOTPnkrV/oMcRvJBP9lF 7gmT5Kd1QKfDuz92l1Mb0erQA17dwsGFeCN+4ztksC/cpGfs/Cwo0/i9Yacj8Oy739x1sC XFHnugHihFyH6x1FBk7ouKEl8sL/N38= X-MC-Unique: o94_3eJuN22AM3alRjcSGA-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 09/11] virnetsockettest: Allow changing the proxy parameter Date: Fri, 11 Feb 2022 18:39:17 +0100 Message-Id: <20220211173919.112353-10-abologna@redhat.com> In-Reply-To: <20220211173919.112353-1-abologna@redhat.com> References: <20220211173919.112353-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644601725319100001 Content-Type: text/plain; charset="utf-8" Currently the test cases all follow the proxy=3Dauto behavior, but we want to add coverage for other proxy modes as well. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- tests/virnetsockettest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 557d781605..36f6993ba5 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -441,6 +441,7 @@ struct testSSHData { const char *username; bool noTTY; bool noVerify; + virNetClientProxy proxy; const char *netcat; const char *keyfile; const char *path; @@ -456,7 +457,7 @@ static int testSocketSSH(const void *opaque) virNetSocket *csock =3D NULL; /* Client socket */ int ret =3D -1; char buf[1024]; - g_autofree char *command =3D virNetClientSSHHelperCommand(VIR_NET_CLIE= NT_PROXY_AUTO, + g_autofree char *command =3D virNetClientSSHHelperCommand(data->proxy, data->netcat, data->path, "qemu:///sessi= on", --=20 2.34.1 From nobody Fri Nov 1 00:38:24 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=1644601346; cv=none; d=zohomail.com; s=zohoarc; b=ICcQO89QD/V1bAT7fnIUYTCDX9DxHDDRNtQpjabySDTkrnDlYyAi2HAoEhF/W7iv1Vy9NQFCpxs7GiHP1XQIAE28r4otVNxPw8mIsn3VSDAiZlq8jIVZB08UnyIReZveqW0K6dURK4PS//WbOAt+N2PPVrAV2uQ6yTft4KOwuPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644601346; 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=57rGs2X52v1ppTdV8/ct6YyfOIyhEYVEBy1FUUuya78=; b=KtWFjAl36xz9h5y153IdU5arp2n/O8hnkvccguCM3WAWf37ZueP2TxLxdaZ0jiKA4WW5zpOWLHPBp2DNauWbXxwrwtQB3t2wlxWtpvUEPd8Nx5MduZrKCDhN9Xmp4ymB20kBeSdsSr+jVbUgxsTkO0SveGgLJtDKwXp/qhYD2AE= 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 1644601346882648.0774596538466; Fri, 11 Feb 2022 09:42:26 -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-416-P4-0ejZtPwizM0TLU4HJiA-1; Fri, 11 Feb 2022 12:42:22 -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 9357B1006ABA; Fri, 11 Feb 2022 17:42:17 +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 414E9753D3; Fri, 11 Feb 2022 17:42:17 +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 04FCD1809CBF; Fri, 11 Feb 2022 17:42:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21BHeLWu006768 for ; Fri, 11 Feb 2022 12:40:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 720A12DE99; Fri, 11 Feb 2022 17:40:21 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.194.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D400234D41 for ; Fri, 11 Feb 2022 17:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644601345; 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=57rGs2X52v1ppTdV8/ct6YyfOIyhEYVEBy1FUUuya78=; b=Xq2N5R6qmt2FNvy/gkOddx03zgkEJz1jLfCs3QNnC1prqP39cDhDe1WaNxJy4FCFnk/kKS iTZQFyS9jWjoUyZ/40J9xMd2cIKEBbnMoY8MGJCvajU5Hyjw+rf8sbkSq9raNih6L8LFK9 eYj0anZCEISEWonlz7BkwKHOJPZawN4= X-MC-Unique: P4-0ejZtPwizM0TLU4HJiA-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 10/11] virnetsockettest: Increase coverage Date: Fri, 11 Feb 2022 18:39:18 +0100 Message-Id: <20220211173919.112353-11-abologna@redhat.com> In-Reply-To: <20220211173919.112353-1-abologna@redhat.com> References: <20220211173919.112353-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644601348657100001 Content-Type: text/plain; charset="utf-8" Add test cases for quotes appearing in the netcat and socket parameters, for the default behavior of proxy=3Dauto where virt-ssh-helper is used if available, and for proxy=3Dnative. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- tests/virnetsockettest.c | 62 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 36f6993ba5..b0e26bc2b2 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -678,10 +678,70 @@ mymain(void) "'''\\''n c'\\'''' $ARG -U /tmp/sock et" "'\n", }; - VIR_WARNINGS_RESET if (virTestRun("SSH test 7", testSocketSSH, &sshData7) < 0) ret =3D -1; =20 + struct testSSHData sshData8 =3D { + .nodename =3D "somehost", + .netcat =3D "n'c", + .path =3D "/tmp/sock'et", + .expectOut =3D "-T -e none -- somehost sh -c '" + "if '''\\''n'\\''\\'\\'''\\''c'\\'''' -q 2>&1 | g= rep \"requires an argument\" >/dev/null 2>&1; then " + "ARG=3D-q0; " + "else " + "ARG=3D; " + "fi; " + "'''\\''n'\\''\\'\\'''\\''c'\\'''' $ARG -U /tmp/s= ock'et" + "'\n", + }; + if (virTestRun("SSH test 8", testSocketSSH, &sshData8) < 0) + ret =3D -1; + + struct testSSHData sshData9 =3D { + .nodename =3D "somehost", + .netcat =3D "n\"c", + .path =3D "/tmp/sock\"et", + .expectOut =3D "-T -e none -- somehost sh -c '" + "if '''\\''n\"c'\\'''' -q 2>&1 | grep \"requires = an argument\" >/dev/null 2>&1; then " + "ARG=3D-q0; " + "else " + "ARG=3D; " + "fi; " + "'''\\''n\"c'\\'''' $ARG -U /tmp/sock\"et" + "'\n", + }; + if (virTestRun("SSH test 9", testSocketSSH, &sshData9) < 0) + ret =3D -1; + + struct testSSHData sshData10 =3D { + .nodename =3D "somehost", + .path =3D "/tmp/socket", + .expectOut =3D "-T -e none -- somehost sh -c '" + "if which virt-ssh-helper >/dev/null 2>&1; then " + "virt-ssh-helper -r 'qemu:///session'; " + "else " + "if 'nc' -q 2>&1 | grep \"requires an argumen= t\" >/dev/null 2>&1; then " + "ARG=3D-q0; " + "else " + "ARG=3D; " + "fi; " + "'nc' $ARG -U /tmp/socket; " + "fi" + "'\n" + }; + if (virTestRun("SSH test 10", testSocketSSH, &sshData10) < 0) + ret =3D -1; + + struct testSSHData sshData11 =3D { + .nodename =3D "somehost", + .proxy =3D VIR_NET_CLIENT_PROXY_NATIVE, + .expectOut =3D "-T -e none -- somehost sh -c '" + "virt-ssh-helper -r 'qemu:///session'" + "'\n" + }; + if (virTestRun("SSH test 11", testSocketSSH, &sshData11) < 0) + ret =3D -1; + VIR_WARNINGS_RESET #endif =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; --=20 2.34.1 From nobody Fri Nov 1 00:38:24 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=1644601349; cv=none; d=zohomail.com; s=zohoarc; b=kLm203TA7BhZkxdyhK78OACp7TBBi492KWUbwMWp4m+9INSt/b9eE5t+xxIh9bJGypSazDcF29kHNs6LF7lJ8WTgZWEeGxyRPaq6pTft6nE2EAN66Hh18Ct6xH5baHrGgl7sBbWDmkTpbNGRIM3vPpF96mQhGr6eAJssCtjY/XU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644601349; 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=hJuSiyyHZxANYRsNKWBa2ibu2FOjp3ybIAPy55K0kzI=; b=jPtTZo6hcLWHH31uLTLQehLSc8ll+J777fccpOQ2bqECcFzmMSjy7vC4DpgZZC3CO0vE+N2IwAgUdf3NjX5jGBTSl15RNbycuoHJcqeq1Cr0XoBztQrPZpxY1YICG0MbLOlbW367tS3kOFN+M/QPRIYr7j7HvPcFR2aslqK1CpE= 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 1644601349316320.7724380701484; Fri, 11 Feb 2022 09:42:29 -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-438-nS0tTGy8N_O8DP31FMgNvA-1; Fri, 11 Feb 2022 12:42:24 -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 EF3C11006AAF; Fri, 11 Feb 2022 17:42:19 +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 CC6D7348F2; Fri, 11 Feb 2022 17:42:19 +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 9DD904CA9B; Fri, 11 Feb 2022 17:42:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21BHeMV9006774 for ; Fri, 11 Feb 2022 12:40:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7E9F334B21; Fri, 11 Feb 2022 17:40:22 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.194.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DF5C32DE99 for ; Fri, 11 Feb 2022 17:40:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644601348; 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=hJuSiyyHZxANYRsNKWBa2ibu2FOjp3ybIAPy55K0kzI=; b=Flxr8v/3PHm5ZqkXNW3HQSUEVlXjzKbHFPhO+tlpqkNWwK29g3mh45ZVadHaqBYpfBKTgf sSJQ39+eC6YkX96hhHFLLpcjMQ23E8fOVLaSc1/LosRIRpiulNgssT6IVSG4LOMjmhNh/9 5ZrC1Vkxfu2OrsXkBgfBkCy32x9fTzM= X-MC-Unique: nS0tTGy8N_O8DP31FMgNvA-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 11/11] virnetclient: Escape socket path Date: Fri, 11 Feb 2022 18:39:19 +0100 Message-Id: <20220211173919.112353-12-abologna@redhat.com> In-Reply-To: <20220211173919.112353-1-abologna@redhat.com> References: <20220211173919.112353-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644601350689100003 Content-Type: text/plain; charset="utf-8" Just like the name of the netcat command and the connection URI, the socket path is a user-provided piece of information that might contain characters that have special meaning for the shell, and as such should be escaped. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/rpc/virnetclient.c | 5 +++-- tests/virnetsockettest.c | 18 +++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 7e7e9d52a6..563cffff85 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -422,6 +422,7 @@ virNetClientSSHHelperCommand(virNetClientProxy proxy, { g_autofree char *netcatPathSafe =3D virNetClientDoubleEscapeShell(netc= atPath ? netcatPath : "nc"); g_autofree char *driverURISafe =3D virNetClientDoubleEscapeShell(drive= rURI); + g_autofree char *socketPathSafe =3D virNetClientDoubleEscapeShell(sock= etPath); g_autofree char *nccmd =3D NULL; g_autofree char *helpercmd =3D NULL; =20 @@ -440,8 +441,8 @@ virNetClientSSHHelperCommand(virNetClientProxy proxy, "else " "ARG=3D; " "fi; " - "'%s' $ARG -U %s", - netcatPathSafe, netcatPathSafe, socketPath); + "'%s' $ARG -U '%s'", + netcatPathSafe, netcatPathSafe, socketPathSafe); =20 helpercmd =3D g_strdup_printf("virt-ssh-helper%s'%s'", readonly ? " -r " : " ", diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index b0e26bc2b2..d79027d637 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -576,7 +576,7 @@ mymain(void) "else " "ARG=3D; " "fi; " - "'nc' $ARG -U /tmp/socket" + "'nc' $ARG -U '/tmp/socket'" "'\n", }; if (virTestRun("SSH test 1", testSocketSSH, &sshData1) < 0) @@ -596,7 +596,7 @@ mymain(void) "else " "ARG=3D; " "fi; " - "'netcat' $ARG -U /tmp/socket" + "'netcat' $ARG -U '/tmp/socket'" "'\n", }; if (virTestRun("SSH test 2", testSocketSSH, &sshData2) < 0) @@ -616,7 +616,7 @@ mymain(void) "else " "ARG=3D; " "fi; " - "'netcat' $ARG -U /tmp/socket" + "'netcat' $ARG -U '/tmp/socket'" "'\n", }; if (virTestRun("SSH test 3", testSocketSSH, &sshData3) < 0) @@ -640,7 +640,7 @@ mymain(void) "else " "ARG=3D; " "fi; " - "'nc' $ARG -U /tmp/socket" + "'nc' $ARG -U '/tmp/socket'" "'\n", .dieEarly =3D true, }; @@ -659,7 +659,7 @@ mymain(void) "else " "ARG=3D; " "fi; " - "'nc' $ARG -U /tmp/socket" + "'nc' $ARG -U '/tmp/socket'" "'\n", }; if (virTestRun("SSH test 6", testSocketSSH, &sshData6) < 0) @@ -675,7 +675,7 @@ mymain(void) "else " "ARG=3D; " "fi; " - "'''\\''n c'\\'''' $ARG -U /tmp/sock et" + "'''\\''n c'\\'''' $ARG -U '''\\''/tmp/sock et'\\= ''''" "'\n", }; if (virTestRun("SSH test 7", testSocketSSH, &sshData7) < 0) @@ -691,7 +691,7 @@ mymain(void) "else " "ARG=3D; " "fi; " - "'''\\''n'\\''\\'\\'''\\''c'\\'''' $ARG -U /tmp/s= ock'et" + "'''\\''n'\\''\\'\\'''\\''c'\\'''' $ARG -U '''\\'= '/tmp/sock'\\''\\'\\'''\\''et'\\''''" "'\n", }; if (virTestRun("SSH test 8", testSocketSSH, &sshData8) < 0) @@ -707,7 +707,7 @@ mymain(void) "else " "ARG=3D; " "fi; " - "'''\\''n\"c'\\'''' $ARG -U /tmp/sock\"et" + "'''\\''n\"c'\\'''' $ARG -U '''\\''/tmp/sock\"et'= \\''''" "'\n", }; if (virTestRun("SSH test 9", testSocketSSH, &sshData9) < 0) @@ -725,7 +725,7 @@ mymain(void) "else " "ARG=3D; " "fi; " - "'nc' $ARG -U /tmp/socket; " + "'nc' $ARG -U '/tmp/socket'; " "fi" "'\n" }; --=20 2.34.1