Skip to contentSkip to conversation

support for unsetting the VNC password from the monitor.

PATCH In review Nolan 3 participants 6 messages Mar 5, 2009 – Mar 9, 2009

lore
Share & tools
lore

Nolan

author
#0 lore raw

PATCH 1/1 support for unsetting the VNC password from the monitor.

Add monitor support for setting the VNC password to "", disabling VNC.

The magic sentinel value is "<<unset>>" which is not a valid VNC password by virtue of being 9 characters long.

qemu/monitor.c +7 -2
index 1b2adc8..7bbb457 100644
@@ -466,8 +466,13 @@ static void do_change_vnc(const char *target, const char *arg)
 	strcmp(target, "password") == 0) {
 	char password[9];
 	if (arg) {
-	    strncpy(password, arg, sizeof(password));
-	    password[sizeof(password) - 1] = '\0';
+            /* "<<unset>>" is 9 chars long, so it is not a valid VNC passwd. */
+            if (strcmp(arg, "<<unset>>") == 0) {
+                password[0] = '\0';
+            } else {
+                strncpy(password, arg, sizeof(password));
+                password[sizeof(password) - 1] = '\0';
+            }
 	} else
 	    monitor_readline("Password: ", 1, password, sizeof(password));
 	if (vnc_display_password(NULL, password) < 0)
#1 lore raw
Quoted 5 lines · Nolan

Add monitor support for setting the VNC password to "", disabling VNC.

The magic sentinel value is "<<unset>>" which is not a valid VNC password by virtue of being 9 characters long.

That's a little too magical for me. If you want to disable VNC, can't you just say change vnc none?

Regards,

Anthony Liguori

Quoted 26 lines
qemu/monitor.c +7 -2
index 1b2adc8..7bbb457 100644
@@ -466,8 +466,13 @@ static void do_change_vnc(const char *target, const char *arg)
 	strcmp(target, "password") == 0) {
 	char password[9];
 	if (arg) {
-	    strncpy(password, arg, sizeof(password));
-	    password[sizeof(password) - 1] = '\0';
+            /* "<<unset>>" is 9 chars long, so it is not a valid VNC passwd. */
+            if (strcmp(arg, "<<unset>>") == 0) {
+                password[0] = '\0';
+            } else {
+                strncpy(password, arg, sizeof(password));
+                password[sizeof(password) - 1] = '\0';
+            }
 	} else
 	    monitor_readline("Password: ", 1, password, sizeof(password));
 	if (vnc_display_password(NULL, password) < 0)
author
#2 lore raw
Quoted 8 lines · Anthony
Quoted 4 lines · Nolan

Add monitor support for setting the VNC password to "", disabling VNC.

The magic sentinel value is "<<unset>>" which is not a valid VNC password by virtue of being 9 characters long.

That's a little too magical for me. If you want to disable VNC, can't you just say change vnc none?

If you start with "-vnc :0,password", you will have no password set (thus logins are disabled), but qemu is listening on the port (keeping it occupied).

"vnc change none" will close the socket. The intent of "change vnc password <<unset>>" is to leave the socket open, but disallow logins until the password is reset. Basically the goal is to provide a way to get back into state we were in immediately after process start. This is currently possible with the interactive "change vnc password" command, but not possible with the non-interactive variant.

#3 lore raw
Quoted 14 lines · Nolan
Quoted 8 lines · Anthony
Quoted 4 lines · Nolan

Add monitor support for setting the VNC password to "", disabling VNC.

The magic sentinel value is "<<unset>>" which is not a valid VNC password by virtue of being 9 characters long.

That's a little too magical for me. If you want to disable VNC, can't you just say change vnc none?

If you start with "-vnc :0,password", you will have no password set (thus logins are disabled), but qemu is listening on the port (keeping it occupied).

Quoted 6 lines

"vnc change none" will close the socket. The intent of "change vnc password <<unset>>" is to leave the socket open, but disallow logins until the password is reset. Basically the goal is to provide a way to get back into state we were in immediately after process start. This is currently possible with the interactive "change vnc password" command, but not possible with the non-interactive variant.

How about just making it parse quotes for the password, so you could do

change vnc password ""

and thus have it set to the empty string. This would also let people have passwords with spaces in them

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
author
#4 lore raw
Quoted 7 lines · Daniel

How about just making it parse quotes for the password, so you could do

change vnc password ""

and thus have it set to the empty string. This would also let people have passwords with spaces in them

An excellent suggestion. So excellent in fact, that it already works with qemu as is.

I rescind my request to apply this patch. Either quotes being parsed by the monitor is a relatively new phenomenon, or I spaced pretty badly when I wrote this last summer.

#5 lore raw
Quoted 11 lines · Nolan
Quoted 7 lines · Daniel

How about just making it parse quotes for the password, so you could do

change vnc password ""

and thus have it set to the empty string. This would also let people have passwords with spaces in them

An excellent suggestion. So excellent in fact, that it already works with qemu as is.

I aim to please :-)

Quoted 3 lines

I rescind my request to apply this patch. Either quotes being parsed by the monitor is a relatively new phenomenon, or I spaced pretty badly when I wrote this last summer.

This was news to me too! It is probably worth mentioning this explicitly in the qemu-doc.texi documentation file on the 'change vnc passwd' command, if you wish to provide a patch to that.

Regards,
Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|