vnc: refuse to set a password with VNC_AUTH_NONE
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>
This commit is contained in:
parent
9bb931802e
commit
cf864569cd
34
ui/vnc.c
34
ui/vnc.c
|
@ -2976,26 +2976,6 @@ static void vnc_display_close(DisplayState *ds)
|
||||||
#endif
|
#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)
|
int vnc_display_password(DisplayState *ds, const char *password)
|
||||||
{
|
{
|
||||||
VncDisplay *vs = vnc_display;
|
VncDisplay *vs = vnc_display;
|
||||||
|
@ -3003,20 +2983,18 @@ int vnc_display_password(DisplayState *ds, const char *password)
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
if (vs->auth == VNC_AUTH_NONE) {
|
||||||
if (!password) {
|
error_printf_unless_qmp("If you want use passwords please enable "
|
||||||
/* This is not the intention of this interface but err on the side
|
"password auth using '-vnc ${dpy},password'.");
|
||||||
of being safe */
|
return -EINVAL;
|
||||||
return vnc_display_disable_login(ds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vs->password) {
|
if (vs->password) {
|
||||||
g_free(vs->password);
|
g_free(vs->password);
|
||||||
vs->password = NULL;
|
vs->password = NULL;
|
||||||
}
|
}
|
||||||
vs->password = g_strdup(password);
|
if (password) {
|
||||||
if (vs->auth == VNC_AUTH_NONE) {
|
vs->password = g_strdup(password);
|
||||||
vs->auth = VNC_AUTH_VNC;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue