fixing #4386: use more sane configuration and data file structure

This commit is contained in:
Christian Grothoff 2016-04-10 17:10:20 +02:00
parent 5fb65f59b2
commit 30d66bcebc
39 changed files with 499 additions and 316 deletions

2
.gitignore vendored
View File

@ -31,8 +31,10 @@ src/lib/test_exchange_api
doc/doxygen/doxygen_sqlite3.db doc/doxygen/doxygen_sqlite3.db
src/bank-lib/test_bank_api src/bank-lib/test_bank_api
src/exchange-lib/test_exchange_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/taler-exchange-aggregator
src/exchange/test_taler_exchange_aggregator-postgres 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-auditor-sign
src/exchange-tools/taler-exchange-dbinit src/exchange-tools/taler-exchange-dbinit
src/exchange-tools/taler-exchange-keycheck src/exchange-tools/taler-exchange-keycheck

View File

@ -1,14 +1,14 @@
.TH TALER.CONF 5 "Aug 11, 2015" "GNU Taler" .TH TALER.CONF 5 "Apr 11, 2016" "GNU Taler"
.SH NAME .SH NAME
taler.conf \- Taler configuration file. taler.conf \- Taler configuration file.
.SH SYNOPSIS .SH SYNOPSIS
.B DIRNAME/taler.conf .B taler.conf
.SH DESCRIPTION .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 .SH EXCHANGE OPTIONS

View File

@ -61,5 +61,6 @@ test_exchange_api_LDADD = \
-ljansson -ljansson
EXTRA_DIST = \ EXTRA_DIST = \
test-exchange-home/config/exchange-common.conf \ test_taler_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv \
test-exchange-home/master.priv test_taler_exchange_api_home/.config/taler/sepa.json \
test_taler_exchange_api.conf

View File

@ -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

View File

