Skip to content

Commit

Permalink
vnc: refuse to set a password with VNC_AUTH_NONE
Browse files Browse the repository at this point in the history
Current code silently changes the authentication settings
in case you try to set a password without password authentication
turned on.  This is bad.  Return an error instead.

If we want allow changing auth settings at runtime this should
be done explicitly using a separate monitor command, not as
side effect of set_passwd.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
kraxel committed Jun 2, 2014
1 parent 9bb9318 commit cf86456
Showing 1 changed file with 6 additions and 28 deletions.
34 changes: 6 additions & 28 deletions ui/vnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2976,47 +2976,25 @@ static void vnc_display_close(DisplayState *ds)
#endif
}

static int vnc_display_disable_login(DisplayState *ds)
{
VncDisplay *vs = vnc_display;

if (!vs) {
return -1;
}

if (vs->password) {
g_free(vs->password);
}

vs->password = NULL;
if (vs->auth == VNC_AUTH_NONE) {
vs->auth = VNC_AUTH_VNC;
}

return 0;
}

int vnc_display_password(DisplayState *ds, const char *password)
{
VncDisplay *vs = vnc_display;

if (!vs) {
return -EINVAL;
}

if (!password) {
/* This is not the intention of this interface but err on the side
of being safe */
return vnc_display_disable_login(ds);
if (vs->auth == VNC_AUTH_NONE) {
error_printf_unless_qmp("If you want use passwords please enable "
"password auth using '-vnc ${dpy},password'.");
return -EINVAL;
}

if (vs->password) {
g_free(vs->password);
vs->password = NULL;
}
vs->password = g_strdup(password);
if (vs->auth == VNC_AUTH_NONE) {
vs->auth = VNC_AUTH_VNC;
if (password) {
vs->password = g_strdup(password);
}

return 0;
Expand Down

0 comments on commit cf86456

Please sign in to comment.