-fix FTBFS in taler-exchange-httpd_kyc.c

This commit is contained in:
Christian Grothoff 2022-08-04 12:52:30 +02:00
parent 61f39f0941
commit c78331b6c2
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 71 additions and 50 deletions

View File

@ -132,6 +132,7 @@ taler_exchange_httpd_SOURCES = \
taler-exchange-httpd_deposits_get.c taler-exchange-httpd_deposits_get.h \ taler-exchange-httpd_deposits_get.c taler-exchange-httpd_deposits_get.h \
taler-exchange-httpd_extensions.c taler-exchange-httpd_extensions.h \ taler-exchange-httpd_extensions.c taler-exchange-httpd_extensions.h \
taler-exchange-httpd_keys.c taler-exchange-httpd_keys.h \ taler-exchange-httpd_keys.c taler-exchange-httpd_keys.h \
taler-exchange-httpd_kyc.c taler-exchange-httpd_kyc.h \
taler-exchange-httpd_kyc-check.c taler-exchange-httpd_kyc-check.h \ taler-exchange-httpd_kyc-check.c taler-exchange-httpd_kyc-check.h \
taler-exchange-httpd_kyc-proof.c taler-exchange-httpd_kyc-proof.h \ taler-exchange-httpd_kyc-proof.c taler-exchange-httpd_kyc-proof.h \
taler-exchange-httpd_kyc-wallet.c taler-exchange-httpd_kyc-wallet.h \ taler-exchange-httpd_kyc-wallet.c taler-exchange-httpd_kyc-wallet.h \

View File

