qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] extend monitor "change vnc password"


From: Nolan
Subject: [Qemu-devel] [PATCH] extend monitor "change vnc password"
Date: Thu, 23 Oct 2008 15:45:19 -0700

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 via email to

[Prev in Thread] Current Thread [Next in Thread]