@ -2539,13 +2539,15 @@ main (int argc,
GNUNET_log_setup ("test-exchange-api", GNUNET_log_setup ("test-exchange-api",
"WARNING", "WARNING",
NULL); NULL);
/* These might get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
proc = GNUNET_OS_start_process (GNUNET_NO, proc = GNUNET_OS_start_process (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL, GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL, NULL, NULL, NULL,
"taler-exchange-keyup", "taler-exchange-keyup",
"taler-exchange-keyup", "taler-exchange-keyup",
"-d", "test-exchange-home", "-c", "test_exchange_api.conf",
"-m", "test-exchange-home/master.priv",
NULL); NULL);
GNUNET_OS_process_wait (proc); GNUNET_OS_process_wait (proc);
GNUNET_OS_process_destroy (proc); GNUNET_OS_process_destroy (proc);
@ -2554,7 +2556,7 @@ main (int argc,
NULL, NULL, NULL, NULL, NULL, NULL,
"taler-exchange-httpd", "taler-exchange-httpd",
"taler-exchange-httpd", "taler-exchange-httpd",
"-d", "test-exchange-home", "-c", "test_exchange_api.conf",
NULL); NULL);
/* give child time to start and bind against the socket */ /* give child time to start and bind against the socket */
fprintf (stderr, "Waiting for taler-exchange-httpd to be ready"); fprintf (stderr, "Waiting for taler-exchange-httpd to be ready");

View File

@ -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? [exchange]
signkey_duration = 4 weeks # Currency supported by the exchange (can only be one)
CURRENCY = EUR
# how long are the signatures with the signkey valid? # Wire format supported by the exchange
legal_duration = 2 years # 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 # HTTP port the exchange listens to
# ahead of time? PORT = 8081
lookahead_sign = 32 weeks 1 day
# how long do we provide to clients denomination and signing keys # Master public key used to sign the exchange's various keys
# ahead of time? MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
lookahead_provide = 4 weeks 1 day
# 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] [coin_eur_ct_1]
value = EUR:0.01 value = EUR:0.01
duration_overlap = 5 minutes duration_overlap = 5 minutes
@ -73,14 +94,3 @@ fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01 fee_deposit = EUR:0.01
fee_refresh = EUR:0.03 fee_refresh = EUR:0.03
rsa_keysize = 1024 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

View File

@ -1,6 +1,14 @@
# This Makefile.am is in the public domain # This Makefile.am is in the public domain
AM_CPPFLAGS = -I$(top_srcdir)/src/include 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 if USE_COVERAGE
AM_CFLAGS = --coverage -O0 AM_CFLAGS = --coverage -O0
XLIB = -lgcov XLIB = -lgcov
@ -81,3 +89,7 @@ taler_exchange_dbinit_CPPFLAGS = \
-I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/pq/ \ -I$(top_srcdir)/src/pq/ \
$(POSTGRESQL_CPPFLAGS) $(POSTGRESQL_CPPFLAGS)
EXTRA_DIST = \
auditor.conf

View File

@ -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/

View File

@ -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

View File

@ -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

View File

@ -59,6 +59,11 @@ static char *auditor_url;
*/ */
static struct TALER_MasterPublicKeyP master_public_key; static struct TALER_MasterPublicKeyP master_public_key;
/**
* Our configuration.
*/
static struct GNUNET_CONFIGURATION_Handle *cfg;
/** /**
* Print denomination key details for diagnostics. * Print denomination key details for diagnostics.
@ -131,10 +136,12 @@ int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
static const struct GNUNET_GETOPT_CommandLineOption options[] = { char *cfgfile = NULL;
{'a', "auditor-key", "FILE", const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'a', "auditor-key", "FILENAME",
"file containing the private key of the auditor", 1, "file containing the private key of the auditor", 1,
&GNUNET_GETOPT_set_filename, &auditor_key_file}, &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"), GNUNET_GETOPT_OPTION_HELP ("Private key of the auditor to use for signing"),
{'m', "exchange-key", "KEY", {'m', "exchange-key", "KEY",
"public key of the exchange (Crockford base32 encoded)", 1, "public key of the exchange (Crockford base32 encoded)", 1,
@ -142,10 +149,10 @@ main (int argc,
{'u', "auditor-url", "URL", {'u', "auditor-url", "URL",
"URL of the auditor (informative link for the user)", 1, "URL of the auditor (informative link for the user)", 1,
&GNUNET_GETOPT_set_string, &auditor_url}, &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, "set of keys the exchange requested the auditor to sign", 1,
&GNUNET_GETOPT_set_string, &exchange_request_file}, &GNUNET_GETOPT_set_string, &exchange_request_file},
{'o', "output", "FILE", {'o', "output", "FILENAME",
"where to write our signature", 1, "where to write our signature", 1,
&GNUNET_GETOPT_set_string, &output_file}, &GNUNET_GETOPT_set_string, &output_file},
GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION), GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION),
@ -163,20 +170,41 @@ main (int argc,
unsigned int i; unsigned int i;
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-exchange-keyup", GNUNET_log_setup ("taler-auditor-sign",
"WARNING", "WARNING",
NULL)); NULL));
if (GNUNET_GETOPT_run ("taler-exchange-keyup", if (GNUNET_GETOPT_run ("taler-auditor-sign",
options, options,
argc, argv) < 0) argc, argv) < 0)
return 1; return 1;
if (NULL == auditor_key_file) cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg,
cfgfile))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Auditor key file not given\n"); _("Malformed configuration file `%s', exit ...\n"),
cfgfile);
GNUNET_free_non_null (cfgfile);
return 1; return 1;
} }
if (NULL == auditor_url) 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 in neither configuration nor command-line\n");
return 1;
}
if ( (NULL == auditor_url) &&
(GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"auditor",
"AUDITOR_URL",
&auditor_url)) )
{ {
fprintf (stderr, fprintf (stderr,
"Auditor URL not given\n"); "Auditor URL not given\n");
@ -328,6 +356,7 @@ main (int argc,
GNUNET_free (dks); GNUNET_free (dks);
return 1; return 1;
} }
GNUNET_free (sigs); GNUNET_free (sigs);
GNUNET_free (dks); GNUNET_free (dks);
GNUNET_free (eddsa_priv); GNUNET_free (eddsa_priv);

View File

@ -20,24 +20,8 @@
*/ */
#include "platform.h" #include "platform.h"
#include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_util_lib.h>
#include <libpq-fe.h>
#include "taler_exchangedb_plugin.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. * The main function of the database initialization tool.
@ -51,14 +35,15 @@ int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
static const struct GNUNET_GETOPT_CommandLineOption options[] = { char *cfgfile = NULL;
{'d', "exchange-dir", "DIR", const struct GNUNET_GETOPT_CommandLineOption options[] = {
"exchange directory", 1, GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),
&GNUNET_GETOPT_set_filename, &exchange_base_dir},
GNUNET_GETOPT_OPTION_HELP ("Initialize Taler Exchange database"), GNUNET_GETOPT_OPTION_HELP ("Initialize Taler Exchange database"),
GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION), GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION),
GNUNET_GETOPT_OPTION_END GNUNET_GETOPT_OPTION_END
}; };
struct GNUNET_CONFIGURATION_Handle *cfg;
struct TALER_EXCHANGEDB_Plugin *plugin;
if (GNUNET_GETOPT_run ("taler-exchange-dbinit", if (GNUNET_GETOPT_run ("taler-exchange-dbinit",
options, options,
@ -69,24 +54,23 @@ main (int argc,
GNUNET_log_setup ("taler-exchange-dbinit", GNUNET_log_setup ("taler-exchange-dbinit",
"INFO", "INFO",
NULL)); NULL));
if (NULL == exchange_base_dir) cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg,
cfgfile))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Exchange base directory not given.\n"); _("Malformed configuration file `%s', exit ...\n"),
return 1; cfgfile);
} GNUNET_free_non_null (cfgfile);
cfg = TALER_config_load (exchange_base_dir);
if (NULL == cfg)
{
fprintf (stderr,
"Failed to load exchange configuration.\n");
return 1; return 1;
} }
GNUNET_free_non_null (cfgfile);
if (NULL == if (NULL ==
(plugin = TALER_EXCHANGEDB_plugin_load (cfg))) (plugin = TALER_EXCHANGEDB_plugin_load (cfg)))
{ {
fprintf (stderr, fprintf (stderr,
"Failed to initialize database plugin.\n"); "Failed to initialize database plugin.\n");
GNUNET_CONFIGURATION_destroy (cfg);
return 1; return 1;
} }
if (GNUNET_OK != if (GNUNET_OK !=
@ -96,9 +80,11 @@ main (int argc,
fprintf (stderr, fprintf (stderr,
"Failed to initialize database.\n"); "Failed to initialize database.\n");
TALER_EXCHANGEDB_plugin_unload (plugin); TALER_EXCHANGEDB_plugin_unload (plugin);
GNUNET_CONFIGURATION_destroy (cfg);
return 1; return 1;
} }
TALER_EXCHANGEDB_plugin_unload (plugin); TALER_EXCHANGEDB_plugin_unload (plugin);
GNUNET_CONFIGURATION_destroy (cfg);
return 0; return 0;
} }

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 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 terms of the GNU General Public License as published by the Free Software
@ -104,8 +104,8 @@ static int
exchange_signkeys_check () exchange_signkeys_check ()
{ {
if (0 > TALER_EXCHANGEDB_signing_keys_iterate (exchange_directory, if (0 > TALER_EXCHANGEDB_signing_keys_iterate (exchange_directory,
&signkeys_iter, &signkeys_iter,
NULL)) NULL))
return GNUNET_NO; return GNUNET_NO;
return GNUNET_OK; return GNUNET_OK;
} }
@ -186,8 +186,8 @@ static int
exchange_denomkeys_check () exchange_denomkeys_check ()
{ {
if (0 > TALER_EXCHANGEDB_denomination_keys_iterate (exchange_directory, if (0 > TALER_EXCHANGEDB_denomination_keys_iterate (exchange_directory,
&denomkeys_iter, &denomkeys_iter,
NULL)) NULL))
return GNUNET_NO; return GNUNET_NO;
return GNUNET_OK; return GNUNET_OK;
} }
@ -203,11 +203,10 @@ exchange_denomkeys_check ()
int int
main (int argc, char *const *argv) 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"), 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 GNUNET_GETOPT_OPTION_END
}; };
@ -220,20 +219,29 @@ main (int argc, char *const *argv)
options, options,
argc, argv) < 0) argc, argv) < 0)
return 1; return 1;
if (NULL == exchange_directory) kcfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (kcfg,
cfgfile))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Exchange directory not given\n"); _("Malformed configuration file `%s', exit ...\n"),
cfgfile);
GNUNET_free_non_null (cfgfile);
return 1;
}
GNUNET_free_non_null (cfgfile);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (kcfg,
"exchange",
"KEYDIR",
&exchange_directory))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"KEYDIR");
return 1; return 1;
} }
kcfg = TALER_config_load (exchange_directory);
if (NULL == kcfg)
{
fprintf (stderr,
"Failed to load exchange configuration\n");
return 1;
}
if ( (GNUNET_OK != exchange_signkeys_check ()) || if ( (GNUNET_OK != exchange_signkeys_check ()) ||
(GNUNET_OK != exchange_denomkeys_check ()) ) (GNUNET_OK != exchange_denomkeys_check ()) )
{ {

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 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 terms of the GNU General Public License as published by the Free Software
@ -876,10 +876,9 @@ int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
static const struct GNUNET_GETOPT_CommandLineOption options[] = { char *cfgfile = NULL;
{'d', "exchange-dir", "DIR", const struct GNUNET_GETOPT_CommandLineOption options[] = {
"exchange directory with keys to update", 1, GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),
&GNUNET_GETOPT_set_filename, &exchange_directory},
GNUNET_GETOPT_OPTION_HELP ("Setup signing and denomination keys for a Taler exchange"), GNUNET_GETOPT_OPTION_HELP ("Setup signing and denomination keys for a Taler exchange"),
{'m', "master-key", "FILE", {'m', "master-key", "FILE",
"master key file (private key)", 1, "master key file (private key)", 1,
@ -905,12 +904,17 @@ main (int argc,
options, options,
argc, argv) < 0) argc, argv) < 0)
return 1; return 1;
if (NULL == exchange_directory) kcfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (kcfg,
cfgfile))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Exchange directory not given\n"); _("Malformed configuration file `%s', exit ...\n"),
cfgfile);
GNUNET_free_non_null (cfgfile);
return 1; return 1;
} }
GNUNET_free_non_null (cfgfile);
if (NULL != pretend_time_str) if (NULL != pretend_time_str)
{ {
if (GNUNET_OK != if (GNUNET_OK !=
@ -928,18 +932,26 @@ main (int argc,
now = GNUNET_TIME_absolute_get (); now = GNUNET_TIME_absolute_get ();
} }
GNUNET_TIME_round_abs (&now); GNUNET_TIME_round_abs (&now);
if ( (NULL == masterkeyfile) &&
kcfg = TALER_config_load (exchange_directory); (GNUNET_OK !=
if (NULL == kcfg) GNUNET_CONFIGURATION_get_value_filename (kcfg,
"exchange",
"MASTER_PRIV_FILE",
&masterkeyfile)) )
{ {
fprintf (stderr, fprintf (stderr,
"Failed to load exchange configuration\n"); "Master key file not given in neither configuration nor command-line\n");
return 1; return 1;
} }
if (NULL == masterkeyfile) if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (kcfg,
"exchange",
"KEYDIR",
&exchange_directory))
{ {
fprintf (stderr, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"Master key file not given\n"); "exchange",
"KEYDIR");
return 1; return 1;
} }
eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile); eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile);

View File

@ -51,6 +51,7 @@ static struct TALER_EXCHANGEDB_Plugin *plugin;
int int
main (int argc, char *const *argv) main (int argc, char *const *argv)
{ {
char *cfgfile = NULL;
char *reserve_pub_str = NULL; char *reserve_pub_str = NULL;
char *add_str = NULL; char *add_str = NULL;
struct TALER_Amount add_value; struct TALER_Amount add_value;
@ -63,10 +64,8 @@ main (int argc, char *const *argv)
{'a', "add", "DENOM", {'a', "add", "DENOM",
"value to add", 1, "value to add", 1,
&GNUNET_GETOPT_set_string, &add_str}, &GNUNET_GETOPT_set_string, &add_str},
{'d', "exchange-dir", "DIR", GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),
"exchange directory with keys to update", 1, {'d', "details", "JSON",
&GNUNET_GETOPT_set_filename, &exchange_directory},
{'D', "details", "JSON",
"details about the bank transaction which justify why we add this amount", 1, "details about the bank transaction which justify why we add this amount", 1,
&GNUNET_GETOPT_set_string, &details}, &GNUNET_GETOPT_set_string, &details},
GNUNET_GETOPT_OPTION_HELP ("Deposit funds into a Taler reserve"), GNUNET_GETOPT_OPTION_HELP ("Deposit funds into a Taler reserve"),
@ -87,10 +86,29 @@ main (int argc, char *const *argv)
options, options,
argc, argv) < 0) argc, argv) < 0)
return 1; return 1;
if (NULL == exchange_directory) cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg,
cfgfile))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Exchange directory not given\n"); _("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 (add_str);
GNUNET_free_non_null (details); GNUNET_free_non_null (details);
GNUNET_free_non_null (reserve_pub_str); GNUNET_free_non_null (reserve_pub_str);
@ -133,16 +151,6 @@ main (int argc, char *const *argv)
return 1; 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; ret = 1;
if (NULL == if (NULL ==
(plugin = TALER_EXCHANGEDB_plugin_load (cfg))) (plugin = TALER_EXCHANGEDB_plugin_load (cfg)))

View File

@ -46,6 +46,11 @@ static char *method;
*/ */
static char *output_filename; 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 * The main function of the taler-exchange-sepa tool. This tool is used
@ -59,7 +64,9 @@ int
main (int argc, main (int argc,
char *const *argv) 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", {'j', "json", "JSON",
"account information in JSON format", 1, "account information in JSON format", 1,
&GNUNET_GETOPT_set_string, &json_in}, &GNUNET_GETOPT_set_string, &json_in},
@ -95,10 +102,26 @@ main (int argc,
options, options,
argc, argv) < 0) argc, argv) < 0)
return 1; 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, fprintf (stderr,
"Master key file not given\n"); "Master key file not given in neither configuration nor command-line\n");
return 1; return 1;
} }
eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile); eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile);

View File

@ -89,4 +89,6 @@ TESTS = \
EXTRA_DIST = \ EXTRA_DIST = \
test-taler-exchange-aggregator-postgres.conf \ 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 exchange.conf

View File

@ -1,13 +1,20 @@
# This file is in the public domain.
#
[exchange] [exchange]
# Currency supported by the exchange (can only be one) # Currency supported by the exchange (can only be one)
# CURRENCY = EUR # 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. # the actual coin operations.
WIREFORMAT = test # WIREFORMAT = test
# HTTP port the exchange listens to # HTTP port the exchange listens to
PORT = 8081 # PORT = 8081
# Master public key used to sign the exchange's various keys # Master public key used to sign the exchange's various keys
# MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG # MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
@ -18,21 +25,5 @@ DB = postgres
# Is this is a testcase, use transient DB actions? # Is this is a testcase, use transient DB actions?
# TESTRUN = YES # TESTRUN = YES
[exchangedb-postgres] # Where do we store the offline master private key of the exchange?
DB_CONN_STR = "postgres:///taler" MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
[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

View File

@ -134,11 +134,6 @@ static char *exchange_currency_string;
*/ */
static char *exchange_wireformat; static char *exchange_wireformat;
/**
* Base directory of the exchange (global)
*/
static char *exchange_directory;
/** /**
* The exchange's configuration (global) * The exchange's configuration (global)
*/ */
@ -238,26 +233,20 @@ shutdown_task (void *cls)
} }
TALER_EXCHANGEDB_plugin_unload (db_plugin); TALER_EXCHANGEDB_plugin_unload (db_plugin);
TALER_WIRE_plugin_unload (wire_plugin); TALER_WIRE_plugin_unload (wire_plugin);
GNUNET_CONFIGURATION_destroy (cfg);
cfg = NULL;
} }
/** /**
* Load configuration parameters for the exchange * Parse configuration parameters for the exchange server into the
* server into the corresponding global variables. * corresponding global variables.
* *
* @param exchange_directory the exchange's directory
* @return #GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
static int 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 != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg, GNUNET_CONFIGURATION_get_value_string (cfg,
"exchange", "exchange",
@ -311,7 +300,6 @@ exchange_serve_process_config (const char *exchange_directory)
exchange_wireformat); exchange_wireformat);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
return GNUNET_OK; return GNUNET_OK;
} }
@ -958,10 +946,24 @@ run_transfers (void *cls)
* First task. * First task.
* *
* @param cls closure, NULL * @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 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, task = GNUNET_SCHEDULER_add_now (&run_transfers,
NULL); NULL);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
@ -982,13 +984,9 @@ main (int argc,
char *const *argv) char *const *argv)
{ {
static const struct GNUNET_GETOPT_CommandLineOption options[] = { 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", {'f', "format", "WIREFORMAT",
"wireformat to use, overrides WIREFORMAT option in [exchange] section", 1, "wireformat to use, overrides WIREFORMAT option in [exchange] section", 1,
&GNUNET_GETOPT_set_filename, &exchange_wireformat}, &GNUNET_GETOPT_set_filename, &exchange_wireformat},
GNUNET_GETOPT_OPTION_HELP ("background process that aggregates and executes wire transfers to merchants"),
{'t', "test", NULL, {'t', "test", NULL,
"run in test mode with temporary tables", 0, "run in test mode with temporary tables", 0,
&GNUNET_GETOPT_set_one, &test_mode}, &GNUNET_GETOPT_set_one, &test_mode},
@ -996,30 +994,17 @@ main (int argc,
GNUNET_GETOPT_OPTION_END GNUNET_GETOPT_OPTION_END
}; };
GNUNET_assert (GNUNET_OK == if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv,
GNUNET_log_setup ("taler-exchange-aggregator", &argc, &argv))
"INFO", return 2;
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 != 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; return 1;
} return global_ret;
global_ret = GNUNET_OK;
GNUNET_SCHEDULER_run (&run, NULL);
return (GNUNET_SYSERR == global_ret) ? 1 : 0;
} }
/* end of taler-exchange-aggregator.c */ /* end of taler-exchange-aggregator.c */

View File

@ -360,16 +360,20 @@ handle_mhd_request (void *cls,
* @return #GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
static int static int
exchange_serve_process_config (const char *exchange_directory) exchange_serve_process_config ()
{ {
unsigned long long port; unsigned long long port;
char *TMH_master_public_key_str; char *TMH_master_public_key_str;
cfg = TALER_config_load (exchange_directory); if (GNUNET_OK !=
if (NULL == cfg) GNUNET_CONFIGURATION_get_value_filename (cfg,
"exchange",
"KEYDIR",
&TMH_exchange_directory))
{ {
fprintf (stderr, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"Failed to load exchange configuration\n"); "exchange",
"KEYDIR");
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (GNUNET_OK != if (GNUNET_OK !=
@ -615,13 +619,12 @@ int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
static const struct GNUNET_GETOPT_CommandLineOption options[] = { char *cfgfile = NULL;
const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'C', "connection-close", NULL, {'C', "connection-close", NULL,
"force HTTP connections to be closed after each request", 0, "force HTTP connections to be closed after each request", 0,
&GNUNET_GETOPT_set_one, &TMH_exchange_connection_close}, &GNUNET_GETOPT_set_one, &TMH_exchange_connection_close},
{'d', "exchange-dir", "DIR", GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),
"exchange directory with configuration and keys for operating the exchange", 1,
&GNUNET_GETOPT_set_filename, &TMH_exchange_directory},
{'t', "timeout", "SECONDS", {'t', "timeout", "SECONDS",
"after how long do connections timeout by default (in seconds)", 1, "after how long do connections timeout by default (in seconds)", 1,
&GNUNET_GETOPT_set_uint, &connection_timeout}, &GNUNET_GETOPT_set_uint, &connection_timeout},
@ -645,15 +648,18 @@ main (int argc,
options, options,
argc, argv)) argc, argv))
return 1; return 1;
if (NULL == TMH_exchange_directory) cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cfgfile))
{ {
fprintf (stderr, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Exchange directory not specified\n"); _("Malformed configuration file `%s', exit ...\n"),
cfgfile);
GNUNET_free_non_null (cfgfile);
return 1; return 1;
} }
GNUNET_free_non_null (cfgfile);
if (GNUNET_OK != if (GNUNET_OK !=
exchange_serve_process_config (TMH_exchange_directory)) exchange_serve_process_config ())
return 1; return 1;
mydaemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, mydaemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG,

