From nobody Sat Nov 23 15:49:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1723121828738134.28923730913493; Thu, 8 Aug 2024 05:57:08 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B08551345; Thu, 8 Aug 2024 08:57:07 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4A31212D7; Thu, 8 Aug 2024 08:56:31 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id ACD47AEB; Thu, 8 Aug 2024 08:56:26 -0400 (EDT) Received: from mx2.osci.io (francine.osci.io [8.43.85.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 19022AEB for ; Thu, 8 Aug 2024 08:56:26 -0400 (EDT) Received: by mx2.osci.io (Postfix, from userid 995) id 7EA533FDE8; Thu, 8 Aug 2024 08:49:38 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mx2.osci.io (Postfix) with ESMTPS id 1EC8F3FDE6 for ; Thu, 8 Aug 2024 08:49:34 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517-cl74RhpBOIO25joMf7nQwA-1; Thu, 08 Aug 2024 08:49:17 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3861D196E09E for ; Thu, 8 Aug 2024 12:49:16 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 662433000197 for ; Thu, 8 Aug 2024 12:49:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-Greylist: delayed 7643 seconds by postgrey-1.37 at francine.osci.io; Thu, 08 Aug 2024 08:49:34 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723121358; h=from:from: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; bh=W5ch9NCLizr8d7dlTljns0M4sBJ9sbPRabZ1kZFaTVM=; b=NeSubt0mMeLdYWlt7Xb+DdcH16l9gxIwae0a8uJGlKxVFpOasAZOP86jWWsNUhuFI3IgG1 wDiWcTnxBxc9rdOxDGRHbDdgVgaz9G6QGhk/z3kgn6xR54B0WjvETDmXVSAwQ2MoXv82N6 fWQFZ7CtIGgKjIRGaUJWBXXiIXS6V0U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723121373; h=from:from: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; bh=W5ch9NCLizr8d7dlTljns0M4sBJ9sbPRabZ1kZFaTVM=; b=PB38rJQeLObtapPul3lpvxVA0tvlZi+W8rwez+VKn+5WMivfmJBS3Rghvlb8O2slts8Qfk tsLSlD83kzeq32WlxsOCXGg2lkZ++4URGVTuSAcQlZV+Qr8cMOZJldHt9o27ThXBXopRCN yOz4bQIsKCN4K8DlXEscQwGhgMBhW+g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723121373; h=from:from: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; bh=W5ch9NCLizr8d7dlTljns0M4sBJ9sbPRabZ1kZFaTVM=; b=PB38rJQeLObtapPul3lpvxVA0tvlZi+W8rwez+VKn+5WMivfmJBS3Rghvlb8O2slts8Qfk tsLSlD83kzeq32WlxsOCXGg2lkZ++4URGVTuSAcQlZV+Qr8cMOZJldHt9o27ThXBXopRCN yOz4bQIsKCN4K8DlXEscQwGhgMBhW+g= X-MC-Unique: cl74RhpBOIO25joMf7nQwA-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH] vsh: Allow vshReadlineInit() to be called multiple times Date: Thu, 8 Aug 2024 14:49:12 +0200 Message-ID: <9b0775cc607a723228cd433a7be403b9eae78f2c.1723121352.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: D2FXV5ZVRANXPBXJ3M5AVNRFK62JU6N3 X-Message-ID-Hash: D2FXV5ZVRANXPBXJ3M5AVNRFK62JU6N3 X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZM-MESSAGEID: 1723121829286116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Thing about vshReadlineInit() is - it's called multiple times. The first time from vshInit(), when @ctl was filled only partially (most notably, before any argv parsing is done, hence ctl->imode is set to false). The second time after argv parsing, from virshInit() -> vshInitReload(). In here, ctl->imode might have changed and thus vshReadlineInit() can't exit early - it needs to set up stuff for interactive mode (history basically). To allow vshReadlineInit() to be called again, vshReadlineDeinit() must set @autoCompleteOpaque to NULL. Fixes: cab1e71f0161fd24c5d6ff4c379d3a242ea8c2d9 Resolves: https://issues.redhat.com/browse/RHEL-53560 Signed-off-by: Michal Privoznik Reviewed-by: Jiri Denemark --- tools/vsh.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/vsh.c b/tools/vsh.c index 9fbb1f9349..5f5e2f281d 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -3040,6 +3040,9 @@ vshReadlineDeinit(vshControl *ctl) =20 g_clear_pointer(&ctl->historydir, g_free); g_clear_pointer(&ctl->historyfile, g_free); + + /* Allow vshReadlineInit() to be called again. */ + autoCompleteOpaque =3D NULL; } =20 char * --=20 2.44.2