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

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

View File

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

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",
"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");

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

View File

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

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;
/**
* 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))
{
fprintf (stderr,
"Auditor key file not given\n");
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Malformed configuration file `%s', exit ...\n"),
cfgfile);
GNUNET_free_non_null (cfgfile);
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,
"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);

View File

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

View File

@ -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;
}
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;
}
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 ()) ||
(GNUNET_OK != exchange_denomkeys_check ()) )
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -134,11 +134,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)
*/
@ -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 */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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.
*
* @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;
}

View File

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

View File

@ -95,17 +95,6 @@ TALER_b2s (const void *buf,
#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.
*

View File

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

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

View File

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

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