View File

@ -650,9 +650,9 @@ TMH_KS_acquire_ (const char *location)
TALER_EXCHANGEDB_signing_keys_iterate (TMH_exchange_directory, TALER_EXCHANGEDB_signing_keys_iterate (TMH_exchange_directory,
&reload_keys_sign_iter, &reload_keys_sign_iter,
key_state); key_state);
TALER_EXCHANGEDB_auditor_iterate (TMH_exchange_directory, TALER_EXCHANGEDB_auditor_iterate (cfg,
&reload_auditor_iter, &reload_auditor_iter,
key_state); key_state);
ks.purpose.size = htonl (sizeof (ks)); ks.purpose.size = htonl (sizeof (ks));
ks.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_KEY_SET); ks.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_KEY_SET);
ks.list_issue_date = GNUNET_TIME_absolute_hton (key_state->reload_time); ks.list_issue_date = GNUNET_TIME_absolute_hton (key_state->reload_time);

View File

@ -570,8 +570,7 @@ interpreter (void *cls)
NULL, NULL, NULL, NULL, NULL, NULL,
"taler-exchange-aggregator", "taler-exchange-aggregator",
"taler-exchange-aggregator", "taler-exchange-aggregator",
/* "-c", config_filename, */ "-c", "test_taler_exchange_httpd.conf",
"-d", "test-exchange-home",
"-t", /* enable temporary tables */ "-t", /* enable temporary tables */
NULL); NULL);
return; return;
@ -1523,6 +1522,9 @@ main (int argc,
"test-taler-exchange-aggregator-%s", plugin_name); "test-taler-exchange-aggregator-%s", plugin_name);
(void) GNUNET_asprintf (&config_filename, (void) GNUNET_asprintf (&config_filename,
"%s.conf", testname); "%s.conf", testname);
/* these might get in the way */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup ("test_taler_exchange_aggregator", GNUNET_log_setup ("test_taler_exchange_aggregator",
"WARNING", "WARNING",
NULL); NULL);

