aboutsummaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd.c1
-rw-r--r--src/exchange/taler-exchange-httpd.h1
-rw-r--r--src/exchange/taler-exchange-httpd_batch-deposit.c2
-rw-r--r--src/exchange/taler-exchange-httpd_extensions.c66
-rw-r--r--src/exchange/taler-exchange-httpd_keys.c22
-rw-r--r--src/exchange/taler-exchange-httpd_management_extensions.c35
-rw-r--r--src/exchange/taler-exchange-httpd_refreshes_reveal.c4
7 files changed, 66 insertions, 65 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index 39f383af..d97c68e3 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -102,6 +102,7 @@ const struct GNUNET_CONFIGURATION_Handle *TEH_cfg;
*
* Set after loading the library, enabled in database event handler.
*/
+bool TEH_age_restriction_enabled = false;
struct TALER_AgeRestrictionConfig TEH_age_restriction_config = {0};
/**
diff --git a/src/exchange/taler-exchange-httpd.h b/src/exchange/taler-exchange-httpd.h
index 77aab249..4d3fb490 100644
--- a/src/exchange/taler-exchange-httpd.h
+++ b/src/exchange/taler-exchange-httpd.h
@@ -363,6 +363,7 @@ struct TEH_RequestHandler
/* Age restriction configuration */
+extern bool TEH_age_restriction_enabled;
extern struct TALER_AgeRestrictionConfig TEH_age_restriction_config;
#endif
diff --git a/src/exchange/taler-exchange-httpd_batch-deposit.c b/src/exchange/taler-exchange-httpd_batch-deposit.c
index c2a9cbd5..c9478014 100644
--- a/src/exchange/taler-exchange-httpd_batch-deposit.c
+++ b/src/exchange/taler-exchange-httpd_batch-deposit.c
@@ -242,7 +242,7 @@ batch_deposit_transaction (void *cls,
MHD_RESULT *mhd_ret)
{
struct BatchDepositContext *dc = cls;
- enum GNUNET_DB_QueryStatus qs;
+ enum GNUNET_DB_QueryStatus qs = GNUNET_OK;
bool balance_ok;
bool in_conflict;
diff --git a/src/exchange/taler-exchange-httpd_extensions.c b/src/exchange/taler-exchange-httpd_extensions.c
index 2aee1b5c..e8d3e4af 100644
--- a/src/exchange/taler-exchange-httpd_extensions.c
+++ b/src/exchange/taler-exchange-httpd_extensions.c
@@ -77,67 +77,66 @@ extension_update_event_cb (void *cls,
return;
}
- // Get the config from the database as string
- if (extension->has_config)
+ // Get the manifest from the database as string
{
- char *config_str = NULL;
+ char *manifest_str = NULL;
enum GNUNET_DB_QueryStatus qs;
json_error_t err;
- json_t *config;
+ json_t *manifest_js;
enum GNUNET_GenericReturnValue ret;
- qs = TEH_plugin->get_extension_config (TEH_plugin->cls,
- extension->name,
- &config_str);
+ qs = TEH_plugin->get_extension_manifest (TEH_plugin->cls,
+ extension->name,
+ &manifest_str);
if (qs < 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Couldn't get extension config\n");
+ "Couldn't get extension manifest\n");
GNUNET_break (0);
return;
}
// No config found -> disable extension
- if (NULL == config_str)
+ if (NULL == manifest_str)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "No configuration found for extension %s, disabling it\n",
+ "No manifest found for extension %s, disabling it\n",
extension->name);
extension->disable ((struct TALER_Extension *) extension);
return;
}
// Parse the string as JSON
- config = json_loads (config_str, JSON_DECODE_ANY, &err);
- if (NULL == config)
+ manifest_js = json_loads (manifest_str, JSON_DECODE_ANY, &err);
+ if (NULL == manifest_js)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to parse config for extension `%s' as JSON: %s (%s)\n",
+ "Failed to parse manifest for extension `%s' as JSON: %s (%s)\n",
extension->name,
err.text,
err.source);
GNUNET_break (0);
- free (config_str);
+ free (manifest_js);
return;
}
// Call the parser for the extension
- ret = extension->load_json_config (
+ ret = extension->load_config (
(struct TALER_Extension *) extension,
- json_object_get (config, "config"));
+ json_object_get (manifest_js, "config"));
if (GNUNET_OK != ret)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Couldn't parse configuration for extension %s from the database: %s\n",
+ "Couldn't parse configuration for extension %s from the manifest in the database: %s\n",
extension->name,
- config_str);
+ manifest_str);
GNUNET_break (0);
}
- free (config_str);
- json_decref (config);
+ free (manifest_str);
+ json_decref (manifest_js);
}
/* Special case age restriction: Update global flag and mask */
@@ -145,11 +144,15 @@ extension_update_event_cb (void *cls,
{
const struct TALER_AgeRestrictionConfig *conf =
TALER_extensions_get_age_restriction_config ();
+ TEH_age_restriction_enabled = false;
if (NULL != conf)
+ {
+ TEH_age_restriction_enabled = true;
TEH_age_restriction_config = *conf;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"[age restriction] DB event has changed the config to %s with mask: %s\n",
- conf->enabled ? "enabled": "disabled",
+ TEH_age_restriction_enabled ? "enabled": "DISABLED",
TALER_age_mask_to_string (&conf->mask));
}
@@ -167,13 +170,22 @@ TEH_extensions_init ()
/* Load the shared libraries first */
if (GNUNET_OK !=
- TALER_extensions_load (TEH_cfg))
+ TALER_extensions_init (TEH_cfg))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"failed to load extensions");
return GNUNET_SYSERR;
}
+ /* Check for age restriction */
+ {
+ const struct TALER_AgeRestrictionConfig *arc;
+
+ if (NULL !=
+ (arc = TALER_extensions_get_age_restriction_config ()))
+ TEH_age_restriction_config = *arc;
+ }
+
extensions_eh = TEH_plugin->event_listen (TEH_plugin->cls,
GNUNET_TIME_UNIT_FOREVER_REL,
&ev,
@@ -192,16 +204,16 @@ TEH_extensions_init ()
{
const struct TALER_Extension *ext = it->extension;
uint32_t typ = htonl (ext->type);
- char *conf = json_dumps (ext->config_to_json (ext), JSON_COMPACT);
+ char *manifest = json_dumps (ext->manifest (ext), JSON_COMPACT);
- TEH_plugin->set_extension_config (TEH_plugin->cls,
- ext->name,
- conf);
+ TEH_plugin->set_extension_manifest (TEH_plugin->cls,
+ ext->name,
+ manifest);
extension_update_event_cb (NULL,
&typ,
sizeof(typ));
- free (conf);
+ free (manifest);
}
return GNUNET_OK;
diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c
index 4761f314..cc8759f0 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -837,7 +837,7 @@ load_age_mask (const char*section_name)
if (GNUNET_OK == ret)
{
- if (! TEH_age_restriction_config.enabled)
+ if (! TEH_age_restriction_enabled)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"age restriction set in section %s, yet, age restriction is not enabled\n",
section_name);
@@ -1907,7 +1907,7 @@ create_krd (struct TEH_KeyStateHandle *ksh,
iter = iter->next)
{
const struct TALER_Extension *extension = iter->extension;
- json_t *ext;
+ json_t *manifest;
int r;
/* skip if not enabled */
@@ -1917,26 +1917,14 @@ create_krd (struct TEH_KeyStateHandle *ksh,
/* flag our findings so far */
has_extensions = true;
- ext = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_bool ("critical",
- extension->critical),
- GNUNET_JSON_pack_string ("version",
- extension->version)
- );
- GNUNET_assert (NULL != ext);
- if (extension->has_config)
- {
- GNUNET_assert (extension->config_json);
- json_object_set_new (ext,
- "config",
- extension->config_json);
- }
+ manifest = extension->manifest(extension);
+ GNUNET_assert(manifest);
r = json_object_set_new (
extensions,
extension->name,
- ext);
+ manifest);
GNUNET_assert (0 == r);
}
diff --git a/src/exchange/taler-exchange-httpd_management_extensions.c b/src/exchange/taler-exchange-httpd_management_extensions.c
index c70ad25e..ad2057a9 100644
--- a/src/exchange/taler-exchange-httpd_management_extensions.c
+++ b/src/exchange/taler-exchange-httpd_management_extensions.c
@@ -80,7 +80,7 @@ set_extensions (void *cls,
struct Extension *ext = &sec->extensions[i];
const struct TALER_Extension *taler_ext;
enum GNUNET_DB_QueryStatus qs;
- char *config;
+ char *manifest;
taler_ext = TALER_extensions_get_by_type (ext->type);
if (NULL == taler_ext)
@@ -90,10 +90,8 @@ set_extensions (void *cls,
return GNUNET_DB_STATUS_HARD_ERROR;
}
- GNUNET_assert (NULL != ext->config);
-
- config = json_dumps (ext->config, JSON_COMPACT | JSON_SORT_KEYS);
- if (NULL == config)
+ manifest = json_dumps (ext->config, JSON_COMPACT | JSON_SORT_KEYS);
+ if (NULL == manifest)
{
GNUNET_break (0);
*mhd_ret = TALER_MHD_reply_with_error (connection,
@@ -103,12 +101,12 @@ set_extensions (void *cls,
return GNUNET_DB_STATUS_HARD_ERROR;
}
- qs = TEH_plugin->set_extension_config (
+ qs = TEH_plugin->set_extension_manifest (
TEH_plugin->cls,
taler_ext->name,
- config);
+ manifest);
- free (config);
+ free (manifest);
if (qs < 0)
{
@@ -153,7 +151,7 @@ verify_extensions_from_json (
const char*name;
const struct TALER_Extension *extension;
size_t i = 0;
- json_t *blob;
+ json_t *manifest;
GNUNET_assert (NULL != extensions);
GNUNET_assert (json_is_object (extensions));
@@ -162,7 +160,7 @@ verify_extensions_from_json (
sec->extensions = GNUNET_new_array (sec->num_extensions,
struct Extension);
- json_object_foreach (extensions, name, blob)
+ json_object_foreach (extensions, name, manifest)
{
int critical = 0;
json_t *config;
@@ -178,14 +176,14 @@ verify_extensions_from_json (
}
if (GNUNET_OK !=
- TALER_extensions_is_json_config (
- blob, &critical, &version, &config))
+ TALER_extensions_parse_manifest (
+ manifest, &critical, &version, &config))
return GNUNET_SYSERR;
if (critical != extension->critical
|| 0 != strcmp (version, extension->version) // FIXME-oec: libtool compare
|| NULL == config
- || GNUNET_OK != extension->test_json_config (config))
+ || GNUNET_OK != extension->load_config (NULL, config))
return GNUNET_SYSERR;
sec->extensions[i].type = extension->type;
@@ -226,7 +224,8 @@ TEH_handler_management_post_extensions (
}
/* Ensure we have an object */
- if (! json_is_object (extensions))
+ if ((! json_is_object (extensions)) &&
+ (! json_is_null (extensions)))
{
GNUNET_JSON_parse_free (top_spec);
return TALER_MHD_reply_with_error (
@@ -238,13 +237,13 @@ TEH_handler_management_post_extensions (
/* Verify the signature */
{
- struct TALER_ExtensionConfigHashP h_config;
+ struct TALER_ExtensionManifestsHashP h_manifests;
if (GNUNET_OK !=
- TALER_JSON_extensions_config_hash (extensions, &h_config) ||
+ TALER_JSON_extensions_manifests_hash (extensions, &h_manifests) ||
GNUNET_OK !=
- TALER_exchange_offline_extension_config_hash_verify (
- &h_config,
+ TALER_exchange_offline_extension_manifests_hash_verify (
+ &h_manifests,
&TEH_master_public_key,
&sec.extensions_sig))
{
diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
index 09ab572b..85090ced 100644
--- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c
+++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
@@ -603,7 +603,7 @@ resolve_refreshes_reveal_denominations (
&rrc->coin_envelope_hash);
}
- if (TEH_age_restriction_config.enabled &&
+ if (TEH_age_restriction_enabled &&
((NULL == old_age_commitment_json) !=
TALER_AgeCommitmentHash_isNullOrZero (
&rctx->melt.session.coin.h_age_commitment)))
@@ -614,7 +614,7 @@ resolve_refreshes_reveal_denominations (
/* Reconstruct the old age commitment and verify its hash matches the one
* from the melt request */
- if (TEH_age_restriction_config.enabled &&
+ if (TEH_age_restriction_enabled &&
(NULL != old_age_commitment_json))
{
enum GNUNET_GenericReturnValue res;