From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kt8vx-0001PJ-RC for qemu-devel@nongnu.org; Thu, 23 Oct 2008 18:45:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kt8vw-0001M9-7F for qemu-devel@nongnu.org; Thu, 23 Oct 2008 18:45:37 -0400 Received: from [199.232.76.173] (port=59534 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kt8vw-0001Lz-3g for qemu-devel@nongnu.org; Thu, 23 Oct 2008 18:45:36 -0400 Received: from phong.sigbus.net ([65.49.35.42]:39362) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kt8vv-0007Js-Ji for qemu-devel@nongnu.org; Thu, 23 Oct 2008 18:45:36 -0400 Received: from [192.168.0.3] (c-67-188-86-149.hsd1.ca.comcast.net [67.188.86.149]) by phong.sigbus.net (Postfix) with ESMTP id DC49595C06F for ; Thu, 23 Oct 2008 15:45:19 -0700 (PDT) From: Nolan Content-Type: text/plain Date: Thu, 23 Oct 2008 15:45:19 -0700 Message-Id: <1224801919.7729.30.camel@voxel> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] extend monitor "change vnc password" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This patch extends the monitor command "change vnc password" to accept an optional extra argument that is the new password: (qemu) change vnc password new_pass the magic string "" will unset the password, disabling VNC. If the extra argument is not given, the behavior is to prompt for a password, as before. This change makes it easier to remotely change the VNC password using scripts like Anthony's "qemu-remote". --- monitor.c.orig 2008-10-22 17:32:05.000000000 -0700 +++ monitor.c 2008-10-22 17:56:40.000000000 -0700 @@ -447,35 +447,41 @@ } } if (eject_device(bs, 0) < 0) return; bdrv_open2(bs, filename, 0, drv); qemu_key_check(bs, filename); } -static void do_change_vnc(const char *target) +static void do_change_vnc(const char *target, const char *fmt) { if (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0) { - char password[9]; - monitor_readline("Password: ", 1, password, sizeof(password)-1); + char password[9] = {0, }; + if (fmt) { + if (strcmp(fmt, "") != 0) { + strncpy(password, fmt, sizeof(password)-1); + } + } else { + monitor_readline("Password: ", 1, password, sizeof(password)-1); + } password[sizeof(password)-1] = '\0'; if (vnc_display_password(NULL, password) < 0) term_printf("could not set VNC server password\n"); } else { if (vnc_display_open(NULL, target) < 0) term_printf("could not start VNC server on %s\n", target); } } static void do_change(const char *device, const char *target, const char *fmt) { if (strcmp(device, "vnc") == 0) { - do_change_vnc(target); + do_change_vnc(target, fmt); } else { do_change_block(device, target, fmt); } } static void do_screen_dump(const char *filename) { vga_hw_screen_dump(filename);