From nobody Fri May 3 22:35:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630510699144867.7513015840775; Wed, 1 Sep 2021 08:38:19 -0700 (PDT) Received: from localhost ([::1]:43914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLSJe-000584-5f for importer@patchew.org; Wed, 01 Sep 2021 11:38:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLS0i-0007dd-KX for qemu-devel@nongnu.org; Wed, 01 Sep 2021 11:18:45 -0400 Received: from proxmox-new.maurer-it.com ([94.136.29.106]:18542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLS0e-0004j7-NV for qemu-devel@nongnu.org; Wed, 01 Sep 2021 11:18:44 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9AAE24449E; Wed, 1 Sep 2021 17:18:29 +0200 (CEST) From: Stefan Reiter To: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini , Eric Blake , Gerd Hoffmann , Wolfgang Bumiller , Thomas Lamprecht Subject: [PATCH v2 1/3] monitor/hmp: correctly invert password argument detection again Date: Wed, 1 Sep 2021 17:17:46 +0200 Message-Id: <20210901151748.1712048-2-s.reiter@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210901151748.1712048-1-s.reiter@proxmox.com> References: <20210901151748.1712048-1-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=94.136.29.106; envelope-from=s.reiter@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1630510700790100001 Commit cfb5387a1d 'hmp: remove "change vnc TARGET" command' claims to remove the HMP "change vnc" command, but doesn't actually do that. Instead it rewires it to use 'qmp_change_vnc_password', and in the process inverts the argument detection - ignoring the first issue, this inversion is wrong, as this will now ask the user for a password if one is already provided, and simply fail if none is given. Fixes: cfb5387a1d ("hmp: remove "change vnc TARGET" command") Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Stefan Reiter --- monitor/hmp-cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index e00255f7ee..a7e197a90b 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1496,7 +1496,7 @@ void hmp_change(Monitor *mon, const QDict *qdict) } if (strcmp(target, "passwd") =3D=3D 0 || strcmp(target, "password") =3D=3D 0) { - if (arg) { + if (!arg) { MonitorHMP *hmp_mon =3D container_of(mon, MonitorHMP, comm= on); monitor_read_password(hmp_mon, hmp_change_read_arg, NULL); return; --=20 2.30.2 From nobody Fri May 3 22:35:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630512461567168.29878453523986; Wed, 1 Sep 2021 09:07:41 -0700 (PDT) Received: from localhost ([::1]:32850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLSm4-0005Xu-9F for importer@patchew.org; Wed, 01 Sep 2021 12:07:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLS0i-0007dR-FL for qemu-devel@nongnu.org; Wed, 01 Sep 2021 11:18:45 -0400 Received: from proxmox-new.maurer-it.com ([94.136.29.106]:57124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLS0e-0004j9-NS for qemu-devel@nongnu.org; Wed, 01 Sep 2021 11:18:43 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B9EDB444AC; Wed, 1 Sep 2021 17:18:29 +0200 (CEST) From: Stefan Reiter To: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini , Eric Blake , Gerd Hoffmann , Wolfgang Bumiller , Thomas Lamprecht Subject: [PATCH v2 2/3] monitor/hmp: add support for flag argument with value Date: Wed, 1 Sep 2021 17:17:47 +0200 Message-Id: <20210901151748.1712048-3-s.reiter@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210901151748.1712048-1-s.reiter@proxmox.com> References: <20210901151748.1712048-1-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=94.136.29.106; envelope-from=s.reiter@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1630512462340100001 Content-Type: text/plain; charset="utf-8" Adds support for the "-xS" parameter type, where "-x" denotes a flag name and the "S" suffix indicates that this flag is supposed to take an arbitrary string parameter. These parameters are always optional, the entry in the qdict will be omitted if the flag is not given. Signed-off-by: Stefan Reiter --- monitor/hmp.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/monitor/hmp.c b/monitor/hmp.c index d50c3124e1..a32dce7a35 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -980,6 +980,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, { const char *tmp =3D p; int skip_key =3D 0; + int ret; /* option */ =20 c =3D *typestr++; @@ -1002,8 +1003,22 @@ static QDict *monitor_parse_arguments(Monitor *mon, } if (skip_key) { p =3D tmp; + } else if (*typestr =3D=3D 'S') { + /* has option with string value */ + typestr++; + tmp =3D p++; + while (qemu_isspace(*p)) { + p++; + } + ret =3D get_str(buf, sizeof(buf), &p); + if (ret < 0) { + monitor_printf(mon, "%s: value expected for -%= c\n", + cmd->name, *tmp); + goto fail; + } + qdict_put_str(qdict, key, buf); } else { - /* has option */ + /* has boolean option */ p++; qdict_put_bool(qdict, key, true); } --=20 2.30.2 From nobody Fri May 3 22:35:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630510878375317.16252097038284; Wed, 1 Sep 2021 08:41:18 -0700 (PDT) Received: from localhost ([::1]:52044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLSMX-0002Og-5U for importer@patchew.org; Wed, 01 Sep 2021 11:41:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLS0k-0007f7-Rk for qemu-devel@nongnu.org; Wed, 01 Sep 2021 11:18:47 -0400 Received: from proxmox-new.maurer-it.com ([94.136.29.106]:11149) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLS0e-0004jA-Qe for qemu-devel@nongnu.org; Wed, 01 Sep 2021 11:18:46 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 716D2444B3; Wed, 1 Sep 2021 17:18:30 +0200 (CEST) From: Stefan Reiter To: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini , Eric Blake , Gerd Hoffmann , Wolfgang Bumiller , Thomas Lamprecht Subject: [PATCH v2 3/3] monitor: allow VNC related QMP and HMP commands to take a display ID Date: Wed, 1 Sep 2021 17:17:48 +0200 Message-Id: <20210901151748.1712048-4-s.reiter@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210901151748.1712048-1-s.reiter@proxmox.com> References: <20210901151748.1712048-1-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=94.136.29.106; envelope-from=s.reiter@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1630510879675100001 It is possible to specify more than one VNC server on the command line, either with an explicit ID or the auto-generated ones =C3=A0 la "default", "vnc2", "vnc3", ... It is not possible to change the password on one of these extra VNC displays though. Fix this by adding a "display" parameter to the "set_password" and "expire_password" QMP and HMP commands. For HMP, the display is specified using the "-d" value flag. Signed-off-by: Stefan Reiter --- hmp-commands.hx | 29 +++++++++++++++-------------- monitor/hmp-cmds.c | 7 +++++-- monitor/qmp-cmds.c | 9 +++++---- qapi/ui.json | 12 ++++++++++-- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 8e45bce2cd..d78e4cfc47 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1514,34 +1514,35 @@ ERST =20 { .name =3D "set_password", - .args_type =3D "protocol:s,password:s,connected:s?", - .params =3D "protocol password action-if-connected", + .args_type =3D "protocol:s,password:s,display:-dS,connected:s?", + .params =3D "protocol password [-d display] [action-if-connect= ed]", .help =3D "set spice/vnc password", .cmd =3D hmp_set_password, }, =20 SRST -``set_password [ vnc | spice ] password [ action-if-connected ]`` - Change spice/vnc password. Use zero to make the password stay valid - forever. *action-if-connected* specifies what should happen in - case a connection is established: *fail* makes the password change - fail. *disconnect* changes the password and disconnects the - client. *keep* changes the password and keeps the connection up. - *keep* is the default. +``set_password [ vnc | spice ] password [ -d display ] [ action-if-connect= ed ]`` + Change spice/vnc password. *display* can be used with 'vnc' to specify + which display to set the password on. *action-if-connected* specifies + what should happen in case a connection is established: *fail* makes + the password change fail. *disconnect* changes the password and + disconnects the client. *keep* changes the password and keeps the + connection up. *keep* is the default. ERST =20 { .name =3D "expire_password", - .args_type =3D "protocol:s,time:s", - .params =3D "protocol time", + .args_type =3D "protocol:s,time:s,display:-dS", + .params =3D "protocol time [-d display]", .help =3D "set spice/vnc password expire-time", .cmd =3D hmp_expire_password, }, =20 SRST -``expire_password [ vnc | spice ]`` *expire-time* - Specify when a password for spice/vnc becomes - invalid. *expire-time* accepts: +``expire_password [ vnc | spice ] expire-time [ -d display ]`` + Specify when a password for spice/vnc becomes invalid. + *display* behaves the same as in ``set_password``. + *expire-time* accepts: =20 ``now`` Invalidate password instantly. diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index a7e197a90b..168ca62371 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1451,10 +1451,12 @@ void hmp_set_password(Monitor *mon, const QDict *qd= ict) { const char *protocol =3D qdict_get_str(qdict, "protocol"); const char *password =3D qdict_get_str(qdict, "password"); + const char *display =3D qdict_get_try_str(qdict, "display"); const char *connected =3D qdict_get_try_str(qdict, "connected"); Error *err =3D NULL; =20 - qmp_set_password(protocol, password, !!connected, connected, &err); + qmp_set_password(protocol, password, !!connected, connected, !!display, + display, &err); hmp_handle_error(mon, err); } =20 @@ -1462,9 +1464,10 @@ void hmp_expire_password(Monitor *mon, const QDict *= qdict) { const char *protocol =3D qdict_get_str(qdict, "protocol"); const char *whenstr =3D qdict_get_str(qdict, "time"); + const char *display =3D qdict_get_try_str(qdict, "display"); Error *err =3D NULL; =20 - qmp_expire_password(protocol, whenstr, &err); + qmp_expire_password(protocol, whenstr, !!display, display, &err); hmp_handle_error(mon, err); } =20 diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 5c0d5e116b..b53869d10c 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -164,7 +164,8 @@ void qmp_system_wakeup(Error **errp) } =20 void qmp_set_password(const char *protocol, const char *password, - bool has_connected, const char *connected, Error **e= rrp) + bool has_connected, const char *connected, + bool has_display, const char *display, Error **errp) { int disconnect_if_connected =3D 0; int fail_if_connected =3D 0; @@ -197,7 +198,7 @@ void qmp_set_password(const char *protocol, const char = *password, } /* Note that setting an empty password will not disable login thro= ugh * this interface. */ - rc =3D vnc_display_password(NULL, password); + rc =3D vnc_display_password(has_display ? display : NULL, password= ); } else { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol", "'vnc' or 'spice'"); @@ -210,7 +211,7 @@ void qmp_set_password(const char *protocol, const char = *password, } =20 void qmp_expire_password(const char *protocol, const char *whenstr, - Error **errp) + bool has_display, const char *display, Error **er= rp) { time_t when; int rc; @@ -231,7 +232,7 @@ void qmp_expire_password(const char *protocol, const ch= ar *whenstr, } rc =3D qemu_spice.set_pw_expire(when); } else if (strcmp(protocol, "vnc") =3D=3D 0) { - rc =3D vnc_display_pw_expire(NULL, when); + rc =3D vnc_display_pw_expire(has_display ? display : NULL, when); } else { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol", "'vnc' or 'spice'"); diff --git a/qapi/ui.json b/qapi/ui.json index b2cf7a6759..fa84df9a70 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -25,6 +25,9 @@ # 'disconnect' to disconnect existing clients # 'keep' to maintain existing clients # +# @display: In case of VNC, the id of the display where the password +# should be changed. Defaults to the first. +# # Returns: - Nothing on success # - If Spice is not enabled, DeviceNotFound # @@ -38,7 +41,8 @@ # ## { 'command': 'set_password', - 'data': {'protocol': 'str', 'password': 'str', '*connected': 'str'} } + 'data': {'protocol': 'str', 'password': 'str', '*connected': 'str', + '*display': 'str'} } =20 ## # @expire_password: @@ -54,6 +58,9 @@ # - '+INT' where INT is the number of seconds from now (integer) # - 'INT' where INT is the absolute time in seconds # +# @display: In case of VNC, the id of the display where the password +# should be set to expire. Defaults to the first. +# # Returns: - Nothing on success # - If @protocol is 'spice' and Spice is not active, DeviceNotFou= nd # @@ -71,7 +78,8 @@ # <- { "return": {} } # ## -{ 'command': 'expire_password', 'data': {'protocol': 'str', 'time': 'str'}= } +{ 'command': 'expire_password', + 'data': {'protocol': 'str', 'time': 'str', '*display': 'str'} } =20 ## # @screendump: --=20 2.30.2