View File

@ -1,3 +1,8 @@
[PATHS]
# Persistant data storage for the testcase
TALER_TEST_HOME = test_taler_exchange_httpd_home/
[exchange] [exchange]
# Currency supported by the exchange (can only be one) # Currency supported by the exchange (can only be one)
CURRENCY = EUR CURRENCY = EUR
@ -19,6 +24,9 @@ DB = postgres
# Is this is a testcase, use transient DB actions? # Is this is a testcase, use transient DB actions?
TESTRUN = YES TESTRUN = YES
[exchangedb-postgres] [exchangedb-postgres]
DB_CONN_STR = "postgres:///talercheck" DB_CONN_STR = "postgres:///talercheck"
@ -37,3 +45,38 @@ BANK_URI = "http://localhost:8082/"
# From which account at the 'bank' should outgoing # From which account at the 'bank' should outgoing
# wire transfers be made? # wire transfers be made?
BANK_ACCOUNT_NUMBER = 3 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

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# This file is part of TALER # 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 # 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 # 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 # taler-exchange-httpd. Basically, the goal is to make sure that the
# HTTP server survives (and produces the 'correct' error code). # 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. # 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) # 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 # Give HTTP time to start
sleep 5 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 cat test_taler_exchange_httpd.data | grep -v ^\# | awk '{ print "curl -d \47" $2 "\47 http://localhost:8081" $1 }' | bash
# Stop HTTP server # Stop HTTP server
kill -TERM %% kill -TERM %%

