X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Frlm_yubikey%2Fvalidate.c;fp=src%2Fmodules%2Frlm_yubikey%2Fvalidate.c;h=80930219c141834f5585cb77c60e7416a068b129;hb=14a87b81409ef1b07f589b05f013b4e2356b75a3;hp=67b0d7d933cf027384277411687460aefcab343d;hpb=4ca09576d948b5b74d83a3d981a3b121b87bae20;p=freeradius.git diff --git a/src/modules/rlm_yubikey/validate.c b/src/modules/rlm_yubikey/validate.c index 67b0d7d..8093021 100644 --- a/src/modules/rlm_yubikey/validate.c +++ b/src/modules/rlm_yubikey/validate.c @@ -12,26 +12,33 @@ #ifdef HAVE_YKCLIENT #include +/** Frees a ykclient handle + * + * @param[in] yandle rlm_yubikey_handle_t to close and free. + * @return returns 0. + */ +static int _mod_conn_free(ykclient_handle_t **yandle) +{ + ykclient_handle_done(yandle); + + return 0; +} + /** Creates a new connection handle for use by the FR connection API. * * Matches the fr_connection_create_t function prototype, is passed to * fr_connection_pool_init, and called when a new connection is required by the * connection pool API. * - * @see mod_conn_delete * @see fr_connection_pool_init * @see fr_connection_create_t * @see connection.c - * - * @param[in] instance configuration data. - * @return connection handle or NULL if the connection failed or couldn't - * be initialised. */ -static void *mod_socket_create(void *instance) +static void *mod_conn_create(TALLOC_CTX *ctx, void *instance) { rlm_yubikey_t *inst = instance; ykclient_rc status; - ykclient_handle_t *yandle; + ykclient_handle_t *yandle, **marker; status = ykclient_handle_init(inst->ykc, &yandle); if (status != YKCLIENT_OK) { @@ -39,25 +46,13 @@ static void *mod_socket_create(void *instance) return NULL; } + marker = talloc(ctx, ykclient_handle_t *); + talloc_set_destructor(marker, _mod_conn_free); + *marker = yandle; return yandle; } -/** Frees a ykclient handle - * - * @param[in] instance configuration data. - * @param[in] handle rlm_yubikey_handle_t to close and free. - * @return returns true. - */ -static int mod_socket_delete(UNUSED void *instance, void *handle) -{ - ykclient_handle_t *yandle = handle; - - ykclient_handle_done(&yandle); - - return true; -} - int rlm_yubikey_ykclient_init(CONF_SECTION *conf, rlm_yubikey_t *inst) { ykclient_rc status; @@ -137,7 +132,7 @@ init: } snprintf(prefix, sizeof(prefix), "rlm_yubikey (%s)", inst->name); - inst->conn_pool = fr_connection_pool_init(conf, inst, mod_socket_create, NULL, mod_socket_delete, prefix); + inst->conn_pool = fr_connection_pool_init(conf, inst, mod_conn_create, NULL, prefix); if (!inst->conn_pool) { ykclient_done(&inst->ykc);