fail if exchange-account configuration is definitively wrong (#5642)

This commit is contained in:
Christian Grothoff 2020-08-28 23:43:05 +02:00
parent 8a89eec7b4
commit f486df99c8
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 26 additions and 9 deletions

View File

@ -169,9 +169,14 @@ run (void *cls,
} }
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Signing /wire responses\n"); "Signing /wire responses\n");
TALER_EXCHANGEDB_find_accounts (cfg, if (GNUNET_OK !=
&sign_account_data, TALER_EXCHANGEDB_find_accounts (cfg,
NULL); &sign_account_data,
NULL))
{
global_ret = 1;
return;
}
} }

View File

@ -52,6 +52,11 @@ struct FindAccountContext
* Closure for @e cb. * Closure for @e cb.
*/ */
void *cb_cls; void *cb_cls;
/**
* Set to #GNUNET_SYSERR if the configuration is invalid.
*/
int res;
}; };
@ -86,6 +91,7 @@ check_for_account (void *cls,
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
section, section,
"PAYTO_URI"); "PAYTO_URI");
ctx->res = GNUNET_SYSERR;
return; return;
} }
method = TALER_payto_get_method (payto_uri); method = TALER_payto_get_method (payto_uri);
@ -94,6 +100,7 @@ check_for_account (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"payto URI in config ([%s]/PAYTO_URI) malformed\n", "payto URI in config ([%s]/PAYTO_URI) malformed\n",
section); section);
ctx->res = GNUNET_SYSERR;
GNUNET_free (payto_uri); GNUNET_free (payto_uri);
return; return;
} }
@ -135,20 +142,24 @@ check_for_account (void *cls,
* @param cfg configuration to use * @param cfg configuration to use
* @param cb callback to invoke * @param cb callback to invoke
* @param cb_cls closure for @a cb * @param cb_cls closure for @a cb
* @return #GNUNET_OK if the configuration seems valid, #GNUNET_SYSERR if not
*/ */
void int
TALER_EXCHANGEDB_find_accounts (const struct GNUNET_CONFIGURATION_Handle *cfg, TALER_EXCHANGEDB_find_accounts (const struct GNUNET_CONFIGURATION_Handle *cfg,
TALER_EXCHANGEDB_AccountCallback cb, TALER_EXCHANGEDB_AccountCallback cb,
void *cb_cls) void *cb_cls)
{ {
struct FindAccountContext ctx; struct FindAccountContext ctx = {
.cfg = cfg,
.cb = cb,
.cb_cls = cb_cls,
.res = GNUNET_OK
};
ctx.cfg = cfg;
ctx.cb = cb;
ctx.cb_cls = cb_cls;
GNUNET_CONFIGURATION_iterate_sections (cfg, GNUNET_CONFIGURATION_iterate_sections (cfg,
&check_for_account, &check_for_account,
&ctx); &ctx);
return ctx.res;
} }

View File

@ -438,8 +438,9 @@ typedef void
* @param cfg configuration to use * @param cfg configuration to use
* @param cb callback to invoke * @param cb callback to invoke
* @param cb_cls closure for @a cb * @param cb_cls closure for @a cb
* @return #GNUNET_OK if the configuration seems valid, #GNUNET_SYSERR if not
*/ */
void int
TALER_EXCHANGEDB_find_accounts (const struct GNUNET_CONFIGURATION_Handle *cfg, TALER_EXCHANGEDB_find_accounts (const struct GNUNET_CONFIGURATION_Handle *cfg,
TALER_EXCHANGEDB_AccountCallback cb, TALER_EXCHANGEDB_AccountCallback cb,
void *cb_cls); void *cb_cls);