SASL authentication support. More...
#include "config.h"#include <errno.h>#include <netdb.h>#include <sasl/sasl.h>#include <stdbool.h>#include <stdint.h>#include <stdio.h>#include <string.h>#include <sys/socket.h>#include <sys/types.h>#include "mutt/lib.h"#include "core/lib.h"#include "sasl.h"#include "editor/lib.h"#include "history/lib.h"#include "connaccount.h"#include "connection.h"#include "globals.h"#include "module_data.h"Go to the source code of this file.
Data Structures | |
| struct | SaslSockData |
| SASL authentication API -. More... | |
Macros | |
| #define | MUTT_SASL_MAXBUF 65536 |
| Maximum size for SASL protection buffer. | |
| #define | IP_PORT_BUFLEN (NI_MAXHOST + NI_MAXSERV) |
| Buffer size for "host;port" string (NI_MAXHOST + NI_MAXSERV). | |
Functions | |
| bool | sasl_auth_validator (const char *authenticator) |
| SASL callback functions, e.g. mutt_sasl_cb_authname(), mutt_sasl_cb_pass(). | |
| static int | getnameinfo_err (int rc) |
| Convert a getaddrinfo() error code into an SASL error code. | |
| static int | iptostring (const struct sockaddr *addr, socklen_t addrlen, char *out, unsigned int outlen) |
| Convert IP Address to string. | |
| static int | mutt_sasl_cb_log (void *context, int priority, const char *message) |
| Callback to log SASL messages. | |
| int | mutt_sasl_start (void) |
| Initialise SASL library. | |
| static int | mutt_sasl_cb_authname (void *context, int id, const char **result, unsigned int *len) |
| Callback to retrieve authname or user from ConnAccount. | |
| static int | mutt_sasl_cb_pass (sasl_conn_t *conn, void *context, int id, sasl_secret_t **psecret) |
| SASL callback function to get password. | |
| static sasl_callback_t * | mutt_sasl_get_callbacks (struct ConnAccount *cac) |
| Get the SASL callback functions. | |
| static int | mutt_sasl_conn_open (struct Connection *conn) |
| Empty wrapper for underlying open function - Implements Connection::open() -. | |
| static int | mutt_sasl_conn_close (struct Connection *conn) |
| Close SASL connection - Implements Connection::close() -. | |
| static int | mutt_sasl_conn_read (struct Connection *conn, char *buf, size_t count) |
| Read data from an SASL connection - Implements Connection::read() -. | |
| static int | mutt_sasl_conn_write (struct Connection *conn, const char *buf, size_t count) |
| Write to an SASL connection - Implements Connection::write() -. | |
| static int | mutt_sasl_conn_poll (struct Connection *conn, time_t wait_secs) |
| Check if any data is waiting on a socket - Implements Connection::poll() -. | |
| int | mutt_sasl_client_new (struct Connection *conn, sasl_conn_t **saslconn) |
| Wrapper for sasl_client_new(). | |
| int | mutt_sasl_interact (sasl_interact_t *interaction) |
| Perform an SASL interaction with the user. | |
| void | mutt_sasl_setup_conn (struct Connection *conn, sasl_conn_t *saslconn) |
| Set up an SASL connection. | |
| void | mutt_sasl_cleanup (void) |
| Invoke when processing is complete. | |
Variables | |
| static const char *const | SaslAuthenticators [] |
| Authentication methods supported by Cyrus SASL. | |
SASL authentication support.
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, see http://www.gnu.org/licenses/.
Definition in file sasl.c.
| #define MUTT_SASL_MAXBUF 65536 |
| #define IP_PORT_BUFLEN (NI_MAXHOST + NI_MAXSERV) |
| bool sasl_auth_validator | ( | const char * | authenticator | ) |
SASL callback functions, e.g. mutt_sasl_cb_authname(), mutt_sasl_cb_pass().
SASL secret, to store the password Validate an auth method against Cyrus SASL methods
| authenticator | Name of the authenticator to validate |
| true | Argument matches an accepted auth method |
Definition at line 133 of file sasl.c.
|
static |
Convert a getaddrinfo() error code into an SASL error code.
| rc | getaddrinfo() error code, e.g. EAI_AGAIN |
| num | SASL error code, e.g. SASL_FAIL |
Definition at line 150 of file sasl.c.
|
static |
Convert IP Address to string.
| addr | IP address |
| addrlen | Size of addr struct |
| out | Buffer for result |
| outlen | Length of buffer |
| num | SASL error code, e.g. SASL_BADPARAM |
utility function, copied from sasl2 sample code
Definition at line 204 of file sasl.c.
|
static |
Callback to log SASL messages.
| context | Supplied context, always NULL |
| priority | Debug level |
| message | Message |
| num | SASL_OK, always |
Definition at line 238 of file sasl.c.
| int mutt_sasl_start | ( | void | ) |
Initialise SASL library.
| num | SASL error code, e.g. SASL_OK |
Call before doing an SASL exchange (initialises library if necessary).
Definition at line 275 of file sasl.c.
|
static |
Callback to retrieve authname or user from ConnAccount.
| [in] | context | ConnAccount |
| [in] | id | Field to get. SASL_CB_USER or SASL_CB_AUTHNAME |
| [out] | result | Resulting string |
| [out] | len | Length of result |
| num | SASL error code, e.g. SASL_FAIL |
Definition at line 315 of file sasl.c.
|
static |
SASL callback function to get password.
| [in] | conn | Connection to a server |
| [in] | context | ConnAccount |
| [in] | id | SASL_CB_PASS |
| [out] | psecret | SASL secret |
| num | SASL error code, e.g SASL_FAIL |
Definition at line 359 of file sasl.c.
|
static |
Get the SASL callback functions.
| cac | ConnAccount to associate with callbacks |
| ptr | Array of callback functions |
Definition at line 390 of file sasl.c.
| int mutt_sasl_client_new | ( | struct Connection * | conn, |
| sasl_conn_t ** | saslconn ) |
Wrapper for sasl_client_new().
| [in] | conn | Connection to a server |
| [out] | saslconn | SASL connection |
| 0 | Success |
| -1 | Error |
which also sets various security properties. If this turns out to be fine for POP too we can probably stop exporting mutt_sasl_get_callbacks().
Definition at line 612 of file sasl.c.
| int mutt_sasl_interact | ( | sasl_interact_t * | interaction | ) |
Perform an SASL interaction with the user.
| interaction | Details of interaction |
| num | SASL error code: SASL_OK or SASL_FAIL |
An example interaction might be asking the user for a password.
Definition at line 710 of file sasl.c.
| void mutt_sasl_setup_conn | ( | struct Connection * | conn, |
| sasl_conn_t * | saslconn ) |
Set up an SASL connection.
| conn | Connection to a server |
| saslconn | SASL connection |
Replace connection methods, sockdata with SASL wrappers, for protection layers. Also get ssf, as a fastpath for the read/write methods.
Definition at line 746 of file sasl.c.
| void mutt_sasl_cleanup | ( | void | ) |
Invoke when processing is complete.
This is a cleanup function, used to free all memory used by the library. Invoke when processing is complete.
Definition at line 791 of file sasl.c.
|
static |
Authentication methods supported by Cyrus SASL.
Definition at line 107 of file sasl.c.