View File

@ -6,6 +6,17 @@ if USE_COVERAGE
XLIB = -lgcov XLIB = -lgcov
endif endif
pkgcfgdir = $(prefix)/share/taler/config.d/
pkgcfg_DATA = \
exchangedb.conf \
exchangedb-postgres.conf
EXTRA_DIST = \
exchangedb.conf \
exchangedb-postgres.conf
plugindir = $(libdir)/taler plugindir = $(libdir)/taler
if HAVE_POSTGRESQL if HAVE_POSTGRESQL

View File

@ -0,0 +1,2 @@
[exchangedb-postgres]
DB_CONN_STR = "postgres:///taler"

View File

@ -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/

View File

@ -502,9 +502,7 @@ auditor_iter (void *cls,
/** /**
* Call @a it with information for each auditor found in the @a exchange_base_dir. * Call @a it with information for each auditor found in the @a exchange_base_dir.
* *
* @param exchange_base_dir base directory for the exchange, * @param cfg configuration to use
* the signing keys must be in the #TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS
* subdirectory
* @param it function to call with auditor information * @param it function to call with auditor information
* @param it_cls closure for @a it * @param it_cls closure for @a it
* @return -1 on error, 0 if no files were found, otherwise * @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) * as maybe none of the files were well-formed)
*/ */
int int
TALER_EXCHANGEDB_auditor_iterate (const char *exchange_base_dir, TALER_EXCHANGEDB_auditor_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
TALER_EXCHANGEDB_AuditorIterator it, TALER_EXCHANGEDB_AuditorIterator it,
void *it_cls) void *it_cls)
{ {
char *dir;
struct AuditorIterateContext aic; struct AuditorIterateContext aic;
int ret; int ret;
char *auditor_base_dir;
GNUNET_asprintf (&dir, if (GNUNET_OK !=
"%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_AUDITORS, GNUNET_CONFIGURATION_get_value_filename (cfg,
exchange_base_dir); "exchangedb",
"AUDITOR_BASE_DIR",
&auditor_base_dir))
return -1;
aic.it = it; aic.it = it;
aic.it_cls = it_cls; aic.it_cls = it_cls;
ret = GNUNET_DISK_directory_scan (dir, ret = GNUNET_DISK_directory_scan (auditor_base_dir,
&auditor_iter, &auditor_iter,
&aic); &aic);
GNUNET_free (dir); GNUNET_free (auditor_base_dir);
return ret; return ret;
} }

