qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Nolan <nolan@sigbus.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] extend monitor "change vnc password"
Date: Thu, 23 Oct 2008 15:45:19 -0700	[thread overview]
Message-ID: <1224801919.7729.30.camel@voxel> (raw)

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 "<unset>" 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, "<unset>") != 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);

                 reply	other threads:[~2008-10-23 22:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1224801919.7729.30.camel@voxel \
    --to=nolan@sigbus.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).