~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to camel/camel-sasl-gssapi.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <string.h>
32
32
#include <sys/socket.h>
33
33
#include <sys/types.h>
 
34
#ifdef HAVE_HEIMDAL_KRB5
 
35
#include <krb5.h>
 
36
#else
 
37
#include <krb5/krb5.h>
 
38
#endif
34
39
#ifdef HAVE_ET_COM_ERR_H
35
40
#include <et/com_err.h>
36
41
#else
 
42
#ifdef HAVE_COM_ERR_H
37
43
#include <com_err.h>
38
44
#endif
 
45
#endif
39
46
#ifdef HAVE_MIT_KRB5
40
47
#include <gssapi/gssapi.h>
41
48
#include <gssapi/gssapi_generic.h>
56
63
 
57
64
#include <glib/gi18n-lib.h>
58
65
 
 
66
#include <dbus/dbus.h>
 
67
#include <dbus/dbus-glib-lowlevel.h>
 
68
 
59
69
#include "camel-net-utils.h"
60
70
#include "camel-sasl-gssapi.h"
 
71
#include "camel-session.h"
 
72
 
 
73
#define DBUS_PATH               "/org/gnome/KrbAuthDialog"
 
74
#define DBUS_INTERFACE          "org.gnome.KrbAuthDialog"
 
75
#define DBUS_METHOD             "org.gnome.KrbAuthDialog.acquireTgt"
61
76
 
62
77
CamelServiceAuthType camel_sasl_gssapi_authtype = {
63
78
        N_("GSSAPI"),
203
218
        camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, str);
204
219
}
205
220
 
 
221
/* DBUS Specific code */
 
222
 
 
223
static gboolean
 
224
send_dbus_message (gchar *name)
 
225
{
 
226
        DBusMessage *message, *reply;
 
227
        DBusError dbus_error;
 
228
        gint success = FALSE;
 
229
        DBusConnection *bus = NULL;
 
230
 
 
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);
 
235
                return FALSE;
 
236
        }
 
237
 
 
238
        dbus_error_free (&dbus_error);
 
239
 
 
240
        dbus_connection_setup_with_g_main (bus, NULL);
 
241
        dbus_connection_set_exit_on_disconnect (bus, FALSE);
 
242
 
 
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);
 
246
                return FALSE;
 
247
        }
 
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,
 
253
                                  DBUS_TYPE_INVALID);
 
254
        dbus_error_init(&dbus_error);
 
255
 
 
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);
 
258
 
 
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);
 
262
 
 
263
        if (reply)
 
264
        {
 
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);
 
269
        }
 
270
 
 
271
        /* Free the message */
 
272
        dbus_message_unref (message);
 
273
        dbus_connection_unref (bus);
 
274
 
 
275
        return success;
 
276
}
 
277
 
 
278
/* END DBus stuff */
 
279
 
206
280
static GByteArray *
207
281
gssapi_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex)
208
282
{
268
342
                        priv->state = GSSAPI_STATE_CONTINUE_NEEDED;
269
343
                        break;
270
344
                default:
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))
 
349
                                        goto challenge;
 
350
                        } else
 
351
                                gssapi_set_exception (major, minor, ex);
272
352
                        return NULL;
273
353
                }
274
354