/*
- * Copyright (C) 2000-3 Brendan Cully <brendan@kublai.com>
+ * Copyright (C) 2000-5 Brendan Cully <brendan@kublai.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
/* common SASL helper routines */
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "mutt.h"
#include "account.h"
#include "mutt_sasl.h"
#include "mutt_socket.h"
#ifdef USE_SASL2
+#include <errno.h>
#include <netdb.h>
#include <sasl/sasl.h>
#else
service = "imap";
break;
case M_ACCT_TYPE_POP:
- service = "pop-3";
+ service = "pop";
break;
default:
dprint (1, (debugfile, "mutt_sasl_client_new: account type unset\n"));
* If someone does it'd probably be trivial to write mutt_nss_get_ssf().
* I have a feeling more SSL code could be shared between those two files,
* but I haven't looked into it yet, since I still don't know the APIs. */
-#if (defined(USE_SSL) || defined(USE_GNUTLS) && !defined(USE_NSS)
+#if (defined(USE_SSL) || defined(USE_GNUTLS) && !defined(USE_NSS))
if (conn->account.flags & M_ACCT_SSL)
{
#ifdef USE_SASL2 /* I'm not sure this actually has an effect, at least with SASLv2 */
return -1;
}
#ifdef USE_SASL2
- dprint (2, (debugfile, "External authentication name: %s\n","NULL"));
- if (sasl_setprop (*saslconn, SASL_AUTH_EXTERNAL, NULL) != SASL_OK)
+ dprint (2, (debugfile, "External authentication name: %s\n", conn->account.user));
+ if (sasl_setprop (*saslconn, SASL_AUTH_EXTERNAL, conn->account.user) != SASL_OK)
{
dprint (1, (debugfile, "mutt_sasl_client_new: Error setting external properties\n"));
return -1;
/* preserve old functions */
sasldata->sockdata = conn->sockdata;
- sasldata->open = conn->open;
- sasldata->close = conn->close;
- sasldata->read = conn->read;
- sasldata->write = conn->write;
+ sasldata->msasl_open = conn->conn_open;
+ sasldata->msasl_close = conn->conn_close;
+ sasldata->msasl_read = conn->conn_read;
+ sasldata->msasl_write = conn->conn_write;
/* and set up new functions */
conn->sockdata = sasldata;
- conn->open = mutt_sasl_conn_open;
- conn->close = mutt_sasl_conn_close;
- conn->read = mutt_sasl_conn_read;
- conn->write = mutt_sasl_conn_write;
+ conn->conn_open = mutt_sasl_conn_open;
+ conn->conn_close = mutt_sasl_conn_close;
+ conn->conn_read = mutt_sasl_conn_read;
+ conn->conn_write = mutt_sasl_conn_write;
}
/* mutt_sasl_cb_log: callback to log SASL messages */
sasldata = (SASL_DATA*) conn->sockdata;
conn->sockdata = sasldata->sockdata;
- rc = (sasldata->open) (conn);
+ rc = (sasldata->msasl_open) (conn);
conn->sockdata = sasldata;
return rc;
/* restore connection's underlying methods */
conn->sockdata = sasldata->sockdata;
- conn->open = sasldata->open;
- conn->close = sasldata->close;
- conn->read = sasldata->read;
- conn->write = sasldata->write;
+ conn->conn_open = sasldata->msasl_open;
+ conn->conn_close = sasldata->msasl_close;
+ conn->conn_read = sasldata->msasl_read;
+ conn->conn_write = sasldata->msasl_write;
/* release sasl resources */
sasl_dispose (&sasldata->saslconn);
FREE (&sasldata);
/* call underlying close */
- rc = (conn->close) (conn);
+ rc = (conn->conn_close) (conn);
return rc;
}
do
{
/* call the underlying read function to fill the buffer */
- rc = (sasldata->read) (conn, buf, len);
+ rc = (sasldata->msasl_read) (conn, buf, len);
if (rc <= 0)
goto out;
rc = olen;
}
else
- rc = (sasldata->read) (conn, buf, len);
+ rc = (sasldata->msasl_read) (conn, buf, len);
out:
conn->sockdata = sasldata;
goto fail;
}
- rc = (sasldata->write) (conn, pbuf, plen);
+ rc = (sasldata->msasl_write) (conn, pbuf, plen);
#ifndef USE_SASL2
FREE (&pbuf);
#endif
}
else
/* just write using the underlying socket function */
- rc = (sasldata->write) (conn, buf, len);
+ rc = (sasldata->msasl_write) (conn, buf, len);
conn->sockdata = sasldata;