#endif /* HAVE_SUN_KRB5 */
#endif /* HAVE_HEIMDAL_KRB5 */
+#define CAMEL_SASL_GSSAPI_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), CAMEL_TYPE_SASL_GSSAPI, CamelSaslGssapiPrivate))
+
#ifndef GSS_C_OID_KRBV5_DES
#define GSS_C_OID_KRBV5_DES GSS_C_NO_OID
#endif
gchar *str;
struct addrinfo *ai, hints;
const gchar *service_name;
- const gchar *host;
- const gchar *user;
+ gchar *host;
+ gchar *user;
- priv = CAMEL_SASL_GSSAPI (sasl)->priv;
+ priv = CAMEL_SASL_GSSAPI_GET_PRIVATE (sasl);
service = camel_sasl_get_service (sasl);
service_name = camel_sasl_get_service_name (sasl);
- settings = camel_service_get_settings (service);
+ settings = camel_service_ref_settings (service);
g_return_val_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings), NULL);
network_settings = CAMEL_NETWORK_SETTINGS (settings);
- host = camel_network_settings_get_host (network_settings);
- user = camel_network_settings_get_user (network_settings);
+ host = camel_network_settings_dup_host (network_settings);
+ user = camel_network_settings_dup_user (network_settings);
+
+ g_object_unref (settings);
+
g_return_val_if_fail (user != NULL, NULL);
if (host == NULL)
- host = "localhost";
+ host = g_strdup ("localhost");
switch (priv->state) {
case GSSAPI_STATE_INIT:
ai = camel_getaddrinfo (
host, NULL, &hints, cancellable, error);
if (ai == NULL)
- return NULL;
+ goto exit;
str = g_strdup_printf("%s@%s", service_name, ai->ai_canonname);
camel_freeaddrinfo (ai);
if (major != GSS_S_COMPLETE) {
gssapi_set_exception (major, minor, error);
- return NULL;
+ goto exit;
}
input_token = GSS_C_NO_BUFFER;
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Bad authentication response from server."));
- return NULL;
+ goto exit;
}
inbuf.value = token->data;
goto challenge;
gssapi_set_exception (major, minor, error);
- return NULL;
+ goto exit;
}
challenge = g_byte_array_new ();
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
_("Bad authentication response from server."));
- return NULL;
+ goto exit;
}
inbuf.value = token->data;
major = gss_unwrap (&minor, priv->ctx, &inbuf, &outbuf, &conf_state, &qop);
if (major != GSS_S_COMPLETE) {
gssapi_set_exception (major, minor, error);
- return NULL;
+ goto exit;
}
if (outbuf.length < 4) {
#ifndef HAVE_HEIMDAL_KRB5
gss_release_buffer (&minor, &outbuf);
#endif
- return NULL;
+ goto exit;
}
/* check that our desired security layer is supported */
#ifndef HAVE_HEIMDAL_KRB5
gss_release_buffer (&minor, &outbuf);
#endif
- return NULL;
+ goto exit;
}
inbuf.length = 4 + strlen (user);
if (major != GSS_S_COMPLETE) {
gssapi_set_exception (major, minor, error);
g_free (str);
- return NULL;
+ goto exit;
}
g_free (str);
camel_sasl_set_authenticated (sasl, TRUE);
break;
default:
- return NULL;
+ break;
}
+exit:
+ g_free (host);
+ g_free (user);
+
return challenge;
}
camel_sasl_gssapi_init (CamelSaslGssapi *sasl)
{
#ifdef HAVE_KRB5
- sasl->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- sasl, CAMEL_TYPE_SASL_GSSAPI, CamelSaslGssapiPrivate);
+ sasl->priv = CAMEL_SASL_GSSAPI_GET_PRIVATE (sasl);
sasl->priv->state = GSSAPI_STATE_INIT;
sasl->priv->ctx = GSS_C_NO_CONTEXT;
sasl->priv->target = GSS_C_NO_NAME;