spice: move auth functions to QemuSpiceOps.
Move qemu_spice_set_passwd() and qemu_spice_set_pw_expire() functions to QemuSpiceOps. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 20201019075224.14803-7-kraxel@redhat.com
This commit is contained in:
parent
05b53636d0
commit
08ad262643
@ -26,6 +26,9 @@ struct QemuSpiceOps {
|
|||||||
void (*init)(void);
|
void (*init)(void);
|
||||||
void (*display_init)(void);
|
void (*display_init)(void);
|
||||||
int (*migrate_info)(const char *h, int p, int t, const char *s);
|
int (*migrate_info)(const char *h, int p, int t, const char *s);
|
||||||
|
int (*set_passwd)(const char *passwd,
|
||||||
|
bool fail_if_connected, bool disconnect_if_connected);
|
||||||
|
int (*set_pw_expire)(time_t expires);
|
||||||
#ifdef CONFIG_SPICE
|
#ifdef CONFIG_SPICE
|
||||||
int (*add_interface)(SpiceBaseInstance *sin);
|
int (*add_interface)(SpiceBaseInstance *sin);
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,9 +31,6 @@ void qemu_spice_display_init(void);
|
|||||||
int qemu_spice_display_add_client(int csock, int skipauth, int tls);
|
int qemu_spice_display_add_client(int csock, int skipauth, int tls);
|
||||||
bool qemu_spice_have_display_interface(QemuConsole *con);
|
bool qemu_spice_have_display_interface(QemuConsole *con);
|
||||||
int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con);
|
int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con);
|
||||||
int qemu_spice_set_passwd(const char *passwd,
|
|
||||||
bool fail_if_connected, bool disconnect_if_connected);
|
|
||||||
int qemu_spice_set_pw_expire(time_t expires);
|
|
||||||
int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,
|
int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,
|
||||||
const char *subject);
|
const char *subject);
|
||||||
|
|
||||||
@ -48,17 +45,6 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,
|
|||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
|
|
||||||
#define spice_displays 0
|
#define spice_displays 0
|
||||||
static inline int qemu_spice_set_passwd(const char *passwd,
|
|
||||||
bool fail_if_connected,
|
|
||||||
bool disconnect_if_connected)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
static inline int qemu_spice_set_pw_expire(time_t expires)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int qemu_spice_display_add_client(int csock, int skipauth,
|
static inline int qemu_spice_display_add_client(int csock, int skipauth,
|
||||||
int tls)
|
int tls)
|
||||||
{
|
{
|
||||||
|
@ -197,7 +197,7 @@ void qmp_set_password(const char *protocol, const char *password,
|
|||||||
if (!qemu_using_spice(errp)) {
|
if (!qemu_using_spice(errp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rc = qemu_spice_set_passwd(password, fail_if_connected,
|
rc = qemu_spice.set_passwd(password, fail_if_connected,
|
||||||
disconnect_if_connected);
|
disconnect_if_connected);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
error_setg(errp, QERR_SET_PASSWD_FAILED);
|
error_setg(errp, QERR_SET_PASSWD_FAILED);
|
||||||
@ -243,7 +243,7 @@ void qmp_expire_password(const char *protocol, const char *whenstr,
|
|||||||
if (!qemu_using_spice(errp)) {
|
if (!qemu_using_spice(errp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rc = qemu_spice_set_pw_expire(when);
|
rc = qemu_spice.set_pw_expire(when);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
error_setg(errp, QERR_SET_PASSWD_FAILED);
|
error_setg(errp, QERR_SET_PASSWD_FAILED);
|
||||||
}
|
}
|
||||||
|
@ -727,7 +727,7 @@ static void qemu_spice_init(void)
|
|||||||
tls_ciphers);
|
tls_ciphers);
|
||||||
}
|
}
|
||||||
if (password) {
|
if (password) {
|
||||||
qemu_spice_set_passwd(password, false, false);
|
qemu_spice.set_passwd(password, false, false);
|
||||||
}
|
}
|
||||||
if (qemu_opt_get_bool(opts, "sasl", 0)) {
|
if (qemu_opt_get_bool(opts, "sasl", 0)) {
|
||||||
if (spice_server_set_sasl(spice_server, 1) == -1) {
|
if (spice_server_set_sasl(spice_server, 1) == -1) {
|
||||||
@ -941,8 +941,8 @@ static int qemu_spice_set_ticket(bool fail_if_conn, bool disconnect_if_conn)
|
|||||||
fail_if_conn, disconnect_if_conn);
|
fail_if_conn, disconnect_if_conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_spice_set_passwd(const char *passwd,
|
static int qemu_spice_set_passwd(const char *passwd,
|
||||||
bool fail_if_conn, bool disconnect_if_conn)
|
bool fail_if_conn, bool disconnect_if_conn)
|
||||||
{
|
{
|
||||||
if (strcmp(auth, "spice") != 0) {
|
if (strcmp(auth, "spice") != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -953,7 +953,7 @@ int qemu_spice_set_passwd(const char *passwd,
|
|||||||
return qemu_spice_set_ticket(fail_if_conn, disconnect_if_conn);
|
return qemu_spice_set_ticket(fail_if_conn, disconnect_if_conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_spice_set_pw_expire(time_t expires)
|
static int qemu_spice_set_pw_expire(time_t expires)
|
||||||
{
|
{
|
||||||
auth_expires = expires;
|
auth_expires = expires;
|
||||||
return qemu_spice_set_ticket(false, false);
|
return qemu_spice_set_ticket(false, false);
|
||||||
@ -997,6 +997,8 @@ static struct QemuSpiceOps real_spice_ops = {
|
|||||||
.init = qemu_spice_init,
|
.init = qemu_spice_init,
|
||||||
.display_init = qemu_spice_display_init,
|
.display_init = qemu_spice_display_init,
|
||||||
.migrate_info = qemu_spice_migrate_info,
|
.migrate_info = qemu_spice_migrate_info,
|
||||||
|
.set_passwd = qemu_spice_set_passwd,
|
||||||
|
.set_pw_expire = qemu_spice_set_pw_expire,
|
||||||
.add_interface = qemu_spice_add_interface,
|
.add_interface = qemu_spice_add_interface,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,8 +40,22 @@ static int qemu_spice_migrate_info_stub(const char *h, int p, int t,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int qemu_spice_set_passwd_stub(const char *passwd,
|
||||||
|
bool fail_if_connected,
|
||||||
|
bool disconnect_if_connected)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int qemu_spice_set_pw_expire_stub(time_t expires)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
struct QemuSpiceOps qemu_spice = {
|
struct QemuSpiceOps qemu_spice = {
|
||||||
.init = qemu_spice_init_stub,
|
.init = qemu_spice_init_stub,
|
||||||
.display_init = qemu_spice_display_init_stub,
|
.display_init = qemu_spice_display_init_stub,
|
||||||
.migrate_info = qemu_spice_migrate_info_stub,
|
.migrate_info = qemu_spice_migrate_info_stub,
|
||||||
|
.set_passwd = qemu_spice_set_passwd_stub,
|
||||||
|
.set_pw_expire = qemu_spice_set_pw_expire_stub,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user