@ -19,7 +19,9 @@
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#include "platform.h" #include "platform.h"
#include "taler-exchange-httpd.h"
#include "taler-exchange-httpd_kyc.h" #include "taler-exchange-httpd_kyc.h"
#include "taler_exchangedb_plugin.h"
/** /**
* Information about a KYC provider. * Information about a KYC provider.
@ -40,7 +42,7 @@ struct TEH_KycCheck
/** /**
* Array of @e num_providers providers that offer this type of KYC check. * Array of @e num_providers providers that offer this type of KYC check.
*/ */
struct TEH_KycProvider *providers; struct TEH_KycProvider **providers;
/** /**
* Length of the @e providers array. * Length of the @e providers array.
@ -65,13 +67,13 @@ struct TEH_KycProvider
/** /**
* Logic to run for this provider. * Logic to run for this provider.
*/ */
struct TEH_KYCLOGIC_Plugin *logic; struct TALER_KYCLOGIC_Plugin *logic;
/** /**
* @e provider_section_name specific details to * @e provider_section_name specific details to
* pass to the @e logic functions. * pass to the @e logic functions.
*/ */
struct TEH_KYCLOGIC_ProviderDetails *pd; struct TALER_KYCLOGIC_ProviderDetails *pd;
/** /**
* Cost of running this provider's KYC. * Cost of running this provider's KYC.
@ -130,12 +132,12 @@ struct TEH_KycTrigger
/** /**
* Array of @e num_kyc_logics KYC logic plugins we have loaded. * Array of @e num_kyc_logics KYC logic plugins we have loaded.
*/ */
static struct TEH_KYCLOGIC_Plugin **kyc_logics; static struct TALER_KYCLOGIC_Plugin **kyc_logics;
/** /**
* Length of the #kyc_logics array. * Length of the #kyc_logics array.
*/ */
static unsigned in num_kyc_logics; static unsigned int num_kyc_logics;
/** /**
* Array of @e num_kyc_checks known types of * Array of @e num_kyc_checks known types of
@ -267,11 +269,22 @@ TEH_kyc_user_type2s (enum TEH_KycUserType ut)
* @param name name of the plugin * @param name name of the plugin
* @return NULL on error * @return NULL on error
*/ */
static struct TEH_KYCLOGIC_Plugin * static struct TALER_KYCLOGIC_Plugin *
load_logic (const char *name) load_logic (const char *name)
{ {
GNUNET_break (0); char *lib_name;
return NULL; struct TALER_KYCLOGIC_Plugin *plugin;
GNUNET_asprintf (&lib_name,
"libtaler_plugin_kyclogic_%s",
name);
plugin = GNUNET_PLUGIN_load (lib_name,
(void *) TEH_cfg);
if (NULL != plugin)
plugin->library_name = lib_name;
else
GNUNET_free (lib_name);
return plugin;
} }
@ -312,16 +325,16 @@ add_check (const char *check)
*/ */
static void static void
add_checks (char *checks, add_checks (char *checks,
struct TEH_KycCheck **p_checks, struct TEH_KycCheck ***p_checks,
unsigned int *num_p_checks) unsigned int *num_p_checks)
{ {
char *sptr; char *sptr;
struct TEH_KycCheck *rchecks = NULL; struct TEH_KycCheck **rchecks = NULL;
unsigned int num_rchecks = 0; unsigned int num_rchecks = 0;
for (char *tok = strtok_r (checks, " ", &sptr); for (char *tok = strtok_r (checks, " ", &sptr);
NULL != tok; NULL != tok;
tok = strtok_r (checks, NULL, &sptr)) tok = strtok_r (NULL, " ", &sptr))
{ {
struct TEH_KycCheck *kc; struct TEH_KycCheck *kc;
@ -348,6 +361,7 @@ add_provider (const char *section)
char *ut_s; char *ut_s;
enum TEH_KycUserType ut; enum TEH_KycUserType ut;
char *checks; char *checks;
struct TALER_KYCLOGIC_Plugin *lp;
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (TEH_cfg, GNUNET_CONFIGURATION_get_value_number (TEH_cfg,
@ -429,7 +443,7 @@ add_provider (const char *section)
&kp->provided_checks, &kp->provided_checks,
&kp->num_checks); &kp->num_checks);
GNUNET_free (checks); GNUNET_free (checks);
kp->pd = lp->load (lp->cls, kp->pd = lp->load_configuration (lp->cls,
section); section);
if (NULL == kp->pd) if (NULL == kp->pd)
{ {
@ -462,7 +476,7 @@ add_trigger (const char *section)
enum TEH_KycTriggerEvent ot; enum TEH_KycTriggerEvent ot;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_CONFIGURATION_get_value_amount (TEH_cfg, TALER_config_get_amount (TEH_cfg,
section, section,
"THRESHOLD", "THRESHOLD",
&threshold)) &threshold))
@ -539,8 +553,8 @@ add_trigger (const char *section)
&kt->required_checks, &kt->required_checks,
&kt->num_checks); &kt->num_checks);
GNUNET_free (checks); GNUNET_free (checks);
GNUNET_array_append (kyc_checks, GNUNET_array_append (kyc_triggers,
num_kyc_checks, num_kyc_triggers,
kt); kt);
} }
return GNUNET_OK; return GNUNET_OK;
@ -589,11 +603,11 @@ handle_section (void *cls,
* @return -1 if p1 < p2, 0 if p1==p2, 1 if p1 > p2. * @return -1 if p1 < p2, 0 if p1==p2, 1 if p1 > p2.
*/ */
static int static int
sort_by_timeframe (void *p1, sort_by_timeframe (const void *p1,
void *p2) const void *p2)
{ {
struct TEH_KycTrigger **t1 = p1; struct TEH_KycTrigger **t1 = (struct TEH_KycTrigger **) p1;
struct TEH_KycTrigger **t2 = p2; struct TEH_KycTrigger **t2 = (struct TEH_KycTrigger **) p2;
if (GNUNET_TIME_relative_cmp ((*t1)->timeframe, if (GNUNET_TIME_relative_cmp ((*t1)->timeframe,
<, <,
@ -610,7 +624,7 @@ sort_by_timeframe (void *p1,
enum GNUNET_GenericReturnValue enum GNUNET_GenericReturnValue
TEH_kyc_init (void) TEH_kyc_init (void)
{ {
book ok = true; bool ok = true;
GNUNET_CONFIGURATION_iterate_sections (TEH_cfg, GNUNET_CONFIGURATION_iterate_sections (TEH_cfg,
&handle_section, &handle_section,
@ -659,7 +673,7 @@ TEH_kyc_done (void)
{ {
struct TEH_KycProvider *kp = kyc_providers[i]; struct TEH_KycProvider *kp = kyc_providers[i];
kp->logic->unload (kp->pd); kp->logic->unload_configuration (kp->pd);
GNUNET_array_grow (kp->provided_checks, GNUNET_array_grow (kp->provided_checks,
kp->num_checks, kp->num_checks,
0); 0);
@ -670,9 +684,12 @@ TEH_kyc_done (void)
0); 0);
for (unsigned int i = 0; i<num_kyc_logics; i++) for (unsigned int i = 0; i<num_kyc_logics; i++)
{ {
struct TEH_KYCLOGIC_Plugin *lp = kyc_logics[i]; struct TALER_KYCLOGIC_Plugin *lp = kyc_logics[i];
char *lib_name = lp->library_name;
unload_plugin (lp); GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name,
lp));
GNUNET_free (lib_name);
} }
GNUNET_array_grow (kyc_logics, GNUNET_array_grow (kyc_logics,
num_kyc_logics, num_kyc_logics,
@ -759,9 +776,9 @@ eval_trigger (void *cls,
{ {
const struct TEH_KycTrigger *kt = kyc_triggers[i]; const struct TEH_KycTrigger *kt = kyc_triggers[i];
if (event != kt->trigger) if (ttc->event != kt->trigger)
continue; continue;
timeframe = GNUNET_TIME_relative_max (timeframe, duration = GNUNET_TIME_relative_max (duration,
kt->timeframe); kt->timeframe);
if (GNUNET_TIME_relative_cmp (kt->timeframe, if (GNUNET_TIME_relative_cmp (kt->timeframe,
>, >,
@ -769,7 +786,7 @@ eval_trigger (void *cls,
{ {
if (bump) if (bump)
ttc->start = i; ttc->start = i;
return; return GNUNET_OK;
} }
if (-1 == if (-1 ==
TALER_amount_cmp (&ttc->total, TALER_amount_cmp (&ttc->total,
@ -868,7 +885,7 @@ const char *
TEH_kyc_test_required (enum TEH_KycTriggerEvent event, TEH_kyc_test_required (enum TEH_KycTriggerEvent event,
const struct TALER_PaytoHashP *h_payto, const struct TALER_PaytoHashP *h_payto,
TEH_KycAmountIterator ai, TEH_KycAmountIterator ai,
void *cls) void *ai_cls)
{ {
struct TEH_KycCheck *needed[num_kyc_checks]; struct TEH_KycCheck *needed[num_kyc_checks];
unsigned int needed_cnt = 0; unsigned int needed_cnt = 0;
@ -977,8 +994,8 @@ TEH_kyc_test_required (enum TEH_KycTriggerEvent event,
enum GNUNET_GenericReturnValue enum GNUNET_GenericReturnValue
TEH_kyc_get_logic (const char *provider_section_name, TEH_kyc_get_logic (const char *provider_section_name,
struct TEH_KYCLOGIC_Plugin **plugin, struct TALER_KYCLOGIC_Plugin **plugin,
struct TEH_KYCLOGIC_ProviderDetails **pd) struct TALER_KYCLOGIC_ProviderDetails **pd)
{ {
for (unsigned int i = 0; i<num_kyc_providers; i++) for (unsigned int i = 0; i<num_kyc_providers; i++)
{ {

View File

@ -150,7 +150,7 @@ TEH_kyc_done (void);
* #GNUNET_NO to abort iteration * #GNUNET_NO to abort iteration
* #GNUNET_SYSERR on internal error (also abort itaration) * #GNUNET_SYSERR on internal error (also abort itaration)
*/ */
enum GNUNET_GenericReturnValue typedef enum GNUNET_GenericReturnValue
(*TEH_KycAmountCallback)(void *cls, (*TEH_KycAmountCallback)(void *cls,
const struct TALER_Amount *amount, const struct TALER_Amount *amount,
struct GNUNET_TIME_Absolute date); struct GNUNET_TIME_Absolute date);
@ -171,7 +171,7 @@ enum GNUNET_GenericReturnValue
* order * order
* @param cb_cls closure for @a cb * @param cb_cls closure for @a cb
*/ */
void typedef void
(*TEH_KycAmountIterator)(void *cls, (*TEH_KycAmountIterator)(void *cls,
struct GNUNET_TIME_Absolute limit, struct GNUNET_TIME_Absolute limit,
TEH_KycAmountCallback cb, TEH_KycAmountCallback cb,
@ -192,14 +192,14 @@ void
* @param ai callback offered to inquire about historic * @param ai callback offered to inquire about historic
* amounts involved in this type of operation * amounts involved in this type of operation
* at the given account * at the given account
* @param cls closure for @a pi and @a ai * @param ai_cls closure for @a ai
* @return NULL if no check is needed * @return NULL if no check is needed
*/ */
const char * const char *
TEH_kyc_test_required (enum TEH_KycTriggerEvent event, TEH_kyc_test_required (enum TEH_KycTriggerEvent event,
const struct TALER_PaytoHashP *h_payto, const struct TALER_PaytoHashP *h_payto,
TEH_KycAmountIterator ai, TEH_KycAmountIterator ai,
void *cls); void *ai_cls);
/** /**
@ -212,8 +212,8 @@ TEH_kyc_test_required (enum TEH_KycTriggerEvent event,
*/ */
enum GNUNET_GenericReturnValue enum GNUNET_GenericReturnValue
TEH_kyc_get_logic (const char *provider_section_name, TEH_kyc_get_logic (const char *provider_section_name,
struct TEH_KYCLOGIC_Plugin **plugin, struct TALER_KYCLOGIC_Plugin **plugin,
struct TEH_KYCLOGIC_ProviderDetails **pd); struct TALER_KYCLOGIC_ProviderDetails **pd);
#endif #endif

View File

@ -23,18 +23,19 @@
#include <jansson.h> #include <jansson.h>
#include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_util_lib.h>
#include "taler_util.h"
/** /**
* Plugin-internal specification of the configuration * Plugin-internal specification of the configuration
* of the plugin for a given KYC provider. * of the plugin for a given KYC provider.
*/ */
struct TEH_KYCLOGIC_ProviderDetails; struct TALER_KYCLOGIC_ProviderDetails;
/** /**
* Handle for an initiation operation. * Handle for an initiation operation.
*/ */
struct TEH_KYCLOGIC_InitiateHandle; struct TALER_KYCLOGIC_InitiateHandle;
/** /**
@ -48,7 +49,7 @@ struct TEH_KYCLOGIC_InitiateHandle;
* @param error_msg_hint set to additional details to return to user, NULL on success * @param error_msg_hint set to additional details to return to user, NULL on success
*/ */
typedef void typedef void
(*TEH_KYCLOGIC_InitiateCallback)( (*TALER_KYCLOGIC_InitiateCallback)(
enum TALER_ErrorCode ec, enum TALER_ErrorCode ec,
const char *redirect_url, const char *redirect_url,
const char *provider_user_id, const char *provider_user_id,
@ -77,11 +78,13 @@ struct TALER_KYCLOGIC_Plugin
/** /**
* Load the configuration of the KYC provider. * Load the configuration of the KYC provider.
* *
* @param cls closure
* @param provider_section_name configuration section to parse * @param provider_section_name configuration section to parse
* @return NULL if configuration is invalid * @return NULL if configuration is invalid
*/ */
struct TEH_KYCLOGIC_ProviderDetails * struct TALER_KYCLOGIC_ProviderDetails *
(*load_configuration)(const char *provider_section_name); (*load_configuration)(void *cls,
const char *provider_section_name);
/** /**
* Release configuration resources previously loaded * Release configuration resources previously loaded
@ -89,7 +92,7 @@ struct TALER_KYCLOGIC_Plugin
* @param[in] pd configuration to release * @param[in] pd configuration to release
*/ */
void void
(*unload_configuration)(struct TEH_KYCLOGIC_ProviderDetails *pd); (*unload_configuration)(struct TALER_KYCLOGIC_ProviderDetails *pd);
/** /**
@ -100,11 +103,11 @@ struct TALER_KYCLOGIC_Plugin
* @param account_id which account to trigger process for * @param account_id which account to trigger process for
* @return handle to cancel operation early * @return handle to cancel operation early
*/ */
struct TEH_KYCLOGIC_InitiateHandle * struct TALER_KYCLOGIC_InitiateHandle *
(*initiate)(void *cls, (*initiate)(void *cls,
const struct TEH_KYCLOGIC_ProviderDetails *pd, const struct TALER_KYCLOGIC_ProviderDetails *pd,
const struct TALER_PaytoHashP *account_id, const struct TALER_PaytoHashP *account_id,
TEH_KYCLOGIC_InitiateCallback cb, TALER_KYCLOGIC_InitiateCallback cb,
void *cb_cls); void *cb_cls);
/** /**
@ -113,7 +116,7 @@ struct TALER_KYCLOGIC_Plugin
* @param[in] ih handle of operation to cancel * @param[in] ih handle of operation to cancel
*/ */
void void
(*initiate_cancel) (struct TEH_KYCLOGIC_InitiateHandle *ih); (*initiate_cancel) (struct TALER_KYCLOGIC_InitiateHandle *ih);
// FIXME: add callback pair for kyc_proof // FIXME: add callback pair for kyc_proof