57
64
#include <glib/gi18n-lib.h>
66
#include <dbus/dbus.h>
67
#include <dbus/dbus-glib-lowlevel.h>
59
69
#include "camel-net-utils.h"
60
70
#include "camel-sasl-gssapi.h"
71
#include "camel-session.h"
73
#define DBUS_PATH "/org/gnome/KrbAuthDialog"
74
#define DBUS_INTERFACE "org.gnome.KrbAuthDialog"
75
#define DBUS_METHOD "org.gnome.KrbAuthDialog.acquireTgt"
62
77
CamelServiceAuthType camel_sasl_gssapi_authtype = {
203
218
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, str);
221
/* DBUS Specific code */
224
send_dbus_message (gchar *name)
226
DBusMessage *message, *reply;
227
DBusError dbus_error;
228
gint success = FALSE;
229
DBusConnection *bus = NULL;
231
dbus_error_init (&dbus_error);
232
if (!(bus = dbus_bus_get (DBUS_BUS_SESSION, &dbus_error))) {
233
g_warning ("could not get system bus: %s\n", dbus_error.message);
234
dbus_error_free (&dbus_error);
238
dbus_error_free (&dbus_error);
240
dbus_connection_setup_with_g_main (bus, NULL);
241
dbus_connection_set_exit_on_disconnect (bus, FALSE);
243
/* Create a new message on the DBUS_INTERFACE */
244
if (!(message = dbus_message_new_method_call (DBUS_INTERFACE, DBUS_PATH, DBUS_INTERFACE, "acquireTgt"))) {
245
g_object_unref (bus);
248
/* Appends the data as an argument to the message */
249
if (strchr(name, '\\'))
250
name = strchr(name, '\\');
251
dbus_message_append_args (message,
252
DBUS_TYPE_STRING, &name,
254
dbus_error_init(&dbus_error);
256
/* Sends the message: Have a 300 sec wait timeout */
257
reply = dbus_connection_send_with_reply_and_block (bus, message, 300 * 1000, &dbus_error);
259
if (dbus_error_is_set(&dbus_error))
260
g_warning ("%s: %s\n", dbus_error.name, dbus_error.message);
261
dbus_error_free(&dbus_error);
265
dbus_error_init(&dbus_error);
266
dbus_message_get_args(reply, &dbus_error, DBUS_TYPE_BOOLEAN, &success, DBUS_TYPE_INVALID);
267
dbus_error_free(&dbus_error);
268
dbus_message_unref(reply);
271
/* Free the message */
272
dbus_message_unref (message);
273
dbus_connection_unref (bus);
206
280
static GByteArray *
207
281
gssapi_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex)
268
342
priv->state = GSSAPI_STATE_CONTINUE_NEEDED;
271
gssapi_set_exception (major, minor, ex);
345
if (major == (OM_uint32)GSS_S_FAILURE &&
346
(minor == (OM_uint32)KRB5KRB_AP_ERR_TKT_EXPIRED ||
347
minor == (OM_uint32)KRB5KDC_ERR_NEVER_VALID)) {
348
if (send_dbus_message (sasl->service->url->user))
351
gssapi_set_exception (major, minor, ex);