@@ -3161,6 +3161,7 @@ void vnc_display_init(const char *id)
QTAILQ_INIT(&vs->clients);
vs->expires = TIME_MAX;
+ vs->oldauth = VNC_AUTH_NONE;
if (keyboard_layout) {
trace_vnc_key_map_init(keyboard_layout);
@@ -3214,10 +3215,19 @@ int vnc_display_password(const char *id, const char *password)
if (!vs) {
return -EINVAL;
}
- 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 (password) {
+ if (vs->auth == VNC_AUTH_NONE && vs->oldauth == VNC_AUTH_NONE) {
+ vs->auth = VNC_AUTH_VNC;
+ } else if (vs->oldauth != VNC_AUTH_NONE) {
+ vs->auth = vs->oldauth;
+ vs->oldauth = VNC_AUTH_NONE;
+ }
+ } else {
+ if (vs->auth != VNC_AUTH_NONE) {
+ vs->oldauth = vs->auth;
+ vs->auth = VNC_AUTH_NONE;
+ }
}
g_free(vs->password);
@@ -180,6 +180,7 @@ struct VncDisplay
char *password;
time_t expires;
int auth;
+ int oldauth; /* Used to store value of auth, when temporary disabled */
bool lossy;
bool non_adaptive;
#ifdef CONFIG_VNC_TLS
Well, this is a bit difficult since VNC has many ways of authentication. So, if no password was provided, the current authentication method is held in a variable (oldauth) and the method is set to VNC_AUTH_NONE to mark it explicitly that no password is required. However, as soon as the password is provided, the old method is restored. But, what happens if there's no old method? What if no authentication method was provided at the command line? Well, in that case the VNC_AUTH_VNC is set, which boils down to the same state as if the password was put onto command line. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- ui/vnc.c | 18 ++++++++++++++---- ui/vnc.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-)