/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Authors: Jeffrey Stedfast * * Copyright 2001 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. * */ #ifdef HAVE_CONFIG_H #include #endif #ifdef HAVE_KRB4 #include /* MIT krb4 des.h #defines _. Sigh. We don't need it. #undef it here * so we get the gettexty _ definition later. */ #undef _ #include #include "camel-sasl-kerberos4.h" #include "camel-service.h" CamelServiceAuthType camel_sasl_kerberos4_authtype = { N_("Kerberos 4"), N_("This option will connect to the server using " "Kerberos 4 authentication."), "KERBEROS_V4", FALSE }; #define KERBEROS_V4_PROTECTION_NONE 1 #define KERBEROS_V4_PROTECTION_INTEGRITY 2 #define KERBEROS_V4_PROTECTION_PRIVACY 4 static CamelSaslClass *parent_class = NULL; /* Returns the class for a CamelSaslKerberos4 */ #define CSK4_CLASS(so) CAMEL_SASL_KERBEROS4_CLASS (CAMEL_OBJECT_GET_CLASS (so)) static GByteArray *krb4_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex); struct _CamelSaslKerberos4Private { int state; guint32 nonce_n; guint32 nonce_h; des_cblock session; des_key_schedule schedule; }; static void camel_sasl_kerberos4_class_init (CamelSaslKerberos4Class *camel_sasl_kerberos4_class) { CamelSaslClass *camel_sasl_class = CAMEL_SASL_CLASS (camel_sasl_kerberos4_class); parent_class = CAMEL_SASL_CLASS (camel_type_get_global_classfuncs (camel_sasl_get_type ())); /* virtual method overload */ camel_sasl_class->challenge = krb4_challenge; } static void camel_sasl_kerberos4_init (gpointer object, gpointer klass) { CamelSaslKerberos4 *sasl_krb4 = CAMEL_SASL_KERBEROS4 (object); sasl_krb4->priv = g_new0 (struct _CamelSaslKerberos4Private, 1); } static void camel_sasl_kerberos4_finalize (CamelObject *object) { CamelSaslKerberos4 *sasl = CAMEL_SASL_KERBEROS4 (object); if (sasl->priv) { memset (sasl->priv, 0, sizeof (sasl->priv)); g_free (sasl->priv); } } CamelType camel_sasl_kerberos4_get_type (void) { static CamelType type = CAMEL_INVALID_TYPE; if (type == CAMEL_INVALID_TYPE) { type = camel_type_register (camel_sasl_get_type (), "CamelSaslKerberos4", sizeof (CamelSaslKerberos4), sizeof (CamelSaslKerberos4Class), (CamelObjectClassInitFunc) camel_sasl_kerberos4_class_init, NULL, (CamelObjectInitFunc) camel_sasl_kerberos4_init, (CamelObjectFinalizeFunc) camel_sasl_kerberos4_finalize); } return type; } static GByteArray * krb4_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex) { struct _CamelSaslKerberos4Private *priv = CAMEL_SASL_KERBEROS4 (sasl)->priv; GByteArray *ret = NULL; char *inst, *realm, *username; struct hostent *h; int status, len; KTEXT_ST authenticator; CREDENTIALS credentials; guint32 plus1; /* Need to wait for the server */ if (!token) return NULL; switch (priv->state) { case 0: if (token->len != 4) goto lose; memcpy (&priv->nonce_n, token->data, 4); priv->nonce_h = ntohl (priv->nonce_n); /* Our response is an authenticator including that number. */ h = camel_service_gethost (sasl->service, ex); inst = g_strndup (h->h_name, strcspn (h->h_name, ".")); g_strdown (inst); realm = g_strdup (krb_realmofhost (h->h_name)); camel_free_host(h); status = krb_mk_req (&authenticator, sasl->service_name, inst, realm, priv->nonce_h); if (status == KSUCCESS) { status = krb_get_cred (sasl->service_name, inst, realm, &credentials); memcpy (priv->session, credentials.session, sizeof (priv->session)); memset (&credentials, 0, sizeof (credentials)); } g_free (inst); g_free (realm); if (status != KSUCCESS) { camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("Could not get Kerberos ticket:\n%s"), krb_err_txt[status]); goto lose; } des_key_sched (&priv->session, priv->schedule); ret = g_byte_array_new (); g_byte_array_append (ret, (const guint8 *)authenticator.dat, authenticator.length); break; case 1: if (token->len != 8) goto lose; /* This one is encrypted. */ des_ecb_encrypt ((des_cblock *)token->data, (des_cblock *)token->data, priv->schedule, 0); /* Check that the returned value is the original nonce plus one. */ memcpy (&plus1, token->data, 4); if (ntohl (plus1) != priv->nonce_h + 1) goto lose; /* "the fifth octet contain[s] a bit-mask specifying the * protection mechanisms supported by the server" */ if (!(token->data[4] & KERBEROS_V4_PROTECTION_NONE)) { g_warning ("Server does not support `no protection' :-("); goto lose; } username = sasl->service->url->user; len = strlen (username) + 9; len += 8 - len % 8; ret = g_byte_array_new (); g_byte_array_set_size (ret, len); memset (ret->data, 0, len); memcpy (ret->data, &priv->nonce_n, 4); ret->data[4] = KERBEROS_V4_PROTECTION_NONE; ret->data[5] = ret->data[6] = ret->data[7] = 0; strcpy (ret->data + 8, username); des_pcbc_encrypt ((void *)ret->data, (void *)ret->data, len, priv->schedule, &priv->session, 1); memset (&priv->session, 0, sizeof (priv->session)); sasl->authenticated = TRUE; break; } priv->state++; return ret; lose: memset (&priv->session, 0, sizeof (priv->session)); if (!camel_exception_is_set (ex)) { camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("Bad authentication response from server.")); } return NULL; } #endif /* HAVE_KRB4 */ ion='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/log/sysutils/smartmontools-devel'>
Commit message (Expand)AuthorAgeFilesLines
* - Revert previous changepav2009-01-012-56/+34
* - Improve periodic scriptpav2008-12-282-34/+56
* - Now comes with a periodic scriptpav2008-12-194-2/+65
* Update CONFIGURE_ARGS for how we pass CONFIGURE_TARGET to configure script.rafan2008-08-211-1/+0
* - Remove CISS option, the necessary support is now included in the vendor codepav2008-04-203-321/+1
* - Update to 5.38pav2008-03-254-27/+24
* - Allow smartctl to interact with SCSI /dev/pass devices, thus enabling it topav2007-10-223-76/+30
* - Set --mandir and --infodir in CONFIGURE_ARGS if the configure scriptrafan2007-07-231-1/+1
* - Fix smartd to detect drives if the first drive has two-digit number (likepav2007-03-263-0/+29
* - Add optional ciss(4) support, defaults to offpav2007-03-033-1/+382
* - Update to 5.37pav2007-01-074-58/+24
* - Take maintainershippav2006-09-052-12/+7
* Reset inactive maintainer who has not responded to email.linimon2006-09-051-1/+1
* - Update to 5.36 [1]garga2006-05-1211-956/+45
* As of FreeBSD 6.x, the full path to the device is required. This is backwardsvs2006-03-151-2/+2
* Remove the FreeBSD KEYWORD from all rc.d scripts where it appears.dougb2006-02-211-1/+1
* SHA256ifyedwin2006-01-241-0/+1
* Now that new style rc.d scripts are being run as part of thedougb2006-01-072-2/+2
* - It seems --configfile is no-op, replace by -c.flz2005-11-182-2/+2
* - Tweak rcng script to allow alternative location for the configuration file.flz2005-11-182-3/+5
* Add patches for twa (3ware 9000 series controller) support.lawrance2005-10-105-21/+642
* fix smartmontools for recent CURRENT systems.oliver2005-05-252-3/+301
* Update to 5.33 and unIGNORE on 4.xvs2005-05-092-7/+3
* At Kris's request, back out the MACHINE_ARCH spelling correction untilobrien2005-04-121-1/+1
* Assist getting more ports working on AMD64 by obeying theobrien2005-04-111-1/+1
* Mark as IGNORE for OSVERSION < 501105: Needs ATAngvs2004-09-031-3/+1
* Oops, I forgot to add a patch file.nork2004-07-151-0/+10
* Update to 5.32.nork2004-07-152-3/+3
* o Update to 5.31.nork2004-07-153-5/+6
* Oops, fix handling pidfile.nork2004-04-292-3/+4
* rcNG-fy.nork2004-04-294-6/+50
* Update to 5.30.nork2004-03-092-3/+4
* Bump PORTREVISION on all ports that depend on gettext to aid with upgrading.marcus2004-02-041-0/+1
* - Update to 5.26sergei2003-12-055-64/+3
* - Properly spell pre-everything with two colonssergei2003-11-021-4/+4
* Unbreak build on 4-STABLE and 5.1-RELEASE. Add a warning which statesbms2003-11-013-2/+65
* - Update to 5.22sergei2003-11-012-2/+2