diff options
-rw-r--r-- | doc/taler-auditor.1 | 2 | ||||
-rw-r--r-- | src/auditor/taler-auditor.c | 47 | ||||
-rw-r--r-- | src/auditor/taler-wire-auditor.c | 47 |
3 files changed, 83 insertions, 13 deletions
diff --git a/doc/taler-auditor.1 b/doc/taler-auditor.1 index 7682bf95f..dc4da2381 100644 --- a/doc/taler-auditor.1 +++ b/doc/taler-auditor.1 @@ -17,7 +17,7 @@ taler\-auditor \- Audit exchange. Print short help on options. .B .IP "\-m KEY, \-\-exchange-key=KEY" -Public master key of the exchange in Crockford base32 encoding, for example as generated by gnunet\-ecc \-p. +Public master key of the exchange in Crockford base32 encoding, for example as generated by gnunet\-ecc \-p. If this option is missing, taler\-auditor will use the MASTER_PUBLIC_KEY value from the "exchange" section of the configuration. .B .IP "\-r, \-\-reset" Reset the audit, starts everything from the beginning. Useful for testing and required for the first audit to setup auditor's tables. Note that if (just) the exchange key changes, the \-r option should not be used again. diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index d33b23dff..faaf55193 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -3901,12 +3901,48 @@ run (void *cls, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { + static const struct TALER_MasterPublicKeyP zeromp; struct TALER_Amount income_fee_total; json_t *report; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Launching auditor\n"); cfg = c; + if (0 == memcmp (&zeromp, + &master_pub, + sizeof (struct TALER_MasterPublicKeyP))) + { + /* -m option not given, try configuration */ + char *master_public_key_str; + + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, + "exchange", + "MASTER_PUBLIC_KEY", + &master_public_key_str)) + { + fprintf (stderr, + "Pass option -m or set it in the configuration!\n"); + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "MASTER_PUBLIC_KEY"); + global_ret = 1; + return; + } + if (GNUNET_OK != + GNUNET_CRYPTO_eddsa_public_key_from_string (master_public_key_str, + strlen (master_public_key_str), + &master_pub.eddsa_pub)) + { + fprintf (stderr, + "Invalid master public key given in configuration file."); + GNUNET_free (master_public_key_str); + global_ret = 1; + return; + } + GNUNET_free (master_public_key_str); + } /* end of -m not given */ + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "taler", @@ -4163,12 +4199,11 @@ main (int argc, char *const *argv) { const struct GNUNET_GETOPT_CommandLineOption options[] = { - GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_base32_auto ('m', - "exchange-key", - "KEY", - "public key of the exchange (Crockford base32 encoded)", - &master_pub)), + GNUNET_GETOPT_option_base32_auto ('m', + "exchange-key", + "KEY", + "public key of the exchange (Crockford base32 encoded)", + &master_pub), GNUNET_GETOPT_option_flag ('r', "restart", "restart audit from the beginning (required on first run)", diff --git a/src/auditor/taler-wire-auditor.c b/src/auditor/taler-wire-auditor.c index f34fc7e71..4ee92566e 100644 --- a/src/auditor/taler-wire-auditor.c +++ b/src/auditor/taler-wire-auditor.c @@ -1091,12 +1091,48 @@ run (void *cls, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { + static const struct TALER_MasterPublicKeyP zeromp; enum GNUNET_DB_QueryStatus qs; int ret; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Launching auditor\n"); cfg = c; + if (0 == memcmp (&zeromp, + &master_pub, + sizeof (struct TALER_MasterPublicKeyP))) + { + /* -m option not given, try configuration */ + char *master_public_key_str; + + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, + "exchange", + "MASTER_PUBLIC_KEY", + &master_public_key_str)) + { + fprintf (stderr, + "Pass option -m or set it in the configuration!\n"); + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "MASTER_PUBLIC_KEY"); + global_ret = 1; + return; + } + if (GNUNET_OK != + GNUNET_CRYPTO_eddsa_public_key_from_string (master_public_key_str, + strlen (master_public_key_str), + &master_pub.eddsa_pub)) + { + fprintf (stderr, + "Invalid master public key given in configuration file."); + GNUNET_free (master_public_key_str); + global_ret = 1; + return; + } + GNUNET_free (master_public_key_str); + } /* end of -m not given */ + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "taler", @@ -1305,12 +1341,11 @@ main (int argc, char *const *argv) { const struct GNUNET_GETOPT_CommandLineOption options[] = { - GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_base32_auto ('m', - "exchange-key", - "KEY", - "public key of the exchange (Crockford base32 encoded)", - &master_pub)), + GNUNET_GETOPT_option_base32_auto ('m', + "exchange-key", + "KEY", + "public key of the exchange (Crockford base32 encoded)", + &master_pub), GNUNET_GETOPT_option_flag ('r', "restart", "restart audit from the beginning (required on first run)", |