jabberd2
2.2.16
|
#include "sx.h"
#include "sasl.h"
#include <sasl/sasl.h>
#include <sasl/saslutil.h>
#include <sasl/saslplug.h>
Go to the source code of this file.
Data Structures | |
struct | _sx_sasl_st |
our context More... | |
struct | _sx_sasl_data_st |
Typedefs | |
typedef struct _sx_sasl_st * | _sx_sasl_t |
our context | |
typedef struct _sx_sasl_data_st * | _sx_sasl_data_t |
Functions | |
static void | _sx_sasl_free (sx_t s, sx_plugin_t p) |
cleanup | |
static int | _sx_sasl_getopt (void *glob_context, const char *plugin_name, const char *option, const char **result, unsigned *len) |
static void | _sx_auxprop_lookup (void *glob_context, sasl_server_params_t *sparams, unsigned flags, const char *user, unsigned ulen) |
static int | sx_auxprop_init (const sasl_utils_t *utils, int max_version, int *out_version, sasl_auxprop_plug_t **plug, const char *plugname) |
static int | _sx_sasl_checkpass (sasl_conn_t *conn, void *ctx, const char *user, const char *pass, unsigned passlen, struct propctx *propctx) |
static int | _sx_sasl_canon_user (sasl_conn_t *conn, void *ctx, const char *user, unsigned ulen, unsigned flags, const char *user_realm, char *out_user, unsigned out_umax, unsigned *out_ulen) |
static int | _sx_sasl_proxy_policy (sasl_conn_t *conn, void *ctx, const char *requested_user, int rlen, const char *auth_identity, int alen, const char *realm, int urlen, struct propctx *propctx) |
static int | _sx_sasl_wio (sx_t s, sx_plugin_t p, sx_buf_t buf) |
static int | _sx_sasl_rio (sx_t s, sx_plugin_t p, sx_buf_t buf) |
void | _sx_sasl_open (sx_t s, sasl_conn_t *sasl) |
move the stream to the auth state | |
static void | _sx_sasl_stream (sx_t s, sx_plugin_t p) |
make the stream authenticated second time round | |
static void | _sx_sasl_features (sx_t s, sx_plugin_t p, nad_t nad) |
static nad_t | _sx_sasl_success (sx_t s) |
utility: generate a success nad | |
static nad_t | _sx_sasl_failure (sx_t s, const char *err) |
utility: generate a failure nad | |
static nad_t | _sx_sasl_challenge (sx_t s, char *data, int dlen) |
utility: generate a challenge nad | |
static nad_t | _sx_sasl_response (sx_t s, char *data, int dlen) |
utility: generate a response nad | |
static nad_t | _sx_sasl_abort (sx_t s) |
utility: generate an abort nad | |
static void | _sx_sasl_decode (char *in, int inlen, char **out, int *outlen) |
utility: decode incoming handshake data | |
static void | _sx_sasl_encode (char *in, int inlen, char **out, int *outlen) |
utility: encode outgoing handshake data | |
static void | _sx_sasl_notify_success (sx_t s, void *arg) |
auth done, restart the stream | |
static void | _sx_sasl_client_process (sx_t s, sx_plugin_t p, char *mech, char *in, int inlen) |
process handshake packets from the client | |
static void | _sx_sasl_server_process (sx_t s, sx_plugin_t p, char *in, int inlen) |
process handshake packets from the server | |
static int | _sx_sasl_process (sx_t s, sx_plugin_t p, nad_t nad) |
main nad processor | |
static void | _sx_sasl_unload (sx_plugin_t p) |
int | sx_sasl_init (sx_env_t env, sx_plugin_t p, va_list args) |
args: appname, callback, cb arg | |
static int | _sx_sasl_cb_get_simple (void *ctx, int id, const char **result, unsigned *len) |
static int | _sx_sasl_cb_get_secret (sasl_conn_t *conn, void *ctx, int id, sasl_secret_t **psecret) |
int | sx_sasl_auth (sx_plugin_t p, sx_t s, char *appname, char *mech, char *user, char *pass) |
kick off the auth handshake | |
Variables | |
static sasl_auxprop_plug_t | _sx_auxprop_plugin |
typedef struct _sx_sasl_st * _sx_sasl_t |
our context
typedef struct _sx_sasl_data_st * _sx_sasl_data_t |
static void _sx_sasl_free | ( | sx_t | s, |
sx_plugin_t | p | ||
) | [static] |
cleanup
Definition at line 1000 of file sasl_cyrus.c.
References _sx_st::plugin_data, _sx_plugin_st::index, _sx_debug, ZONE, _sx_sasl_data_st::sasl, _sx_sasl_data_st::user, _sx_sasl_data_st::psecret, and _sx_sasl_data_st::callbacks.
Referenced by _sx_sasl_features(), _sx_sasl_process(), and sx_sasl_init().
static int _sx_sasl_getopt | ( | void * | glob_context, |
const char * | plugin_name, | ||
const char * | option, | ||
const char ** | result, | ||
unsigned * | len | ||
) | [static] |
Definition at line 69 of file sasl_cyrus.c.
Referenced by sx_sasl_init().
static void _sx_auxprop_lookup | ( | void * | glob_context, |
sasl_server_params_t * | sparams, | ||
unsigned | flags, | ||
const char * | user, | ||
unsigned | ulen | ||
) | [static] |
Definition at line 111 of file sasl_cyrus.c.
References sx_sasl_creds_st::authnid, sx_sasl_creds_st::realm, _sx_sasl_st::cb, sx_sasl_cb_GET_PASS, _sx_sasl_st::cbarg, and sx_sasl_ret_OK.
static int sx_auxprop_init | ( | const sasl_utils_t * | utils, |
int | max_version, | ||
int * | out_version, | ||
sasl_auxprop_plug_t ** | plug, | ||
const char * | plugname | ||
) | [static] |
Definition at line 180 of file sasl_cyrus.c.
References _sx_auxprop_plugin.
Referenced by sx_sasl_init().
static int _sx_sasl_checkpass | ( | sasl_conn_t * | conn, |
void * | ctx, | ||
const char * | user, | ||
const char * | pass, | ||
unsigned | passlen, | ||
struct propctx * | propctx | ||
) | [static] |
Definition at line 198 of file sasl_cyrus.c.
References sx_sasl_creds_st::realm, sx_sasl_creds_st::authnid, sx_sasl_creds_st::pass, _sx_sasl_data_st::ctx, _sx_sasl_st::cb, sx_sasl_cb_CHECK_PASS, _sx_sasl_data_st::stream, _sx_sasl_st::cbarg, and sx_sasl_ret_OK.
Referenced by _sx_sasl_stream().
static int _sx_sasl_canon_user | ( | sasl_conn_t * | conn, |
void * | ctx, | ||
const char * | user, | ||
unsigned | ulen, | ||
unsigned | flags, | ||
const char * | user_realm, | ||
char * | out_user, | ||
unsigned | out_umax, | ||
unsigned * | out_ulen | ||
) | [static] |
Definition at line 232 of file sasl_cyrus.c.
References _sx_sasl_data_st::ctx, _sx_sasl_st::cb, sx_sasl_cb_GEN_AUTHZID, _sx_sasl_data_st::stream, and _sx_sasl_st::cbarg.
Referenced by _sx_sasl_stream().
static int _sx_sasl_proxy_policy | ( | sasl_conn_t * | conn, |
void * | ctx, | ||
const char * | requested_user, | ||
int | rlen, | ||
const char * | auth_identity, | ||
int | alen, | ||
const char * | realm, | ||
int | urlen, | ||
struct propctx * | propctx | ||
) | [static] |
Definition at line 252 of file sasl_cyrus.c.
References sx_sasl_creds_st::realm, sx_sasl_creds_st::authnid, _sx_sasl_data_st::stream, _sx_st::req_to, sx_sasl_creds_st::authzid, _sx_sasl_data_st::ctx, _sx_sasl_st::cb, sx_sasl_cb_CHECK_AUTHZID, _sx_sasl_st::cbarg, and sx_sasl_ret_OK.
Referenced by _sx_sasl_stream().
static int _sx_sasl_wio | ( | sx_t | s, |
sx_plugin_t | p, | ||
sx_buf_t | buf | ||
) | [static] |
Definition at line 340 of file sasl_cyrus.c.
References _sx_st::plugin_data, _sx_plugin_st::index, _sx_debug, ZONE, _sx_buf_st::len, _sx_buf_st::data, and _sx_buffer_set().
Referenced by sx_sasl_init().
static int _sx_sasl_rio | ( | sx_t | s, |
sx_plugin_t | p, | ||
sx_buf_t | buf | ||
) | [static] |
Definition at line 382 of file sasl_cyrus.c.
References _sx_st::plugin_data, _sx_plugin_st::index, _sx_debug, ZONE, _sx_buf_st::data, _sx_buf_st::len, _sx_gen_error, SX_ERR_AUTH, _sx_event, event_ERROR, and _sx_buffer_set().
Referenced by sx_sasl_init().
void _sx_sasl_open | ( | sx_t | s, |
sasl_conn_t * | sasl | ||
) |
move the stream to the auth state
Definition at line 415 of file sasl_cyrus.c.
References sx_sasl_creds_st::authzid, _sx_st::ssf, _sx_st::type, type_SERVER, _sx_st::req_to, and sx_auth().
Referenced by _sx_sasl_stream().
static void _sx_sasl_stream | ( | sx_t | s, |
sx_plugin_t | p | ||
) | [static] |
make the stream authenticated second time round
Definition at line 471 of file sasl_cyrus.c.
References _sx_plugin_st::private, sx_sasl_creds_st::realm, _sx_st::plugin_data, _sx_plugin_st::index, _sx_st::type, type_SERVER, _sx_st::flags, SX_SASL_OFFER, _sx_debug, ZONE, _sx_sasl_st::cb, sx_sasl_cb_GET_REALM, _sx_sasl_st::cbarg, _sx_sasl_proxy_policy(), _sx_sasl_canon_user(), _sx_sasl_checkpass(), _sx_sasl_st::appname, _sx_sasl_st::sec_props, SX_SSL_MAGIC, and _sx_sasl_open().
Referenced by sx_sasl_init().
static void _sx_sasl_features | ( | sx_t | s, |
sx_plugin_t | p, | ||
nad_t | nad | ||
) | [static] |
Definition at line 583 of file sasl_cyrus.c.
References _sx_st::plugin_data, _sx_plugin_st::index, _sx_st::type, type_SERVER, _sx_sasl_data_st::sasl, _sx_debug, ZONE, _sx_st::flags, SX_SASL_OFFER, SX_SSL_STARTTLS_REQUIRE, _sx_st::ssf, _sx_sasl_free(), _sx_sasl_data_st::ctx, _sx_sasl_st::cb, sx_sasl_cb_CHECK_MECH, _sx_sasl_data_st::stream, _sx_sasl_st::cbarg, sx_sasl_ret_OK, nad_add_namespace(), uri_SASL, nad_append_elem(), and nad_append_cdata().
Referenced by sx_sasl_init().
utility: generate a success nad
Definition at line 650 of file sasl_cyrus.c.
References nad_new(), nad_add_namespace(), uri_SASL, and nad_append_elem().
Referenced by _sx_sasl_client_process().
utility: generate a failure nad
Definition at line 663 of file sasl_cyrus.c.
References nad_new(), nad_add_namespace(), uri_SASL, and nad_append_elem().
Referenced by _sx_sasl_client_process(), and _sx_sasl_process().
utility: generate a challenge nad
Definition at line 678 of file sasl_cyrus.c.
References nad_new(), nad_add_namespace(), uri_SASL, nad_append_elem(), and nad_append_cdata().
Referenced by _sx_sasl_client_process().
utility: generate a response nad
Definition at line 693 of file sasl_cyrus.c.
References nad_new(), nad_add_namespace(), uri_SASL, nad_append_elem(), and nad_append_cdata().
Referenced by _sx_sasl_server_process().
utility: generate an abort nad
Definition at line 708 of file sasl_cyrus.c.
References nad_new(), nad_add_namespace(), uri_SASL, and nad_append_elem().
Referenced by _sx_sasl_server_process().
static void _sx_sasl_decode | ( | char * | in, |
int | inlen, | ||
char ** | out, | ||
int * | outlen | ||
) | [static] |
utility: decode incoming handshake data
Definition at line 721 of file sasl_cyrus.c.
Referenced by _sx_sasl_client_process(), and _sx_sasl_server_process().
static void _sx_sasl_encode | ( | char * | in, |
int | inlen, | ||
char ** | out, | ||
int * | outlen | ||
) | [static] |
utility: encode outgoing handshake data
Definition at line 727 of file sasl_cyrus.c.
Referenced by _sx_sasl_client_process(), and _sx_sasl_server_process().
static void _sx_sasl_notify_success | ( | sx_t | s, |
void * | arg | ||
) | [static] |
auth done, restart the stream
Definition at line 733 of file sasl_cyrus.c.
References _sx_chain_io_plugin(), _sx_debug, ZONE, _sx_reset(), sx_server_init(), and _sx_st::flags.
Referenced by _sx_sasl_client_process().
static void _sx_sasl_client_process | ( | sx_t | s, |
sx_plugin_t | p, | ||
char * | mech, | ||
char * | in, | ||
int | inlen | ||
) | [static] |
process handshake packets from the client
Definition at line 745 of file sasl_cyrus.c.
References _sx_st::plugin_data, _sx_plugin_st::index, _sx_sasl_decode(), _sx_debug, ZONE, _sx_sasl_data_st::sasl, _sx_nad_write(), _sx_sasl_failure(), _sasl_err_MECH_TOO_WEAK, _sx_sasl_success(), _sx_st::wbufq, _jqueue_st::front, _jqueue_node_st::data, _sx_sasl_notify_success(), _sx_sasl_encode(), _sx_sasl_challenge(), and _sasl_err_MALFORMED_REQUEST.
Referenced by _sx_sasl_process().
static void _sx_sasl_server_process | ( | sx_t | s, |
sx_plugin_t | p, | ||
char * | in, | ||
int | inlen | ||
) | [static] |
process handshake packets from the server
Definition at line 813 of file sasl_cyrus.c.
References _sx_st::plugin_data, _sx_plugin_st::index, _sx_debug, ZONE, _sx_sasl_decode(), _sx_sasl_data_st::sasl, _sx_sasl_encode(), _sx_nad_write(), _sx_sasl_response(), and _sx_sasl_abort().
Referenced by _sx_sasl_process().
static int _sx_sasl_process | ( | sx_t | s, |
sx_plugin_t | p, | ||
nad_t | nad | ||
) | [static] |
main nad processor
Definition at line 853 of file sasl_cyrus.c.
References _sx_st::plugin_data, _sx_plugin_st::index, NAD_ENS, NAD_NURI_L, uri_SASL, NAD_NURI, _sx_st::state, state_STREAM, _sx_debug, ZONE, nad_free(), _sx_st::type, type_SERVER, _sx_st::flags, SX_SASL_OFFER, SX_SSL_STARTTLS_REQUIRE, _sx_st::ssf, NAD_ENAME_L, NAD_ENAME, nad_find_attr(), _sx_nad_write(), _sx_sasl_failure(), _sasl_err_INVALID_MECHANISM, NAD_AVAL_L, NAD_AVAL, _sx_sasl_client_process(), NAD_CDATA, NAD_CDATA_L, _sasl_err_ABORTED, type_CLIENT, _sx_sasl_server_process(), _sx_st::ns, _sx_st::req_to, _sx_st::req_from, _sx_st::req_version, _sx_chain_io_plugin(), _sx_reset(), sx_client_init(), _sx_gen_error, SX_ERR_AUTH, _sx_event, event_ERROR, and _sx_sasl_free().
Referenced by sx_sasl_init().
static void _sx_sasl_unload | ( | sx_plugin_t | p | ) | [static] |
Definition at line 1018 of file sasl_cyrus.c.
References _sx_plugin_st::private, _sx_sasl_st::appname, and _sx_sasl_st::saslcallbacks.
Referenced by sx_sasl_init().
int sx_sasl_init | ( | sx_env_t | env, |
sx_plugin_t | p, | ||
va_list | args | ||
) |
args: appname, callback, cb arg
init function
Definition at line 1030 of file sasl_cyrus.c.
References _sx_debug, ZONE, sx_auxprop_init(), _sx_sasl_st::sec_props, _sx_sasl_st::appname, _sx_sasl_st::cb, _sx_sasl_st::cbarg, _sx_sasl_st::saslcallbacks, _sx_sasl_getopt(), _sx_plugin_st::private, _sx_plugin_st::unload, _sx_sasl_unload(), _sx_plugin_st::wio, _sx_sasl_wio(), _sx_plugin_st::rio, _sx_sasl_rio(), _sx_plugin_st::stream, _sx_sasl_stream(), _sx_plugin_st::features, _sx_sasl_features(), _sx_plugin_st::process, _sx_sasl_process(), _sx_plugin_st::free, and _sx_sasl_free().
static int _sx_sasl_cb_get_simple | ( | void * | ctx, |
int | id, | ||
const char ** | result, | ||
unsigned * | len | ||
) | [static] |
Definition at line 1112 of file sasl_cyrus.c.
References _sx_debug, ZONE, and _sx_sasl_data_st::user.
static int _sx_sasl_cb_get_secret | ( | sasl_conn_t * | conn, |
void * | ctx, | ||
int | id, | ||
sasl_secret_t ** | psecret | ||
) | [static] |
Definition at line 1125 of file sasl_cyrus.c.
References _sx_debug, ZONE, and _sx_sasl_data_st::psecret.
int sx_sasl_auth | ( | sx_plugin_t | p, |
sx_t | s, | ||
char * | appname, | ||
char * | mech, | ||
char * | user, | ||
char * | pass | ||
) |
kick off the auth handshake
trigger for client auth
Definition at line 1141 of file sasl_cyrus.c.
References _sx_plugin_st::private.
sasl_auxprop_plug_t _sx_auxprop_plugin [static] |
{0, 0, NULL, NULL, _sx_auxprop_lookup, "jabberdsx", NULL}
Definition at line 176 of file sasl_cyrus.c.
Referenced by sx_auxprop_init().