diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-04-10 17:10:20 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-04-10 17:10:20 +0200 |
commit | 30d66bcebc27a1cdcbad39ddbeeaf047da6cc1dd (patch) | |
tree | b78ddf34d0360b2cf87037009d32dac0d3eaeb91 | |
parent | 5fb65f59b2de184f4fcb1417923711bd64fe781a (diff) |
fixing #4386: use more sane configuration and data file structure
39 files changed, 496 insertions, 313 deletions
diff --git a/.gitignore b/.gitignore index ce73b4d26..fc31e919e 100644 --- a/.gitignore +++ b/.gitignore @@ -31,8 +31,10 @@ src/lib/test_exchange_api doc/doxygen/doxygen_sqlite3.db src/bank-lib/test_bank_api src/exchange-lib/test_exchange_api +src/exchange-lib/test_exchange_api_home/.local/share/taler/exchange/live-keys/ src/exchange/taler-exchange-aggregator src/exchange/test_taler_exchange_aggregator-postgres +src/exchange/test_taler_exchange_httpd_home/.local/share/taler/exchange/live-keys/ src/exchange-tools/taler-auditor-sign src/exchange-tools/taler-exchange-dbinit src/exchange-tools/taler-exchange-keycheck diff --git a/doc/taler.conf.5 b/doc/taler.conf.5 index e4c7083d6..1d03927ea 100644 --- a/doc/taler.conf.5 +++ b/doc/taler.conf.5 @@ -1,14 +1,14 @@ -.TH TALER.CONF 5 "Aug 11, 2015" "GNU Taler" +.TH TALER.CONF 5 "Apr 11, 2016" "GNU Taler" .SH NAME taler.conf \- Taler configuration file. .SH SYNOPSIS -.B DIRNAME/taler.conf +.B taler.conf .SH DESCRIPTION -The basic structure of the configuration file is the following. The file is split into sections. Every section begins with "[SECTIONNAME]" and contains a number of options of the form "OPTION=VALUE". Empty lines and lines beginning with a "#" are treated as comments. +The basic structure of the configuration file is the following. The file is split into sections. Every section begins with "[SECTIONNAME]" and contains a number of options of the form "OPTION=VALUE". Empty lines and lines beginning with a "#" are treated as comments. Files containing default values for many of the options described below are installed under \$TALER\_PREFIX/share/taler/config.d/. The configuration file given with \-c to Taler binaries overrides these defaults. .SH EXCHANGE OPTIONS diff --git a/src/exchange-lib/Makefile.am b/src/exchange-lib/Makefile.am index 49cb234a1..58a903342 100644 --- a/src/exchange-lib/Makefile.am +++ b/src/exchange-lib/Makefile.am @@ -61,5 +61,6 @@ test_exchange_api_LDADD = \ -ljansson EXTRA_DIST = \ - test-exchange-home/config/exchange-common.conf \ - test-exchange-home/master.priv + test_taler_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv \ + test_taler_exchange_api_home/.config/taler/sepa.json \ + test_taler_exchange_api.conf diff --git a/src/exchange-lib/test-exchange-home/config/exchange-common.conf b/src/exchange-lib/test-exchange-home/config/exchange-common.conf deleted file mode 100644 index 97947f111..000000000 --- a/src/exchange-lib/test-exchange-home/config/exchange-common.conf +++ /dev/null @@ -1,41 +0,0 @@ -[exchange] -# Currency supported by the exchange (can only be one) -CURRENCY = EUR - -# Wire format supported by the exchange -# We use 'test' for testing of the actual -# coin operations, and 'sepa' to test SEPA-specific routines. -WIREFORMAT = test sepa - -# HTTP port the exchange listens to -PORT = 8081 - -# Master public key used to sign the exchange's various keys -MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG - -# How to access our database -DB = postgres - -# Is this is a testcase, use transient DB actions? -TESTRUN = YES - -[exchangedb-postgres] -DB_CONN_STR = "postgres:///talercheck" - -[wire-incoming-sepa] -SEPA_RESPONSE_FILE = "test-exchange-home/sepa.json" - -[wire-incoming-sepa] -SEPA_RESPONSE_FILE = "test-exchange-home/sepa.json" - -[wire-incoming-test] -# What is the main website of the bank? -BANK_URI = "http://localhost/" -# Into which account at the 'bank' should (incoming) wire transfers be made? -BANK_ACCOUNT_NUMBER = 2 - -[wire-outgoing-test] -# What is the main website of the bank? -BANK_URI = "http://localhost/" -# Into which account at the 'bank' should (incoming) wire transfers be made? -BANK_ACCOUNT_NUMBER = 2 diff --git a/src/exchange-lib/test_exchange_api.c b/src/exchange-lib/test_exchange_api.c index c7eb9e314..68f4852be 100644 --- a/src/exchange-lib/test_exchange_api.c +++ b/src/exchange-lib/test_exchange_api.c @@ -2539,13 +2539,15 @@ main (int argc, GNUNET_log_setup ("test-exchange-api", "WARNING", NULL); + /* These might get in the way... */ + unsetenv ("XDG_DATA_HOME"); + unsetenv ("XDG_CONFIG_HOME"); proc = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL, NULL, NULL, "taler-exchange-keyup", "taler-exchange-keyup", - "-d", "test-exchange-home", - "-m", "test-exchange-home/master.priv", + "-c", "test_exchange_api.conf", NULL); GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); @@ -2554,7 +2556,7 @@ main (int argc, NULL, NULL, NULL, "taler-exchange-httpd", "taler-exchange-httpd", - "-d", "test-exchange-home", + "-c", "test_exchange_api.conf", NULL); /* give child time to start and bind against the socket */ fprintf (stderr, "Waiting for taler-exchange-httpd to be ready"); diff --git a/src/exchange-lib/test-exchange-home/config/exchange-keyup.conf b/src/exchange-lib/test_exchange_api.conf index 4a80da7e9..e1e916bd2 100644 --- a/src/exchange-lib/test-exchange-home/config/exchange-keyup.conf +++ b/src/exchange-lib/test_exchange_api.conf @@ -1,24 +1,45 @@ -[exchange_keys] +# This file is in the public domain. +# +[PATHS] +# Persistant data storage for the testcase +TALER_TEST_HOME = test_exchange_api_home/ -# how long is one signkey valid? -signkey_duration = 4 weeks +[exchange] +# Currency supported by the exchange (can only be one) +CURRENCY = EUR -# how long are the signatures with the signkey valid? -legal_duration = 2 years +# Wire format supported by the exchange +# We use 'test' for testing of the actual +# coin operations, and 'sepa' to test SEPA-specific routines. +WIREFORMAT = test sepa -# how long do we generate denomination and signing keys -# ahead of time? -lookahead_sign = 32 weeks 1 day +# HTTP port the exchange listens to +PORT = 8081 -# how long do we provide to clients denomination and signing keys -# ahead of time? -lookahead_provide = 4 weeks 1 day +# Master public key used to sign the exchange's various keys +MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG +# How to access our database +DB = postgres + +# Is this is a testcase, use transient DB actions? +TESTRUN = YES + +[exchangedb-postgres] +DB_CONN_STR = "postgres:///talercheck" + +[wire-incoming-test] +# What is the main website of the bank? +BANK_URI = "http://localhost/" +# Into which account at the 'bank' should (incoming) wire transfers be made? +BANK_ACCOUNT_NUMBER = 2 + +[wire-outgoing-test] +# What is the main website of the bank? +BANK_URI = "http://localhost/" +# Into which account at the 'bank' should (incoming) wire transfers be made? +BANK_ACCOUNT_NUMBER = 2 -# Coin definitions are detected because the section -# name begins with "coin_". The rest of the -# name is free, but of course following the convention -# of "coin_$CURRENCY[_$SUBUNIT]_$VALUE" make sense. [coin_eur_ct_1] value = EUR:0.01 duration_overlap = 5 minutes @@ -73,14 +94,3 @@ fee_withdraw = EUR:0.01 fee_deposit = EUR:0.01 fee_refresh = EUR:0.03 rsa_keysize = 1024 - -[coin_eur_1000] -value = EUR:1000 -duration_overlap = 5 minutes -duration_withdraw = 7 days -duration_spend = 2 years -duration_legal = 3 years -fee_withdraw = EUR:0.01 -fee_deposit = EUR:0.01 -fee_refresh = EUR:0.03 -rsa_keysize = 2048 diff --git a/src/exchange-lib/test-exchange-home/sepa.json b/src/exchange-lib/test_exchange_api_home/.config/taler/sepa.json index b435ce86b..b435ce86b 100644 --- a/src/exchange-lib/test-exchange-home/sepa.json +++ b/src/exchange-lib/test_exchange_api_home/.config/taler/sepa.json diff --git a/src/exchange-lib/test-exchange-home/master.priv b/src/exchange-lib/test_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv index 394926938..394926938 100644 --- a/src/exchange-lib/test-exchange-home/master.priv +++ b/src/exchange-lib/test_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv diff --git a/src/exchange-tools/Makefile.am b/src/exchange-tools/Makefile.am index feb3c314f..d283979c8 100644 --- a/src/exchange-tools/Makefile.am +++ b/src/exchange-tools/Makefile.am @@ -1,6 +1,14 @@ # This Makefile.am is in the public domain AM_CPPFLAGS = -I$(top_srcdir)/src/include +pkgcfgdir = $(prefix)/share/taler/config.d/ + +pkgcfg_DATA = \ + auditor.conf \ + exchange-signkeys.conf \ + coins.conf + + if USE_COVERAGE AM_CFLAGS = --coverage -O0 XLIB = -lgcov @@ -81,3 +89,7 @@ taler_exchange_dbinit_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/pq/ \ $(POSTGRESQL_CPPFLAGS) + + +EXTRA_DIST = \ + auditor.conf diff --git a/src/exchange-tools/auditor.conf b/src/exchange-tools/auditor.conf new file mode 100644 index 000000000..7eb5f8ae9 --- /dev/null +++ b/src/exchange-tools/auditor.conf @@ -0,0 +1,12 @@ +# This configuration file is in the public domain +# +# It cointains options for the auditor. + +[auditor] + +# Where do we store the auditor's private key? +AUDITOR_PRIV_FILE = ${TALER_DATA_HOME}/auditor/offline-keys/auditor.priv + +# What is the Web site of the auditor (i.e. to file complaints about +# a misbehaving exchange)? +# AUDITOR_URL = https://auditor.taler.net/ diff --git a/src/exchange-tools/coins.conf b/src/exchange-tools/coins.conf new file mode 100644 index 000000000..90bf7064c --- /dev/null +++ b/src/exchange-tools/coins.conf @@ -0,0 +1,25 @@ +# This configuration file is in the public domain +# +# This is a template file for coin definitions. There are no +# reasonable defaults, as legal and business concerns influence each +# value given. +# +# Note that while we only give one section here, you can define +# any number of coins by providing many "coin_" sections. +# +# Coin definitions are detected because the section name begins with +# "coin_". The rest of the name is free, but of course following the +# convention of "coin_$CURRENCY[_$SUBUNIT]_$VALUE" make sense. +# +# [coin_eur_ct_1] + +# All options are mandatory! +# value = EUR:0.01 +# duration_overlap = 60 minutes +# duration_withdraw = 7 days +# duration_spend = 2 years +# duration_legal = 3 years +# fee_withdraw = EUR:0.00 +# fee_deposit = EUR:0.00 +# fee_refresh = EUR:0.01 +# rsa_keysize = 1024 diff --git a/src/exchange-tools/exchange-signkeys.conf b/src/exchange-tools/exchange-signkeys.conf new file mode 100644 index 000000000..3146f09b2 --- /dev/null +++ b/src/exchange-tools/exchange-signkeys.conf @@ -0,0 +1,16 @@ +# General data for signing keys. +[exchange_keys] + +# how long is one signkey valid? +signkey_duration = 4 weeks + +# how long are the signatures with the signkey valid? +legal_duration = 2 years + +# how long do we generate denomination and signing keys +# ahead of time? +lookahead_sign = 32 weeks 1 day + +# how long do we provide to clients denomination and signing keys +# ahead of time? +lookahead_provide = 4 weeks 1 day diff --git a/src/exchange-tools/taler-auditor-sign.c b/src/exchange-tools/taler-auditor-sign.c index 870f889ea..d5a3a9403 100644 --- a/src/exchange-tools/taler-auditor-sign.c +++ b/src/exchange-tools/taler-auditor-sign.c @@ -59,6 +59,11 @@ static char *auditor_url; */ static struct TALER_MasterPublicKeyP master_public_key; +/** + * Our configuration. + */ +static struct GNUNET_CONFIGURATION_Handle *cfg; + /** * Print denomination key details for diagnostics. @@ -131,10 +136,12 @@ int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'a', "auditor-key", "FILE", + char *cfgfile = NULL; + const struct GNUNET_GETOPT_CommandLineOption options[] = { + {'a', "auditor-key", "FILENAME", "file containing the private key of the auditor", 1, &GNUNET_GETOPT_set_filename, &auditor_key_file}, + GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), GNUNET_GETOPT_OPTION_HELP ("Private key of the auditor to use for signing"), {'m', "exchange-key", "KEY", "public key of the exchange (Crockford base32 encoded)", 1, @@ -142,10 +149,10 @@ main (int argc, {'u', "auditor-url", "URL", "URL of the auditor (informative link for the user)", 1, &GNUNET_GETOPT_set_string, &auditor_url}, - {'r', "exchange-request", "FILE", + {'r', "exchange-request", "FILENAME", "set of keys the exchange requested the auditor to sign", 1, &GNUNET_GETOPT_set_string, &exchange_request_file}, - {'o', "output", "FILE", + {'o', "output", "FILENAME", "where to write our signature", 1, &GNUNET_GETOPT_set_string, &output_file}, GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION), @@ -163,20 +170,41 @@ main (int argc, unsigned int i; GNUNET_assert (GNUNET_OK == - GNUNET_log_setup ("taler-exchange-keyup", + GNUNET_log_setup ("taler-auditor-sign", "WARNING", NULL)); - if (GNUNET_GETOPT_run ("taler-exchange-keyup", + if (GNUNET_GETOPT_run ("taler-auditor-sign", options, argc, argv) < 0) return 1; - if (NULL == auditor_key_file) + cfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, + cfgfile)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Malformed configuration file `%s', exit ...\n"), + cfgfile); + GNUNET_free_non_null (cfgfile); + return 1; + } + GNUNET_free_non_null (cfgfile); + if ( (NULL == auditor_key_file) && + (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, + "auditor", + "AUDITOR_PRIV_FILE", + &auditor_key_file)) ) { fprintf (stderr, - "Auditor key file not given\n"); + "Auditor key file not given in neither configuration nor command-line\n"); return 1; } - if (NULL == auditor_url) + if ( (NULL == auditor_url) && + (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, + "auditor", + "AUDITOR_URL", + &auditor_url)) ) { fprintf (stderr, "Auditor URL not given\n"); @@ -328,6 +356,7 @@ main (int argc, GNUNET_free (dks); return 1; } + GNUNET_free (sigs); GNUNET_free (dks); GNUNET_free (eddsa_priv); diff --git a/src/exchange-tools/taler-exchange-dbinit.c b/src/exchange-tools/taler-exchange-dbinit.c index 43a070228..9f301854f 100644 --- a/src/exchange-tools/taler-exchange-dbinit.c +++ b/src/exchange-tools/taler-exchange-dbinit.c @@ -20,24 +20,8 @@ */ #include "platform.h" #include <gnunet/gnunet_util_lib.h> -#include <libpq-fe.h> #include "taler_exchangedb_plugin.h" -/** - * Exchange directory with the keys. - */ -static char *exchange_base_dir; - -/** - * Our configuration. - */ -static struct GNUNET_CONFIGURATION_Handle *cfg; - -/** - * Our DB plugin. - */ -static struct TALER_EXCHANGEDB_Plugin *plugin; - /** * The main function of the database initialization tool. @@ -51,14 +35,15 @@ int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'d', "exchange-dir", "DIR", - "exchange directory", 1, - &GNUNET_GETOPT_set_filename, &exchange_base_dir}, + char *cfgfile = NULL; + const struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), GNUNET_GETOPT_OPTION_HELP ("Initialize Taler Exchange database"), GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION), GNUNET_GETOPT_OPTION_END }; + struct GNUNET_CONFIGURATION_Handle *cfg; + struct TALER_EXCHANGEDB_Plugin *plugin; if (GNUNET_GETOPT_run ("taler-exchange-dbinit", options, @@ -69,24 +54,23 @@ main (int argc, GNUNET_log_setup ("taler-exchange-dbinit", "INFO", NULL)); - if (NULL == exchange_base_dir) + cfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, + cfgfile)) { - fprintf (stderr, - "Exchange base directory not given.\n"); - return 1; - } - cfg = TALER_config_load (exchange_base_dir); - if (NULL == cfg) - { - fprintf (stderr, - "Failed to load exchange configuration.\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Malformed configuration file `%s', exit ...\n"), + cfgfile); + GNUNET_free_non_null (cfgfile); return 1; } + GNUNET_free_non_null (cfgfile); if (NULL == (plugin = TALER_EXCHANGEDB_plugin_load (cfg))) { fprintf (stderr, "Failed to initialize database plugin.\n"); + GNUNET_CONFIGURATION_destroy (cfg); return 1; } if (GNUNET_OK != @@ -96,9 +80,11 @@ main (int argc, fprintf (stderr, "Failed to initialize database.\n"); TALER_EXCHANGEDB_plugin_unload (plugin); + GNUNET_CONFIGURATION_destroy (cfg); return 1; } TALER_EXCHANGEDB_plugin_unload (plugin); + GNUNET_CONFIGURATION_destroy (cfg); return 0; } diff --git a/src/exchange-tools/taler-exchange-keycheck.c b/src/exchange-tools/taler-exchange-keycheck.c index d6566cd03..064f2249e 100644 --- a/src/exchange-tools/taler-exchange-keycheck.c +++ b/src/exchange-tools/taler-exchange-keycheck.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015 GNUnet e.V. + Copyright (C) 2014, 2015, 2016 GNUnet e.V. TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -104,8 +104,8 @@ static int exchange_signkeys_check () { if (0 > TALER_EXCHANGEDB_signing_keys_iterate (exchange_directory, - &signkeys_iter, - NULL)) + &signkeys_iter, + NULL)) return GNUNET_NO; return GNUNET_OK; } @@ -186,8 +186,8 @@ static int exchange_denomkeys_check () { if (0 > TALER_EXCHANGEDB_denomination_keys_iterate (exchange_directory, - &denomkeys_iter, - NULL)) + &denomkeys_iter, + NULL)) return GNUNET_NO; return GNUNET_OK; } @@ -203,11 +203,10 @@ exchange_denomkeys_check () int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { + char *cfgfile; + const struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), GNUNET_GETOPT_OPTION_HELP ("gnunet-exchange-keycheck OPTIONS"), - {'d', "directory", "DIRECTORY", - "exchange directory with keys to check", 1, - &GNUNET_GETOPT_set_filename, &exchange_directory}, GNUNET_GETOPT_OPTION_END }; @@ -220,20 +219,29 @@ main (int argc, char *const *argv) options, argc, argv) < 0) return 1; - if (NULL == exchange_directory) + kcfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (kcfg, + cfgfile)) { - fprintf (stderr, - "Exchange directory not given\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Malformed configuration file `%s', exit ...\n"), + cfgfile); + GNUNET_free_non_null (cfgfile); return 1; } - - kcfg = TALER_config_load (exchange_directory); - if (NULL == kcfg) + GNUNET_free_non_null (cfgfile); + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (kcfg, + "exchange", + "KEYDIR", + &exchange_directory)) { - fprintf (stderr, - "Failed to load exchange configuration\n"); + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "KEYDIR"); return 1; } + if ( (GNUNET_OK != exchange_signkeys_check ()) || (GNUNET_OK != exchange_denomkeys_check ()) ) { diff --git a/src/exchange-tools/taler-exchange-keyup.c b/src/exchange-tools/taler-exchange-keyup.c index 3413dfb42..ab2123a15 100644 --- a/src/exchange-tools/taler-exchange-keyup.c +++ b/src/exchange-tools/taler-exchange-keyup.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015 GNUnet e.V. + Copyright (C) 2014, 2015, 2016 GNUnet e.V. TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -876,10 +876,9 @@ int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'d', "exchange-dir", "DIR", - "exchange directory with keys to update", 1, - &GNUNET_GETOPT_set_filename, &exchange_directory}, + char *cfgfile = NULL; + const struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), GNUNET_GETOPT_OPTION_HELP ("Setup signing and denomination keys for a Taler exchange"), {'m', "master-key", "FILE", "master key file (private key)", 1, @@ -905,12 +904,17 @@ main (int argc, options, argc, argv) < 0) return 1; - if (NULL == exchange_directory) + kcfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (kcfg, + cfgfile)) { - fprintf (stderr, - "Exchange directory not given\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Malformed configuration file `%s', exit ...\n"), + cfgfile); + GNUNET_free_non_null (cfgfile); return 1; } + GNUNET_free_non_null (cfgfile); if (NULL != pretend_time_str) { if (GNUNET_OK != @@ -928,18 +932,26 @@ main (int argc, now = GNUNET_TIME_absolute_get (); } GNUNET_TIME_round_abs (&now); - - kcfg = TALER_config_load (exchange_directory); - if (NULL == kcfg) + if ( (NULL == masterkeyfile) && + (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (kcfg, + "exchange", + "MASTER_PRIV_FILE", + &masterkeyfile)) ) { fprintf (stderr, - "Failed to load exchange configuration\n"); + "Master key file not given in neither configuration nor command-line\n"); return 1; } - if (NULL == masterkeyfile) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (kcfg, + "exchange", + "KEYDIR", + &exchange_directory)) { - fprintf (stderr, - "Master key file not given\n"); + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "KEYDIR"); return 1; } eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile); diff --git a/src/exchange-tools/taler-exchange-reservemod.c b/src/exchange-tools/taler-exchange-reservemod.c index 03a0d17d5..3494e88a0 100644 --- a/src/exchange-tools/taler-exchange-reservemod.c +++ b/src/exchange-tools/taler-exchange-reservemod.c @@ -51,6 +51,7 @@ static struct TALER_EXCHANGEDB_Plugin *plugin; int main (int argc, char *const *argv) { + char *cfgfile = NULL; char *reserve_pub_str = NULL; char *add_str = NULL; struct TALER_Amount add_value; @@ -63,10 +64,8 @@ main (int argc, char *const *argv) {'a', "add", "DENOM", "value to add", 1, &GNUNET_GETOPT_set_string, &add_str}, - {'d', "exchange-dir", "DIR", - "exchange directory with keys to update", 1, - &GNUNET_GETOPT_set_filename, &exchange_directory}, - {'D', "details", "JSON", + GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), + {'d', "details", "JSON", "details about the bank transaction which justify why we add this amount", 1, &GNUNET_GETOPT_set_string, &details}, GNUNET_GETOPT_OPTION_HELP ("Deposit funds into a Taler reserve"), @@ -87,10 +86,29 @@ main (int argc, char *const *argv) options, argc, argv) < 0) return 1; - if (NULL == exchange_directory) + cfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, + cfgfile)) { - fprintf (stderr, - "Exchange directory not given\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Malformed configuration file `%s', exit ...\n"), + cfgfile); + GNUNET_free_non_null (cfgfile); + GNUNET_free_non_null (add_str); + GNUNET_free_non_null (details); + GNUNET_free_non_null (reserve_pub_str); + return 1; + } + GNUNET_free_non_null (cfgfile); + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, + "exchange", + "KEYDIR", + &exchange_directory)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "KEYDIR"); GNUNET_free_non_null (add_str); GNUNET_free_non_null (details); GNUNET_free_non_null (reserve_pub_str); @@ -133,16 +151,6 @@ main (int argc, char *const *argv) return 1; } - cfg = TALER_config_load (exchange_directory); - if (NULL == cfg) - { - fprintf (stderr, - "Failed to load exchange configuration\n"); - GNUNET_free_non_null (add_str); - GNUNET_free_non_null (details); - GNUNET_free_non_null (reserve_pub_str); - return 1; - } ret = 1; if (NULL == (plugin = TALER_EXCHANGEDB_plugin_load (cfg))) diff --git a/src/exchange-tools/taler-exchange-wire.c b/src/exchange-tools/taler-exchange-wire.c index 5bb4835de..930086d39 100644 --- a/src/exchange-tools/taler-exchange-wire.c +++ b/src/exchange-tools/taler-exchange-wire.c @@ -46,6 +46,11 @@ static char *method; */ static char *output_filename; +/** + * Our configuration. + */ +static struct GNUNET_CONFIGURATION_Handle *cfg; + /** * The main function of the taler-exchange-sepa tool. This tool is used @@ -59,7 +64,9 @@ int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { + char *cfgfile = NULL; + const struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), {'j', "json", "JSON", "account information in JSON format", 1, &GNUNET_GETOPT_set_string, &json_in}, @@ -95,10 +102,26 @@ main (int argc, options, argc, argv) < 0) return 1; - if (NULL == masterkeyfile) + cfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, + cfgfile)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Malformed configuration file `%s', exit ...\n"), + cfgfile); + GNUNET_free_non_null (cfgfile); + return 1; + } + GNUNET_free_non_null (cfgfile); + if ( (NULL == masterkeyfile) && + (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, + "exchange-master", + "MASTER_PRIV_FILE", + &masterkeyfile)) ) { fprintf (stderr, - "Master key file not given\n"); + "Master key file not given in neither configuration nor command-line\n"); return 1; } eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile); diff --git a/src/exchange/Makefile.am b/src/exchange/Makefile.am index e815d911b..dc7225b0c 100644 --- a/src/exchange/Makefile.am +++ b/src/exchange/Makefile.am @@ -89,4 +89,6 @@ TESTS = \ EXTRA_DIST = \ test-taler-exchange-aggregator-postgres.conf \ + test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv \ + test_taler_exchange_httpd.conf \ exchange.conf diff --git a/src/exchange/exchange.conf b/src/exchange/exchange.conf index 6a4f03ac1..eab476ccd 100644 --- a/src/exchange/exchange.conf +++ b/src/exchange/exchange.conf @@ -1,13 +1,20 @@ +# This file is in the public domain. +# [exchange] # Currency supported by the exchange (can only be one) # CURRENCY = EUR -# Wire format supported by the exchange We use 'test' for testing of +# Where do we store the private keys the exchange needs at +# runtime? (Denomination and signing keys are then stored +# in respective subdirectories.) +KEYDIR = ${TALER_DATA_HOME}/exchange/live-keys/ + +# Wire format supported by the exchange. We use 'test' for testing of # the actual coin operations. -WIREFORMAT = test +# WIREFORMAT = test # HTTP port the exchange listens to -PORT = 8081 +# PORT = 8081 # Master public key used to sign the exchange's various keys # MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG @@ -18,21 +25,5 @@ DB = postgres # Is this is a testcase, use transient DB actions? # TESTRUN = YES -[exchangedb-postgres] -DB_CONN_STR = "postgres:///taler" - - -[wire-incoming-test] -# What is the main website of the bank? -BANK_URI = "http://localhost:8082/" -# Into which account at the 'bank' should incoming -# wire transfers be made? -BANK_ACCOUNT_NUMBER = 2 - -[wire-outgoing-test] -# What is the main website of the bank? -BANK_URI = "http://localhost:8082/" - -# From which account at the 'bank' should outgoing -# wire transfers be made? -BANK_ACCOUNT_NUMBER = 3 +# Where do we store the offline master private key of the exchange? +MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c index 25ddcf3f6..e4ba975a2 100644 --- a/src/exchange/taler-exchange-aggregator.c +++ b/src/exchange/taler-exchange-aggregator.c @@ -135,11 +135,6 @@ static char *exchange_currency_string; static char *exchange_wireformat; /** - * Base directory of the exchange (global) - */ -static char *exchange_directory; - -/** * The exchange's configuration (global) */ static struct GNUNET_CONFIGURATION_Handle *cfg; @@ -238,26 +233,20 @@ shutdown_task (void *cls) } TALER_EXCHANGEDB_plugin_unload (db_plugin); TALER_WIRE_plugin_unload (wire_plugin); + GNUNET_CONFIGURATION_destroy (cfg); + cfg = NULL; } /** - * Load configuration parameters for the exchange - * server into the corresponding global variables. + * Parse configuration parameters for the exchange server into the + * corresponding global variables. * - * @param exchange_directory the exchange's directory * @return #GNUNET_OK on success */ static int -exchange_serve_process_config (const char *exchange_directory) +exchange_serve_process_config () { - cfg = TALER_config_load (exchange_directory); - if (NULL == cfg) - { - fprintf (stderr, - "Failed to load exchange configuration\n"); - return GNUNET_SYSERR; - } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "exchange", @@ -311,7 +300,6 @@ exchange_serve_process_config (const char *exchange_directory) exchange_wireformat); return GNUNET_SYSERR; } - return GNUNET_OK; } @@ -958,10 +946,24 @@ run_transfers (void *cls) * First task. * * @param cls closure, NULL + * @param args remaining command-line arguments + * @param cfgfile name of the configuration file used (for saving, can be NULL!) + * @param c configuration */ static void -run (void *cls) +run (void *cls, + char *const *args, + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { + cfg = GNUNET_CONFIGURATION_dup (c); + if (GNUNET_OK != exchange_serve_process_config ()) + { + GNUNET_CONFIGURATION_destroy (cfg); + cfg = NULL; + global_ret = 1; + return; + } task = GNUNET_SCHEDULER_add_now (&run_transfers, NULL); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, @@ -982,13 +984,9 @@ main (int argc, char *const *argv) { static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'d', "exchange-dir", "DIR", - "exchange directory with configuration and keys for operating the exchange", 1, - &GNUNET_GETOPT_set_filename, &exchange_directory}, {'f', "format", "WIREFORMAT", "wireformat to use, overrides WIREFORMAT option in [exchange] section", 1, &GNUNET_GETOPT_set_filename, &exchange_wireformat}, - GNUNET_GETOPT_OPTION_HELP ("background process that aggregates and executes wire transfers to merchants"), {'t', "test", NULL, "run in test mode with temporary tables", 0, &GNUNET_GETOPT_set_one, &test_mode}, @@ -996,30 +994,17 @@ main (int argc, GNUNET_GETOPT_OPTION_END }; - GNUNET_assert (GNUNET_OK == - GNUNET_log_setup ("taler-exchange-aggregator", - "INFO", - NULL)); - if (0 >= - GNUNET_GETOPT_run ("taler-exchange-aggregator", - options, - argc, argv)) - return 1; - if (NULL == exchange_directory) - { - fprintf (stderr, - "Exchange directory not specified\n"); - return 1; - } + if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, + &argc, &argv)) + return 2; if (GNUNET_OK != - exchange_serve_process_config (exchange_directory)) - { + GNUNET_PROGRAM_run (argc, argv, + "taler-exchange-aggregator", + gettext_noop ("background process that aggregates and executes wire transfers to merchants"), + options, + &run, NULL)) return 1; - } - global_ret = GNUNET_OK; - GNUNET_SCHEDULER_run (&run, NULL); - - return (GNUNET_SYSERR == global_ret) ? 1 : 0; + return global_ret; } /* end of taler-exchange-aggregator.c */ diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index 3061443b5..a8e9b3b08 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -360,16 +360,20 @@ handle_mhd_request (void *cls, * @return #GNUNET_OK on success */ static int -exchange_serve_process_config (const char *exchange_directory) +exchange_serve_process_config () { unsigned long long port; char *TMH_master_public_key_str; - cfg = TALER_config_load (exchange_directory); - if (NULL == cfg) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, + "exchange", + "KEYDIR", + &TMH_exchange_directory)) { - fprintf (stderr, - "Failed to load exchange configuration\n"); + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "KEYDIR"); return GNUNET_SYSERR; } if (GNUNET_OK != @@ -615,13 +619,12 @@ int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { + char *cfgfile = NULL; + const struct GNUNET_GETOPT_CommandLineOption options[] = { {'C', "connection-close", NULL, "force HTTP connections to be closed after each request", 0, &GNUNET_GETOPT_set_one, &TMH_exchange_connection_close}, - {'d', "exchange-dir", "DIR", - "exchange directory with configuration and keys for operating the exchange", 1, - &GNUNET_GETOPT_set_filename, &TMH_exchange_directory}, + GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), {'t', "timeout", "SECONDS", "after how long do connections timeout by default (in seconds)", 1, &GNUNET_GETOPT_set_uint, &connection_timeout}, @@ -645,15 +648,18 @@ main (int argc, options, argc, argv)) return 1; - if (NULL == TMH_exchange_directory) + cfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cfgfile)) { - fprintf (stderr, - "Exchange directory not specified\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Malformed configuration file `%s', exit ...\n"), + cfgfile); + GNUNET_free_non_null (cfgfile); return 1; } - + GNUNET_free_non_null (cfgfile); if (GNUNET_OK != - exchange_serve_process_config (TMH_exchange_directory)) + exchange_serve_process_config ()) return 1; mydaemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, diff --git a/src/exchange/taler-exchange-httpd_keystate.c b/src/exchange/taler-exchange-httpd_keystate.c index dbb72fab2..c9db50895 100644 --- a/src/exchange/taler-exchange-httpd_keystate.c +++ b/src/exchange/taler-exchange-httpd_keystate.c @@ -650,9 +650,9 @@ TMH_KS_acquire_ (const char *location) TALER_EXCHANGEDB_signing_keys_iterate (TMH_exchange_directory, &reload_keys_sign_iter, key_state); - TALER_EXCHANGEDB_auditor_iterate (TMH_exchange_directory, - &reload_auditor_iter, - key_state); + TALER_EXCHANGEDB_auditor_iterate (cfg, + &reload_auditor_iter, + key_state); ks.purpose.size = htonl (sizeof (ks)); ks.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_KEY_SET); ks.list_issue_date = GNUNET_TIME_absolute_hton (key_state->reload_time); diff --git a/src/exchange/test_taler_exchange_aggregator.c b/src/exchange/test_taler_exchange_aggregator.c index 80c14ed67..594f972c1 100644 --- a/src/exchange/test_taler_exchange_aggregator.c +++ b/src/exchange/test_taler_exchange_aggregator.c @@ -570,8 +570,7 @@ interpreter (void *cls) NULL, NULL, NULL, "taler-exchange-aggregator", "taler-exchange-aggregator", - /* "-c", config_filename, */ - "-d", "test-exchange-home", + "-c", "test_taler_exchange_httpd.conf", "-t", /* enable temporary tables */ NULL); return; @@ -1523,6 +1522,9 @@ main (int argc, "test-taler-exchange-aggregator-%s", plugin_name); (void) GNUNET_asprintf (&config_filename, "%s.conf", testname); + /* these might get in the way */ + unsetenv ("XDG_DATA_HOME"); + unsetenv ("XDG_CONFIG_HOME"); GNUNET_log_setup ("test_taler_exchange_aggregator", "WARNING", NULL); diff --git a/src/exchange/test-exchange-home/config/exchange-common.conf b/src/exchange/test_taler_exchange_httpd.conf index 4078cbee5..0ce9dadd2 100644 --- a/src/exchange/test-exchange-home/config/exchange-common.conf +++ b/src/exchange/test_taler_exchange_httpd.conf @@ -1,3 +1,8 @@ +[PATHS] +# Persistant data storage for the testcase +TALER_TEST_HOME = test_taler_exchange_httpd_home/ + + [exchange] # Currency supported by the exchange (can only be one) CURRENCY = EUR @@ -19,6 +24,9 @@ DB = postgres # Is this is a testcase, use transient DB actions? TESTRUN = YES + + + [exchangedb-postgres] DB_CONN_STR = "postgres:///talercheck" @@ -37,3 +45,38 @@ BANK_URI = "http://localhost:8082/" # From which account at the 'bank' should outgoing # wire transfers be made? BANK_ACCOUNT_NUMBER = 3 + + +# Coins for the tests. +[coin_eur_ct_1] +value = EUR:0.01 +duration_overlap = 5 minutes +duration_withdraw = 7 days +duration_spend = 2 years +duration_legal = 3 years +fee_withdraw = EUR:0.00 +fee_deposit = EUR:0.00 +fee_refresh = EUR:0.01 +rsa_keysize = 1024 + +[coin_eur_ct_10] +value = EUR:0.10 +duration_overlap = 5 minutes +duration_withdraw = 7 days +duration_spend = 2 years +duration_legal = 3 years +fee_withdraw = EUR:0.01 +fee_deposit = EUR:0.01 +fee_refresh = EUR:0.03 +rsa_keysize = 1024 + +[coin_eur_1] +value = EUR:1 +duration_overlap = 5 minutes +duration_withdraw = 7 days +duration_spend = 2 years +duration_legal = 3 years +fee_withdraw = EUR:0.01 +fee_deposit = EUR:0.01 +fee_refresh = EUR:0.03 +rsa_keysize = 1024 diff --git a/src/exchange/test_taler_exchange_httpd.sh b/src/exchange/test_taler_exchange_httpd.sh index 727014243..2b55ef5f4 100755 --- a/src/exchange/test_taler_exchange_httpd.sh +++ b/src/exchange/test_taler_exchange_httpd.sh @@ -1,7 +1,7 @@ #!/bin/bash # # This file is part of TALER -# Copyright (C) 2015 GNUnet e.V. +# Copyright (C) 2015, 2016 Inria and GNUnet e.V. # # TALER is free software; you can redistribute it and/or modify it under the # terms of the GNU Affero General Public License as published by the Free Software @@ -19,15 +19,19 @@ # taler-exchange-httpd. Basically, the goal is to make sure that the # HTTP server survives (and produces the 'correct' error code). # -# We read the JSON snippets to POST from test_taler_exchange_httpd.data +# +# Clear environment from variables that override config. +export XDG_DATA_HOME= +export XDG_CONFIG_HOME= # # Setup keys. -taler-exchange-keyup -d test-exchange-home -m test-exchange-home/master.priv +taler-exchange-keyup -c test_taler_exchange_httpd.conf # Run Exchange HTTPD (in background) -taler-exchange-httpd -d test-exchange-home & +taler-exchange-httpd -c test_taler_exchange_httpd.conf & # Give HTTP time to start sleep 5 -# Run test... +# Finally run test... +# We read the JSON snippets to POST from test_taler_exchange_httpd.data cat test_taler_exchange_httpd.data | grep -v ^\# | awk '{ print "curl -d \47" $2 "\47 http://localhost:8081" $1 }' | bash # Stop HTTP server kill -TERM %% diff --git a/src/exchange/test-exchange-home/master.priv b/src/exchange/test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv index 394926938..394926938 100644 --- a/src/exchange/test-exchange-home/master.priv +++ b/src/exchange/test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index fff112994..0c6a73138 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am @@ -6,6 +6,17 @@ if USE_COVERAGE XLIB = -lgcov endif +pkgcfgdir = $(prefix)/share/taler/config.d/ + +pkgcfg_DATA = \ + exchangedb.conf \ + exchangedb-postgres.conf + +EXTRA_DIST = \ + exchangedb.conf \ + exchangedb-postgres.conf + + plugindir = $(libdir)/taler if HAVE_POSTGRESQL diff --git a/src/exchangedb/exchangedb-postgres.conf b/src/exchangedb/exchangedb-postgres.conf new file mode 100644 index 000000000..3de7474ff --- /dev/null +++ b/src/exchangedb/exchangedb-postgres.conf @@ -0,0 +1,2 @@ +[exchangedb-postgres] +DB_CONN_STR = "postgres:///taler" diff --git a/src/exchangedb/exchangedb.conf b/src/exchangedb/exchangedb.conf new file mode 100644 index 000000000..19277ed23 --- /dev/null +++ b/src/exchangedb/exchangedb.conf @@ -0,0 +1,7 @@ +# This file is in the public domain. +# +# Database-backend independent specification for the exchangedb module. +# +[exchangedb] +# Where do we expect to find information about auditors? +AUDITOR_BASE_DIR = ${TALER_DATA_HOME}/auditors/ diff --git a/src/exchangedb/exchangedb_keyio.c b/src/exchangedb/exchangedb_keyio.c index 4d4f78ed5..9f170f645 100644 --- a/src/exchangedb/exchangedb_keyio.c +++ b/src/exchangedb/exchangedb_keyio.c @@ -502,9 +502,7 @@ auditor_iter (void *cls, /** * Call @a it with information for each auditor found in the @a exchange_base_dir. * - * @param exchange_base_dir base directory for the exchange, - * the signing keys must be in the #TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS - * subdirectory + * @param cfg configuration to use * @param it function to call with auditor information * @param it_cls closure for @a it * @return -1 on error, 0 if no files were found, otherwise @@ -513,23 +511,26 @@ auditor_iter (void *cls, * as maybe none of the files were well-formed) */ int -TALER_EXCHANGEDB_auditor_iterate (const char *exchange_base_dir, +TALER_EXCHANGEDB_auditor_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, TALER_EXCHANGEDB_AuditorIterator it, void *it_cls) { - char *dir; struct AuditorIterateContext aic; int ret; + char *auditor_base_dir; - GNUNET_asprintf (&dir, - "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_AUDITORS, - exchange_base_dir); + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, + "exchangedb", + "AUDITOR_BASE_DIR", + &auditor_base_dir)) + return -1; aic.it = it; aic.it_cls = it_cls; - ret = GNUNET_DISK_directory_scan (dir, + ret = GNUNET_DISK_directory_scan (auditor_base_dir, &auditor_iter, &aic); - GNUNET_free (dir); + GNUNET_free (auditor_base_dir); return ret; } diff --git a/src/include/taler_exchangedb_lib.h b/src/include/taler_exchangedb_lib.h index e13df2d46..1f6445212 100644 --- a/src/include/taler_exchangedb_lib.h +++ b/src/include/taler_exchangedb_lib.h @@ -37,12 +37,6 @@ */ #define TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS "denomkeys" -/** - * Subdirectory under the exchange's base directory which contains - * the exchange's auditing information. - */ -#define TALER_EXCHANGEDB_DIR_AUDITORS "auditors" - GNUNET_NETWORK_STRUCT_BEGIN @@ -234,9 +228,7 @@ typedef int /** * Call @a it with information for each auditor found in the @a exchange_base_dir. * - * @param exchange_base_dir base directory for the exchange, - * the signing keys must be in the #TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS - * subdirectory + * @param cfg configuration to use * @param it function to call with auditor information * @param it_cls closure for @a it * @return -1 on error, 0 if no files were found, otherwise @@ -245,7 +237,7 @@ typedef int * as maybe none of the files were well-formed) */ int -TALER_EXCHANGEDB_auditor_iterate (const char *exchange_base_dir, +TALER_EXCHANGEDB_auditor_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, TALER_EXCHANGEDB_AuditorIterator it, void *it_cls); diff --git a/src/include/taler_util.h b/src/include/taler_util.h index 425304152..0b1d40c85 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -96,17 +96,6 @@ TALER_b2s (const void *buf, /** - * Load configuration by parsing all configuration - * files in the given directory. - * - * @param base_dir directory with the configuration files - * @return NULL on error, otherwise configuration - */ -struct GNUNET_CONFIGURATION_Handle * -TALER_config_load (const char *base_dir); - - -/** * Obtain denomination amount from configuration file. * * @param section section of the configuration to access diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 54f0f0e38..f52bc81c6 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -6,6 +6,15 @@ if USE_COVERAGE XLIB = -lgcov endif + +pkgcfgdir = $(prefix)/share/taler/config.d/ + +pkgcfg_DATA = \ + paths.conf + +EXTRA_DIST = \ + paths.conf + if WALLET_ONLY lib_LTLIBRARIES = \ libtalerutil_wallet.la diff --git a/src/util/paths.conf b/src/util/paths.conf new file mode 100644 index 000000000..03febb0e4 --- /dev/null +++ b/src/util/paths.conf @@ -0,0 +1,29 @@ +# This file is in the public domain. +# +[PATHS] +# The PATHS section is special, as filenames including $-expression are +# expanded using the values from PATHS or the system environment (PATHS +# is checked first). Taler also supports expanding $-expressions using +# defaults with the syntax "${VAR:-default}". Here, "default" can again +# be a $-expression. +# +# We usually want $HOME for $TALER_HOME, but we allow testcases to +# easily override this by setting $TALER_TEST_HOME. +# +TALER_HOME = ${TALER_TEST_HOME:-${HOME:-${USERPROFILE}}} + +# see XDG Base Directory Specification at +# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html +# for how these should be used. + +# Persistant data storage +TALER_DATA_HOME = ${XDG_DATA_HOME:-$TALER_HOME/.local/share}/taler/ + +# Configuration files +TALER_CONFIG_HOME = ${XDG_CONFIG_HOME:-$TALER_HOME/.config}/taler/ + +# Cached data, no big deal if lost +TALER_CACHE_HOME = ${XDG_CACHE_HOME:-$TALER_HOME/.cache}/taler/ + +# Runtime data (always lost on system boot) +TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/taler-system-runtime/ diff --git a/src/util/util.c b/src/util/util.c index 434ce8a9d..d5fa8c05c 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -89,31 +89,4 @@ TALER_config_get_denom (struct GNUNET_CONFIGURATION_Handle *cfg, } -/** - * Load configuration by parsing all configuration - * files in the given directory. - * - * @param base_dir directory with the configuration files - * @return NULL on error, otherwise configuration - */ -struct GNUNET_CONFIGURATION_Handle * -TALER_config_load (const char *base_dir) -{ - struct GNUNET_CONFIGURATION_Handle *cfg; - char *cfg_dir; - int res; - - res = GNUNET_asprintf (&cfg_dir, - "%s" DIR_SEPARATOR_STR "config", - base_dir); - GNUNET_assert (res > 0); - cfg = GNUNET_CONFIGURATION_create (); - res = GNUNET_CONFIGURATION_load_from (cfg, cfg_dir); - GNUNET_free (cfg_dir); - if (GNUNET_OK != res) - return NULL; - return cfg; -} - - /* end of util.c */ diff --git a/src/wire/Makefile.am b/src/wire/Makefile.am index fd59c8eb7..0ed5f7be9 100644 --- a/src/wire/Makefile.am +++ b/src/wire/Makefile.am @@ -6,6 +6,17 @@ if USE_COVERAGE XLIB = -lgcov endif +pkgcfgdir = $(prefix)/share/taler/config.d/ + +pkgcfg_DATA = \ + wire-sepa.conf \ + wire-test.conf + + +EXTRA_DIST = \ + wire-sepa.conf \ + wire-test.conf + plugindir = $(libdir)/taler plugin_LTLIBRARIES = \ diff --git a/src/wire/wire-sepa.conf b/src/wire/wire-sepa.conf new file mode 100644 index 000000000..0ee17db30 --- /dev/null +++ b/src/wire/wire-sepa.conf @@ -0,0 +1,7 @@ +# Configuration for SEPA wire plugin. + +[wire-incoming-sepa] +SEPA_RESPONSE_FILE = ${TALER_CONFIG_HOME}/sepa.json + +[wire-incoming-sepa] +SEPA_RESPONSE_FILE = ${TALER_CONFIG_HOME}/sepa.json diff --git a/src/wire/wire-test.conf b/src/wire/wire-test.conf new file mode 100644 index 000000000..f2a71e2e4 --- /dev/null +++ b/src/wire/wire-test.conf @@ -0,0 +1,14 @@ +[wire-incoming-test] +# What is the main website of the bank? +# BANK_URI = "http://localhost:8082/" +# Into which account at the 'bank' should incoming +# wire transfers be made? +# BANK_ACCOUNT_NUMBER = 2 + +[wire-outgoing-test] +# What is the main website of the bank? +# BANK_URI = "http://localhost:8082/" + +# From which account at the 'bank' should outgoing +# wire transfers be made? +# BANK_ACCOUNT_NUMBER = 3 |