summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@redhat.com>2015-01-27 13:43:56 -0600
committerFabiano FidĂȘncio <fidencio@redhat.com>2015-02-23 23:00:45 +0100
commit8501d3d6cdacbceb7c158e969ccc26496a2d96e1 (patch)
treeda439816ffb5d1a32045bf833295cad3e337ea6e
parent65f08cc5f9b7998ff893fcbd2a140215bac9e287 (diff)
downloadspice-8501d3d6cdacbceb7c158e969ccc26496a2d96e1.tar.gz
spice-8501d3d6cdacbceb7c158e969ccc26496a2d96e1.tar.xz
spice-8501d3d6cdacbceb7c158e969ccc26496a2d96e1.zip
Move sasl_enabled, sasl_appname to RedsState struct
Removing more global variables
-rw-r--r--server/reds-private.h4
-rw-r--r--server/reds.c28
2 files changed, 18 insertions, 14 deletions
diff --git a/server/reds-private.h b/server/reds-private.h
index 8435d03e..efb00674 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -191,6 +191,10 @@ struct RedsState {
int spice_family;
TicketAuthentication taTicket;
+ int sasl_enabled;
+#if HAVE_SASL
+ char *sasl_appname;
+#endif
};
#endif
diff --git a/server/reds.c b/server/reds.c
index 6da85813..0634b0f1 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -89,10 +89,6 @@ SpiceCoreInterface *core = NULL;
#define REDS_TOKENS_TO_SEND 5
#define REDS_VDI_PORT_NUM_RECEIVE_BUFFS 5
-static int sasl_enabled = 0; // sasl disabled by default
-#if HAVE_SASL
-static char *sasl_appname = NULL; // default to "spice" if NULL
-#endif
static char *spice_name = NULL;
static bool spice_uuid_is_set = FALSE;
static uint8_t spice_uuid[16] = { 0, };
@@ -1318,7 +1314,7 @@ int reds_handle_migrate_data(RedsState *reds, MainChannelClient *mcc,
static void reds_channel_init_auth_caps(RedLinkInfo *link, RedChannel *channel)
{
- if (sasl_enabled && !link->skip_auth) {
+ if (reds->sasl_enabled && !link->skip_auth) {
red_channel_set_common_cap(channel, SPICE_COMMON_CAP_AUTH_SASL);
} else {
red_channel_set_common_cap(channel, SPICE_COMMON_CAP_AUTH_SPICE);
@@ -1374,7 +1370,7 @@ static int reds_send_link_ack(RedsState *reds, RedLinkInfo *link)
ack.num_channel_caps = channel_caps->num_caps;
header.size += (ack.num_common_caps + ack.num_channel_caps) * sizeof(uint32_t);
ack.caps_offset = sizeof(SpiceLinkReply);
- if (!sasl_enabled
+ if (!reds->sasl_enabled
|| !red_link_info_test_capability(link, SPICE_COMMON_CAP_AUTH_SASL)) {
if (!(link->tiTicketing.rsa = RSA_new())) {
spice_warning("RSA new failed");
@@ -2047,7 +2043,7 @@ static void reds_handle_auth_mechanism(void *opaque)
spice_info("Auth method: %d", link->auth_mechanism.auth_mechanism);
if (link->auth_mechanism.auth_mechanism == SPICE_COMMON_CAP_AUTH_SPICE
- && !sasl_enabled
+ && !reds->sasl_enabled
) {
reds_get_spice_ticket(link);
#if HAVE_SASL
@@ -2057,7 +2053,7 @@ static void reds_handle_auth_mechanism(void *opaque)
#endif
} else {
spice_warning("Unknown auth method, disconnecting");
- if (sasl_enabled) {
+ if (reds->sasl_enabled) {
spice_warning("Your client doesn't handle SASL?");
}
reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);
@@ -2109,7 +2105,7 @@ static void reds_handle_read_link_done(void *opaque)
}
if (!auth_selection) {
- if (sasl_enabled && !link->skip_auth) {
+ if (reds->sasl_enabled && !link->skip_auth) {
spice_warning("SASL enabled, but peer supports only spice authentication");
reds_send_link_error(link, SPICE_LINK_ERR_VERSION_MISMATCH);
return;
@@ -3280,8 +3276,8 @@ static int do_spice_init(RedsState *reds, SpiceCoreInterface *core_interface)
}
#if HAVE_SASL
int saslerr;
- if ((saslerr = sasl_server_init(NULL, sasl_appname ?
- sasl_appname : "spice")) != SASL_OK) {
+ if ((saslerr = sasl_server_init(NULL, reds->sasl_appname ?
+ reds->sasl_appname : "spice")) != SASL_OK) {
spice_error("Failed to initialize SASL auth %s",
sasl_errstring(saslerr, NULL, NULL));
goto err;
@@ -3321,6 +3317,10 @@ SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
reds->spice_secure_port = -1;
reds->spice_listen_socket_fd = -1;
reds->spice_family = PF_UNSPEC;
+ reds->sasl_enabled = 0; // sasl disabled by default
+#if HAVE_SASL
+ reds->sasl_appname = NULL; // default to "spice" if NULL
+#endif
return reds;
}
@@ -3444,7 +3444,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_sasl(SpiceServer *s, int enabled)
{
spice_assert(reds == s);
#if HAVE_SASL
- sasl_enabled = enabled;
+ s->sasl_enabled = enabled;
return 0;
#else
return -1;
@@ -3455,8 +3455,8 @@ SPICE_GNUC_VISIBLE int spice_server_set_sasl_appname(SpiceServer *s, const char
{
spice_assert(reds == s);
#if HAVE_SASL
- free(sasl_appname);
- sasl_appname = spice_strdup(appname);
+ free(s->sasl_appname);
+ s->sasl_appname = spice_strdup(appname);
return 0;
#else
return -1;