vnc: Simplify vnc_display_password()
Drop the qerror_report() call from it and let its callers set the error themselves. This also allows for dropping the 'ret' variable. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
8c4ec5c026
commit
a6aa9d3e26
@ -384,7 +384,6 @@ int vnc_display_pw_expire(DisplayState *ds, time_t expires);
|
|||||||
#else
|
#else
|
||||||
static inline int vnc_display_password(DisplayState *ds, const char *password)
|
static inline int vnc_display_password(DisplayState *ds, const char *password)
|
||||||
{
|
{
|
||||||
qerror_report(QERR_FEATURE_DISABLED, "vnc");
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
static inline int vnc_display_pw_expire(DisplayState *ds, time_t expires)
|
static inline int vnc_display_pw_expire(DisplayState *ds, time_t expires)
|
||||||
|
@ -929,7 +929,12 @@ static int set_password(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
|||||||
}
|
}
|
||||||
/* Note that setting an empty password will not disable login through
|
/* Note that setting an empty password will not disable login through
|
||||||
* this interface. */
|
* this interface. */
|
||||||
return vnc_display_password(NULL, password);
|
rc = vnc_display_password(NULL, password);
|
||||||
|
if (rc < 0) {
|
||||||
|
qerror_report(QERR_SET_PASSWD_FAILED);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qerror_report(QERR_INVALID_PARAMETER, "protocol");
|
qerror_report(QERR_INVALID_PARAMETER, "protocol");
|
||||||
|
14
ui/vnc.c
14
ui/vnc.c
@ -2686,19 +2686,16 @@ int vnc_display_disable_login(DisplayState *ds)
|
|||||||
|
|
||||||
int vnc_display_password(DisplayState *ds, const char *password)
|
int vnc_display_password(DisplayState *ds, const char *password)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;
|
VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;
|
||||||
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!password) {
|
if (!password) {
|
||||||
/* This is not the intention of this interface but err on the side
|
/* This is not the intention of this interface but err on the side
|
||||||
of being safe */
|
of being safe */
|
||||||
ret = vnc_display_disable_login(ds);
|
return vnc_display_disable_login(ds);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vs->password) {
|
if (vs->password) {
|
||||||
@ -2707,11 +2704,8 @@ int vnc_display_password(DisplayState *ds, const char *password)
|
|||||||
}
|
}
|
||||||
vs->password = g_strdup(password);
|
vs->password = g_strdup(password);
|
||||||
vs->auth = VNC_AUTH_VNC;
|
vs->auth = VNC_AUTH_VNC;
|
||||||
out:
|
|
||||||
if (ret != 0) {
|
return 0;
|
||||||
qerror_report(QERR_SET_PASSWD_FAILED);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int vnc_display_pw_expire(DisplayState *ds, time_t expires)
|
int vnc_display_pw_expire(DisplayState *ds, time_t expires)
|
||||||
|
Loading…
Reference in New Issue
Block a user