fix misc bugs

This commit is contained in:
Christian Grothoff 2020-12-12 22:42:04 +01:00
parent b81a5fb3aa
commit 7442744809
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 292 additions and 230 deletions

View File

@ -6,4 +6,4 @@
MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
# Where do we store the TOFU key material? # Where do we store the TOFU key material?
SECM_TOFU_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/secm_tofus.priv SECM_TOFU_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/secm_tofus.pub

View File

@ -342,9 +342,9 @@ do_shutdown (void *cls)
while (NULL != (drr = drr_head)) while (NULL != (drr = drr_head))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Aborting incomplete denomination revocation #%u\n", "Aborting incomplete denomination revocation #%u\n",
(unsigned int) drr->idx); (unsigned int) drr->idx);
TALER_EXCHANGE_management_revoke_denomination_key_cancel (drr->h); TALER_EXCHANGE_management_revoke_denomination_key_cancel (drr->h);
GNUNET_CONTAINER_DLL_remove (drr_head, GNUNET_CONTAINER_DLL_remove (drr_head,
drr_tail, drr_tail,
@ -357,9 +357,9 @@ do_shutdown (void *cls)
while (NULL != (srr = srr_head)) while (NULL != (srr = srr_head))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Aborting incomplete signkey revocation #%u\n", "Aborting incomplete signkey revocation #%u\n",
(unsigned int) srr->idx); (unsigned int) srr->idx);
TALER_EXCHANGE_management_revoke_signing_key_cancel (srr->h); TALER_EXCHANGE_management_revoke_signing_key_cancel (srr->h);
GNUNET_CONTAINER_DLL_remove (srr_head, GNUNET_CONTAINER_DLL_remove (srr_head,
srr_tail, srr_tail,
@ -373,9 +373,9 @@ do_shutdown (void *cls)
while (NULL != (war = war_head)) while (NULL != (war = war_head))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Aborting incomplete wire add #%u\n", "Aborting incomplete wire add #%u\n",
(unsigned int) war->idx); (unsigned int) war->idx);
TALER_EXCHANGE_management_enable_wire_cancel (war->h); TALER_EXCHANGE_management_enable_wire_cancel (war->h);
GNUNET_CONTAINER_DLL_remove (war_head, GNUNET_CONTAINER_DLL_remove (war_head,
war_tail, war_tail,
@ -388,9 +388,9 @@ do_shutdown (void *cls)
while (NULL != (wdr = wdr_head)) while (NULL != (wdr = wdr_head))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Aborting incomplete wire del #%u\n", "Aborting incomplete wire del #%u\n",
(unsigned int) wdr->idx); (unsigned int) wdr->idx);
TALER_EXCHANGE_management_disable_wire_cancel (wdr->h); TALER_EXCHANGE_management_disable_wire_cancel (wdr->h);
GNUNET_CONTAINER_DLL_remove (wdr_head, GNUNET_CONTAINER_DLL_remove (wdr_head,
wdr_tail, wdr_tail,
@ -403,9 +403,9 @@ do_shutdown (void *cls)
while (NULL != (wfr = wfr_head)) while (NULL != (wfr = wfr_head))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Aborting incomplete wire fee #%u\n", "Aborting incomplete wire fee #%u\n",
(unsigned int) wfr->idx); (unsigned int) wfr->idx);
TALER_EXCHANGE_management_set_wire_fees_cancel (wfr->h); TALER_EXCHANGE_management_set_wire_fees_cancel (wfr->h);
GNUNET_CONTAINER_DLL_remove (wfr_head, GNUNET_CONTAINER_DLL_remove (wfr_head,
wfr_tail, wfr_tail,
@ -418,9 +418,9 @@ do_shutdown (void *cls)
while (NULL != (ukr = ukr_head)) while (NULL != (ukr = ukr_head))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Aborting incomplete key signature upload #%u\n", "Aborting incomplete key signature upload #%u\n",
(unsigned int) ukr->idx); (unsigned int) ukr->idx);
TALER_EXCHANGE_post_management_keys_cancel (ukr->h); TALER_EXCHANGE_post_management_keys_cancel (ukr->h);
GNUNET_CONTAINER_DLL_remove (ukr_head, GNUNET_CONTAINER_DLL_remove (ukr_head,
ukr_tail, ukr_tail,
@ -438,8 +438,8 @@ do_shutdown (void *cls)
} }
if (NULL != in) if (NULL != in)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Warning: input not consumed!\n"); "Input not consumed!\n");
json_decref (in); json_decref (in);
in = NULL; in = NULL;
} }
@ -525,6 +525,7 @@ output_operation (const char *op_name,
{ {
json_t *action; json_t *action;
GNUNET_break (NULL != op_value);
if (NULL == out) if (NULL == out)
out = json_array (); out = json_array ();
action = json_pack ("{ s:s, s:o }", action = json_pack ("{ s:s, s:o }",
@ -532,6 +533,7 @@ output_operation (const char *op_name,
op_name, op_name,
"arguments", "arguments",
op_value); op_value);
GNUNET_break (NULL != action);
GNUNET_break (0 == GNUNET_break (0 ==
json_array_append_new (out, json_array_append_new (out,
action)); action));
@ -578,12 +580,12 @@ load_offline_key (void)
return GNUNET_OK; return GNUNET_OK;
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (kcfg, GNUNET_CONFIGURATION_get_value_filename (kcfg,
"exchange", "exchange-offline",
"MASTER_PRIV_FILE", "MASTER_PRIV_FILE",
&fn)) &fn))
{ {
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange", "exchange-offline",
"MASTER_PRIV_FILE"); "MASTER_PRIV_FILE");
test_shutdown (); test_shutdown ();
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -629,12 +631,13 @@ denom_revocation_cb (
if (MHD_HTTP_NO_CONTENT != hr->http_status) if (MHD_HTTP_NO_CONTENT != hr->http_status)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Upload failed for command %u with status %u: %s (%s)\n", "Upload failed for command %u with status %u: %s (%s)\n",
(unsigned int) drr->idx, (unsigned int) drr->idx,
hr->http_status, hr->http_status,
TALER_ErrorCode_get_hint (hr->ec), TALER_ErrorCode_get_hint (hr->ec),
hr->hint); hr->hint);
global_ret = 10;
} }
GNUNET_CONTAINER_DLL_remove (drr_head, GNUNET_CONTAINER_DLL_remove (drr_head,
drr_tail, drr_tail,
@ -675,11 +678,14 @@ upload_denom_revocation (const char *exchange_url,
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input for denomination revocation: %s#%u at %u (skipping)\n", "Invalid input for denomination revocation: %s#%u at %u (skipping)\n",
err_name, err_name,
err_line, err_line,
(unsigned int) idx); (unsigned int) idx);
json_dumpf (value,
stderr,
JSON_INDENT (2));
global_ret = 7; global_ret = 7;
test_shutdown (); test_shutdown ();
return; return;
@ -714,12 +720,13 @@ signkey_revocation_cb (
if (MHD_HTTP_NO_CONTENT != hr->http_status) if (MHD_HTTP_NO_CONTENT != hr->http_status)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Upload failed for command %u with status %u: %s (%s)\n", "Upload failed for command %u with status %u: %s (%s)\n",
(unsigned int) srr->idx, (unsigned int) srr->idx,
hr->http_status, hr->http_status,
TALER_ErrorCode_get_hint (hr->ec), TALER_ErrorCode_get_hint (hr->ec),
hr->hint); hr->hint);
global_ret = 10;
} }
GNUNET_CONTAINER_DLL_remove (srr_head, GNUNET_CONTAINER_DLL_remove (srr_head,
srr_tail, srr_tail,
@ -760,11 +767,14 @@ upload_signkey_revocation (const char *exchange_url,
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input for signkey revocation: %s#%u at %u (skipping)\n", "Invalid input for signkey revocation: %s#%u at %u (skipping)\n",
err_name, err_name,
err_line, err_line,
(unsigned int) idx); (unsigned int) idx);
json_dumpf (value,
stderr,
JSON_INDENT (2));
global_ret = 7; global_ret = 7;
test_shutdown (); test_shutdown ();
return; return;
@ -799,12 +809,13 @@ wire_add_cb (
if (MHD_HTTP_NO_CONTENT != hr->http_status) if (MHD_HTTP_NO_CONTENT != hr->http_status)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Upload failed for command %u with status %u: %s (%s)\n", "Upload failed for command %u with status %u: %s (%s)\n",
(unsigned int) war->idx, (unsigned int) war->idx,
hr->http_status, hr->http_status,
TALER_ErrorCode_get_hint (hr->ec), TALER_ErrorCode_get_hint (hr->ec),
hr->hint); hr->hint);
global_ret = 10;
} }
GNUNET_CONTAINER_DLL_remove (war_head, GNUNET_CONTAINER_DLL_remove (war_head,
war_tail, war_tail,
@ -851,11 +862,14 @@ upload_wire_add (const char *exchange_url,
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input for adding wire account: %s#%u at %u (skipping)\n", "Invalid input for adding wire account: %s#%u at %u (skipping)\n",
err_name, err_name,
err_line, err_line,
(unsigned int) idx); (unsigned int) idx);
json_dumpf (value,
stderr,
JSON_INDENT (2));
global_ret = 7; global_ret = 7;
test_shutdown (); test_shutdown ();
return; return;
@ -892,12 +906,13 @@ wire_del_cb (
if (MHD_HTTP_NO_CONTENT != hr->http_status) if (MHD_HTTP_NO_CONTENT != hr->http_status)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Upload failed for command %u with status %u: %s (%s)\n", "Upload failed for command %u with status %u: %s (%s)\n",
(unsigned int) wdr->idx, (unsigned int) wdr->idx,
hr->http_status, hr->http_status,
TALER_ErrorCode_get_hint (hr->ec), TALER_ErrorCode_get_hint (hr->ec),
hr->hint); hr->hint);
global_ret = 10;
} }
GNUNET_CONTAINER_DLL_remove (wdr_head, GNUNET_CONTAINER_DLL_remove (wdr_head,
wdr_tail, wdr_tail,
@ -941,11 +956,14 @@ upload_wire_del (const char *exchange_url,
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input to disable wire account: %s#%u at %u (skipping)\n", "Invalid input to disable wire account: %s#%u at %u (skipping)\n",
err_name, err_name,
err_line, err_line,
(unsigned int) idx); (unsigned int) idx);
json_dumpf (value,
stderr,
JSON_INDENT (2));
global_ret = 7; global_ret = 7;
test_shutdown (); test_shutdown ();
return; return;
@ -981,12 +999,13 @@ wire_fee_cb (
if (MHD_HTTP_NO_CONTENT != hr->http_status) if (MHD_HTTP_NO_CONTENT != hr->http_status)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Upload failed for command %u with status %u: %s (%s)\n", "Upload failed for command %u with status %u: %s (%s)\n",
(unsigned int) wfr->idx, (unsigned int) wfr->idx,
hr->http_status, hr->http_status,
TALER_ErrorCode_get_hint (hr->ec), TALER_ErrorCode_get_hint (hr->ec),
hr->hint); hr->hint);
global_ret = 10;
} }
GNUNET_CONTAINER_DLL_remove (wfr_head, GNUNET_CONTAINER_DLL_remove (wfr_head,
wfr_tail, wfr_tail,
@ -1039,11 +1058,14 @@ upload_wire_fee (const char *exchange_url,
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input to set wire fee: %s#%u at %u (skipping)\n", "Invalid input to set wire fee: %s#%u at %u (skipping)\n",
err_name, err_name,
err_line, err_line,
(unsigned int) idx); (unsigned int) idx);
json_dumpf (value,
stderr,
JSON_INDENT (2));
global_ret = 7; global_ret = 7;
test_shutdown (); test_shutdown ();
return; return;
@ -1082,12 +1104,13 @@ keys_cb (
if (MHD_HTTP_NO_CONTENT != hr->http_status) if (MHD_HTTP_NO_CONTENT != hr->http_status)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Upload failed for command %u with status %u: %s (%s)\n", "Upload failed for command %u with status %u: %s (%s)\n",
(unsigned int) ukr->idx, (unsigned int) ukr->idx,
hr->http_status, hr->http_status,
TALER_ErrorCode_get_hint (hr->ec), TALER_ErrorCode_get_hint (hr->ec),
hr->hint); hr->hint);
global_ret = 10;
} }
GNUNET_CONTAINER_DLL_remove (ukr_head, GNUNET_CONTAINER_DLL_remove (ukr_head,
ukr_tail, ukr_tail,
@ -1102,7 +1125,7 @@ keys_cb (
* *
* @param exchange_url base URL of the exchange * @param exchange_url base URL of the exchange
* @param idx index of the operation we are performing (for logging) * @param idx index of the operation we are performing (for logging)
* @param value argumets for POSTing keys * @param value arguments for POSTing keys
*/ */
static void static void
upload_keys (const char *exchange_url, upload_keys (const char *exchange_url,
@ -1125,21 +1148,28 @@ upload_keys (const char *exchange_url,
bool ok = true; bool ok = true;
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_JSON_parse (in, GNUNET_JSON_parse (value,
spec, spec,
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input to 'upload': %s#%u (skipping)\n", "Invalid input to 'upload': %s#%u (skipping)\n",
err_name, err_name,
err_line); err_line);
json_dumpf (value,
stderr,
JSON_INDENT (2));
global_ret = 7; global_ret = 7;
test_shutdown (); test_shutdown ();
return; return;
} }
pkd.num_sign_sigs = json_array_size (signkey_sigs); pkd.num_sign_sigs = json_array_size (signkey_sigs);
pkd.num_denom_sigs = json_array_size (denom_sigs); pkd.num_denom_sigs = json_array_size (denom_sigs);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Uploading %u denomination and %u signing key signatures\n",
pkd.num_denom_sigs,
pkd.num_sign_sigs);
pkd.sign_sigs = GNUNET_new_array ( pkd.sign_sigs = GNUNET_new_array (
pkd.num_sign_sigs, pkd.num_sign_sigs,
struct TALER_EXCHANGE_SigningKeySignature); struct TALER_EXCHANGE_SigningKeySignature);
@ -1165,11 +1195,14 @@ upload_keys (const char *exchange_url,
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input for signkey validity: %s#%u at %u (aborting)\n", "Invalid input for signkey validity: %s#%u at %u (aborting)\n",
err_name, err_name,
err_line, err_line,
i); i);
json_dumpf (val,
stderr,
JSON_INDENT (2));
ok = false; ok = false;
} }
} }
@ -1192,11 +1225,14 @@ upload_keys (const char *exchange_url,
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input for denomination validity: %s#%u at %u (aborting)\n", "Invalid input for denomination validity: %s#%u at %u (aborting)\n",
err_name, err_name,
err_line, err_line,
i); i);
json_dumpf (val,
stderr,
JSON_INDENT (2));
ok = false; ok = false;
} }
} }
@ -1222,6 +1258,7 @@ upload_keys (const char *exchange_url,
} }
GNUNET_free (pkd.sign_sigs); GNUNET_free (pkd.sign_sigs);
GNUNET_free (pkd.denom_sigs); GNUNET_free (pkd.denom_sigs);
GNUNET_JSON_parse_free (spec);
} }
@ -1275,8 +1312,8 @@ trigger_upload (const char *exchange_url)
value = json_object_get (obj, "arguments"); value = json_object_get (obj, "arguments");
if (NULL == key) if (NULL == key)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Malformed JSON input\n"); "Malformed JSON input\n");
global_ret = 3; global_ret = 3;
test_shutdown (); test_shutdown ();
return; return;
@ -1296,9 +1333,9 @@ trigger_upload (const char *exchange_url)
} }
if (! found) if (! found)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Upload does not know how to handle `%s'\n", "Upload does not know how to handle `%s'\n",
key); key);
global_ret = 3; global_ret = 3;
test_shutdown (); test_shutdown ();
return; return;
@ -1319,8 +1356,8 @@ do_upload (char *const *args)
if (NULL != in) if (NULL != in)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, refusing upload\n"); "Downloaded data was not consumed, refusing upload\n");
test_shutdown (); test_shutdown ();
global_ret = 4; global_ret = 4;
return; return;
@ -1334,12 +1371,12 @@ do_upload (char *const *args)
&err); &err);
if (NULL == out) if (NULL == out)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to read JSON input: %s at %d:%s (offset: %d)\n", "Failed to read JSON input: %s at %d:%s (offset: %d)\n",
err.text, err.text,
err.line, err.line,
err.source, err.source,
err.position); err.position);
test_shutdown (); test_shutdown ();
global_ret = 2; global_ret = 2;
return; return;
@ -1347,8 +1384,8 @@ do_upload (char *const *args)
} }
if (! json_is_array (out)) if (! json_is_array (out))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error: expected JSON array for `upload` command\n"); "Error: expected JSON array for `upload` command\n");
test_shutdown (); test_shutdown ();
global_ret = 2; global_ret = 2;
return; return;
@ -1387,8 +1424,8 @@ do_revoke_denomination_key (char *const *args)
if (NULL != in) if (NULL != in)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, refusing revocation\n"); "Downloaded data was not consumed, refusing revocation\n");
test_shutdown (); test_shutdown ();
global_ret = 4; global_ret = 4;
return; return;
@ -1400,8 +1437,8 @@ do_revoke_denomination_key (char *const *args)
&h_denom_pub, &h_denom_pub,
sizeof (h_denom_pub))) ) sizeof (h_denom_pub))) )
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"You must specify a denomination key with this subcommand\n"); "You must specify a denomination key with this subcommand\n");
test_shutdown (); test_shutdown ();
global_ret = 5; global_ret = 5;
return; return;
@ -1436,8 +1473,8 @@ do_revoke_signkey (char *const *args)
if (NULL != in) if (NULL != in)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, refusing revocation\n"); "Downloaded data was not consumed, refusing revocation\n");
test_shutdown (); test_shutdown ();
global_ret = 4; global_ret = 4;
return; return;
@ -1449,8 +1486,8 @@ do_revoke_signkey (char *const *args)
&exchange_pub, &exchange_pub,
sizeof (exchange_pub))) ) sizeof (exchange_pub))) )
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"You must specify an exchange signing key with this subcommand\n"); "You must specify an exchange signing key with this subcommand\n");
test_shutdown (); test_shutdown ();
global_ret = 5; global_ret = 5;
return; return;
@ -1486,16 +1523,16 @@ do_add_wire (char *const *args)
if (NULL != in) if (NULL != in)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, not adding wire account\n"); "Downloaded data was not consumed, not adding wire account\n");
test_shutdown (); test_shutdown ();
global_ret = 4; global_ret = 4;
return; return;
} }
if (NULL == args[0]) if (NULL == args[0])
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"You must specify a payto://-URI with this subcommand\n"); "You must specify a payto://-URI with this subcommand\n");
test_shutdown (); test_shutdown ();
global_ret = 5; global_ret = 5;
return; return;
@ -1541,16 +1578,16 @@ do_del_wire (char *const *args)
if (NULL != in) if (NULL != in)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, not deleting wire account\n"); "Downloaded data was not consumed, not deleting wire account\n");
test_shutdown (); test_shutdown ();
global_ret = 4; global_ret = 4;
return; return;
} }
if (NULL == args[0]) if (NULL == args[0])
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"You must specify a payto://-URI with this subcommand\n"); "You must specify a payto://-URI with this subcommand\n");
test_shutdown (); test_shutdown ();
global_ret = 5; global_ret = 5;
return; return;
@ -1597,8 +1634,8 @@ do_set_wire_fee (char *const *args)
if (NULL != in) if (NULL != in)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, not setting wire fee\n"); "Downloaded data was not consumed, not setting wire fee\n");
test_shutdown (); test_shutdown ();
global_ret = 4; global_ret = 4;
return; return;
@ -1620,8 +1657,8 @@ do_set_wire_fee (char *const *args)
TALER_string_to_amount (args[3], TALER_string_to_amount (args[3],
&closing_fee)) ) &closing_fee)) )
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"You must use YEAR, METHOD, WIRE-FEE and CLOSING-FEE as arguments for this subcommand\n"); "You must use YEAR, METHOD, WIRE-FEE and CLOSING-FEE as arguments for this subcommand\n");
test_shutdown (); test_shutdown ();
global_ret = 5; global_ret = 5;
return; return;
@ -1683,11 +1720,11 @@ download_cb (void *cls,
case MHD_HTTP_OK: case MHD_HTTP_OK:
break; break;
default: default:
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to download keys: %s (HTTP status: %u/%u)\n", "Failed to download keys: %s (HTTP status: %u/%u)\n",
hr->hint, hr->hint,
hr->http_status, hr->http_status,
(unsigned int) hr->ec); (unsigned int) hr->ec);
test_shutdown (); test_shutdown ();
global_ret = 4; global_ret = 4;
return; return;
@ -1777,12 +1814,18 @@ tofu_check (const struct TALER_SecurityModulePublicKeyP secm[2])
GNUNET_free (fn); GNUNET_free (fn);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
GNUNET_free (fn);
/* TOFU check */ /* TOFU check */
if (0 != memcmp (old, if (0 != memcmp (old,
secm, secm,
sizeof (old))) sizeof (old)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Fatal: security module keys changed (file `%s')!\n",
fn);
GNUNET_free (fn);
return GNUNET_SYSERR; return GNUNET_SYSERR;
}
GNUNET_free (fn);
return GNUNET_OK; return GNUNET_OK;
} }
/* persist keys for future runs */ /* persist keys for future runs */
@ -1845,11 +1888,14 @@ show_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input for signing key to 'show': %s#%u at %u (skipping)\n", "Invalid input for signing key to 'show': %s#%u at %u (skipping)\n",
err_name, err_name,
err_line, err_line,
(unsigned int) index); (unsigned int) index);
json_dumpf (value,
stderr,
JSON_INDENT (2));
global_ret = 7; global_ret = 7;
test_shutdown (); test_shutdown ();
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -1863,9 +1909,9 @@ show_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
secm_pub, secm_pub,
&secm_sig)) &secm_sig))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid security module signature for key %s (aborting)\n", "Invalid security module signature for signing key %s (aborting)\n",
TALER_B2S (&exchange_pub)); TALER_B2S (&exchange_pub));
global_ret = 9; global_ret = 9;
test_shutdown (); test_shutdown ();
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -1953,11 +1999,14 @@ show_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input for denomination key to 'show': %s#%u at %u (skipping)\n", "Invalid input for denomination key to 'show': %s#%u at %u (skipping)\n",
err_name, err_name,
err_line, err_line,
(unsigned int) index); (unsigned int) index);
json_dumpf (value,
stderr,
JSON_INDENT (2));
GNUNET_JSON_parse_free (spec); GNUNET_JSON_parse_free (spec);
global_ret = 7; global_ret = 7;
test_shutdown (); test_shutdown ();
@ -1975,9 +2024,9 @@ show_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
secm_pub, secm_pub,
&secm_sig)) &secm_sig))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid security module signature for key %s (aborting)\n", "Invalid security module signature for denomination key %s (aborting)\n",
TALER_B2S (&h_denom_pub)); GNUNET_h2s (&h_denom_pub));
global_ret = 9; global_ret = 9;
test_shutdown (); test_shutdown ();
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -2041,22 +2090,25 @@ do_show (char *const *args)
{ {
json_error_t err; json_error_t err;
out = json_loadf (stdin, in = json_loadf (stdin,
JSON_REJECT_DUPLICATES, JSON_REJECT_DUPLICATES,
&err); &err);
if (NULL == in) if (NULL == in)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to read JSON input: %s at %d:%s (offset: %d)\n", "Failed to read JSON input: %s at %d:%s (offset: %d)\n",
err.text, err.text,
err.line, err.line,
err.source, err.source,
err.position); err.position);
global_ret = 2; global_ret = 2;
test_shutdown (); test_shutdown ();
return; return;
} }
} }
if (GNUNET_OK !=
load_offline_key ())
return;
{ {
const char *err_name; const char *err_name;
@ -2085,10 +2137,13 @@ do_show (char *const *args)
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input to 'show': %s#%u (skipping)\n", "Invalid input to 'show': %s#%u (skipping)\n",
err_name, err_name,
err_line); err_line);
json_dumpf (in,
stderr,
JSON_INDENT (2));
global_ret = 7; global_ret = 7;
test_shutdown (); test_shutdown ();
return; return;
@ -2097,8 +2152,8 @@ do_show (char *const *args)
GNUNET_memcmp (&master_pub, GNUNET_memcmp (&master_pub,
&mpub)) &mpub))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Fatal: exchange uses different master key!\n"); "Fatal: exchange uses different master key!\n");
global_ret = 6; global_ret = 6;
test_shutdown (); test_shutdown ();
GNUNET_JSON_parse_free (spec); GNUNET_JSON_parse_free (spec);
@ -2107,18 +2162,16 @@ do_show (char *const *args)
if (GNUNET_SYSERR == if (GNUNET_SYSERR ==
tofu_check (secm)) tofu_check (secm))
{ {
fprintf (stderr,
"Fatal: security module keys changed!\n");
global_ret = 8; global_ret = 8;
test_shutdown (); test_shutdown ();
GNUNET_JSON_parse_free (spec); GNUNET_JSON_parse_free (spec);
return; return;
} }
if ( (GNUNET_OK != if ( (GNUNET_OK !=
show_signkeys (&secm[0], show_signkeys (&secm[1],
signkeys)) || signkeys)) ||
(GNUNET_OK != (GNUNET_OK !=
show_denomkeys (&secm[1], show_denomkeys (&secm[0],
denomkeys)) ) denomkeys)) )
{ {
global_ret = 8; global_ret = 8;
@ -2187,11 +2240,14 @@ sign_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input for signing key to 'show': %s#%u at %u (skipping)\n", "Invalid input for signing key to 'show': %s#%u at %u (skipping)\n",
err_name, err_name,
err_line, err_line,
(unsigned int) index); (unsigned int) index);
json_dumpf (value,
stderr,
JSON_INDENT (2));
global_ret = 7; global_ret = 7;
test_shutdown (); test_shutdown ();
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -2206,11 +2262,12 @@ sign_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
secm_pub, secm_pub,
&secm_sig)) &secm_sig))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid security module signature for key %s (aborting)\n", "Invalid security module signature for signing key %s (aborting)\n",
TALER_B2S (&exchange_pub)); TALER_B2S (&exchange_pub));
global_ret = 9; global_ret = 9;
test_shutdown (); test_shutdown ();
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
{ {
@ -2225,12 +2282,13 @@ sign_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
GNUNET_assert (0 == GNUNET_assert (0 ==
json_array_append_new ( json_array_append_new (
result, result,
json_pack ("{s:o,s:o}", json_pack ("{s:o, s:o}",
"exchange_pub", "exchange_pub",
GNUNET_JSON_from_data_auto (&exchange_pub), GNUNET_JSON_from_data_auto (&exchange_pub),
"master_sig", "master_sig",
GNUNET_JSON_from_data_auto (&master_sig)))); GNUNET_JSON_from_data_auto (&master_sig))));
} }
GNUNET_JSON_parse_free (spec);
} }
return GNUNET_OK; return GNUNET_OK;
} }
@ -2303,11 +2361,14 @@ sign_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input for denomination key to 'sign': %s#%u at %u (skipping)\n", "Invalid input for denomination key to 'sign': %s#%u at %u (skipping)\n",
err_name, err_name,
err_line, err_line,
(unsigned int) index); (unsigned int) index);
json_dumpf (value,
stderr,
JSON_INDENT (2));
GNUNET_JSON_parse_free (spec); GNUNET_JSON_parse_free (spec);
global_ret = 7; global_ret = 7;
test_shutdown (); test_shutdown ();
@ -2325,11 +2386,12 @@ sign_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
secm_pub, secm_pub,
&secm_sig)) &secm_sig))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid security module signature for key %s (aborting)\n", "Invalid security module signature for denomination key %s (aborting)\n",
TALER_B2S (&h_denom_pub)); GNUNET_h2s (&h_denom_pub));
global_ret = 9; global_ret = 9;
test_shutdown (); test_shutdown ();
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
@ -2351,8 +2413,8 @@ sign_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
GNUNET_assert (0 == GNUNET_assert (0 ==
json_array_append_new ( json_array_append_new (
result, result,
json_pack ("{s:o,s:o}", json_pack ("{s:o, s:o}",
"h_denomn_pub", "h_denom_pub",
GNUNET_JSON_from_data_auto (&h_denom_pub), GNUNET_JSON_from_data_auto (&h_denom_pub),
"master_sig", "master_sig",
GNUNET_JSON_from_data_auto (&master_sig)))); GNUNET_JSON_from_data_auto (&master_sig))));
@ -2375,17 +2437,17 @@ do_sign (char *const *args)
{ {
json_error_t err; json_error_t err;
out = json_loadf (stdin, in = json_loadf (stdin,
JSON_REJECT_DUPLICATES, JSON_REJECT_DUPLICATES,
&err); &err);
if (NULL == in) if (NULL == in)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to read JSON input: %s at %d:%s (offset: %d)\n", "Failed to read JSON input: %s at %d:%s (offset: %d)\n",
err.text, err.text,
err.line, err.line,
err.source, err.source,
err.position); err.position);
global_ret = 2; global_ret = 2;
test_shutdown (); test_shutdown ();
return; return;
@ -2422,10 +2484,13 @@ do_sign (char *const *args)
&err_name, &err_name,
&err_line)) &err_line))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid input to 'sign': %s#%u (skipping)\n", "Invalid input to 'sign': %s#%u (skipping)\n",
err_name, err_name,
err_line); err_line);
json_dumpf (in,
stderr,
JSON_INDENT (2));
global_ret = 7; global_ret = 7;
test_shutdown (); test_shutdown ();
return; return;
@ -2434,8 +2499,8 @@ do_sign (char *const *args)
GNUNET_memcmp (&master_pub, GNUNET_memcmp (&master_pub,
&mpub)) &mpub))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Fatal: exchange uses different master key!\n"); "Fatal: exchange uses different master key!\n");
global_ret = 6; global_ret = 6;
test_shutdown (); test_shutdown ();
GNUNET_JSON_parse_free (spec); GNUNET_JSON_parse_free (spec);
@ -2444,8 +2509,8 @@ do_sign (char *const *args)
if (GNUNET_SYSERR == if (GNUNET_SYSERR ==
tofu_check (secm)) tofu_check (secm))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Fatal: security module keys changed!\n"); "Fatal: security module keys changed!\n");
global_ret = 8; global_ret = 8;
test_shutdown (); test_shutdown ();
GNUNET_JSON_parse_free (spec); GNUNET_JSON_parse_free (spec);
@ -2458,11 +2523,11 @@ do_sign (char *const *args)
GNUNET_assert (NULL != signkey_sig_array); GNUNET_assert (NULL != signkey_sig_array);
GNUNET_assert (NULL != denomkey_sig_array); GNUNET_assert (NULL != denomkey_sig_array);
if ( (GNUNET_OK != if ( (GNUNET_OK !=
sign_signkeys (&secm[0], sign_signkeys (&secm[1],
signkeys, signkeys,
signkey_sig_array)) || signkey_sig_array)) ||
(GNUNET_OK != (GNUNET_OK !=
sign_denomkeys (&secm[1], sign_denomkeys (&secm[0],
denomkeys, denomkeys,
denomkey_sig_array)) ) denomkey_sig_array)) )
{ {
@ -2569,19 +2634,20 @@ work (void *cls)
if (0 != strcasecmp ("help", if (0 != strcasecmp ("help",
args[0])) args[0]))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Unexpected command `%s'\n", "Unexpected command `%s'\n",
args[0]); args[0]);
global_ret = 3; global_ret = 3;
} }
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Supported subcommands:\n");
"Supported subcommands:\n");
for (unsigned int i = 0; NULL != cmds[i].name; i++) for (unsigned int i = 0; NULL != cmds[i].name; i++)
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"\t%s - %s\n", "\t%s - %s\n",
cmds[i].name, cmds[i].name,
cmds[i].help); cmds[i].help);
} }
} }
@ -2634,10 +2700,6 @@ main (int argc,
not do this, the linker may "optimize" libtalerutil not do this, the linker may "optimize" libtalerutil
away and skip #TALER_OS_init(), which we do need */ away and skip #TALER_OS_init(), which we do need */
(void) TALER_project_data_default (); (void) TALER_project_data_default ();
GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-exchange-offline",
"WARNING",
NULL));
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc, argv, GNUNET_PROGRAM_run (argc, argv,
"taler-exchange-offline", "taler-exchange-offline",

View File

@ -8054,8 +8054,8 @@ postgres_insert_auditor (void *cls,
{ {
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (auditor_pub), GNUNET_PQ_query_param_auto_from_type (auditor_pub),
GNUNET_PQ_query_param_string (auditor_url),
GNUNET_PQ_query_param_string (auditor_name), GNUNET_PQ_query_param_string (auditor_name),
GNUNET_PQ_query_param_string (auditor_url),
GNUNET_PQ_query_param_absolute_time (&start_date), GNUNET_PQ_query_param_absolute_time (&start_date),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
@ -8545,7 +8545,7 @@ postgres_add_denomination_key (
{ {
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam iparams[] = { struct GNUNET_PQ_QueryParam iparams[] = {
GNUNET_PQ_query_param_auto_from_type (&h_denom_pub), GNUNET_PQ_query_param_auto_from_type (h_denom_pub),
GNUNET_PQ_query_param_rsa_public_key (denom_pub->rsa_public_key), GNUNET_PQ_query_param_rsa_public_key (denom_pub->rsa_public_key),
GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_auto_from_type (master_sig), GNUNET_PQ_query_param_auto_from_type (master_sig),
@ -8604,7 +8604,7 @@ postgres_activate_signing_key (
{ {
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam iparams[] = { struct GNUNET_PQ_QueryParam iparams[] = {
GNUNET_PQ_query_param_auto_from_type (&exchange_pub), GNUNET_PQ_query_param_auto_from_type (exchange_pub),
TALER_PQ_query_param_absolute_time (&meta->start), TALER_PQ_query_param_absolute_time (&meta->start),
TALER_PQ_query_param_absolute_time (&meta->expire_sign), TALER_PQ_query_param_absolute_time (&meta->expire_sign),
TALER_PQ_query_param_absolute_time (&meta->expire_legal), TALER_PQ_query_param_absolute_time (&meta->expire_legal),