View File

@ -37,12 +37,6 @@
*/ */
#define TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS "denomkeys" #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 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. * Call @a it with information for each auditor found in the @a exchange_base_dir.
* *
* @param exchange_base_dir base directory for the exchange, * @param cfg configuration to use
* the signing keys must be in the #TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS
* subdirectory
* @param it function to call with auditor information * @param it function to call with auditor information
* @param it_cls closure for @a it * @param it_cls closure for @a it
* @return -1 on error, 0 if no files were found, otherwise * @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) * as maybe none of the files were well-formed)
*/ */
int int
TALER_EXCHANGEDB_auditor_iterate (const char *exchange_base_dir, TALER_EXCHANGEDB_auditor_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
TALER_EXCHANGEDB_AuditorIterator it, TALER_EXCHANGEDB_AuditorIterator it,
void *it_cls); void *it_cls);

View File

@ -95,17 +95,6 @@ TALER_b2s (const void *buf,
#define TALER_B2S(obj) TALER_b2s (obj, sizeof (*obj)) #define TALER_B2S(obj) TALER_b2s (obj, sizeof (*obj))
/**
* 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. * Obtain denomination amount from configuration file.
* *

View File

@ -6,6 +6,15 @@ if USE_COVERAGE
XLIB = -lgcov XLIB = -lgcov
endif endif
pkgcfgdir = $(prefix)/share/taler/config.d/
pkgcfg_DATA = \
paths.conf
EXTRA_DIST = \
paths.conf
if WALLET_ONLY if WALLET_ONLY
lib_LTLIBRARIES = \ lib_LTLIBRARIES = \
libtalerutil_wallet.la libtalerutil_wallet.la

29
src/util/paths.conf Normal file
View File

@ -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/

View File

@ -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 */ /* end of util.c */

View File

@ -6,6 +6,17 @@ if USE_COVERAGE
XLIB = -lgcov XLIB = -lgcov
endif 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 plugindir = $(libdir)/taler
plugin_LTLIBRARIES = \ plugin_LTLIBRARIES = \

7
src/wire/wire-sepa.conf Normal file
View File

@ -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

14
src/wire/wire-test.conf Normal file
View File

@ -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