fix taler-exchange-keyup way of loading configuration
This commit is contained in:
parent
480b9cdf39
commit
ecc5b6791f
@ -181,7 +181,7 @@ static char *pretend_time_str;
|
|||||||
/**
|
/**
|
||||||
* Handle to the exchange's configuration
|
* Handle to the exchange's configuration
|
||||||
*/
|
*/
|
||||||
static struct GNUNET_CONFIGURATION_Handle *kcfg;
|
static const struct GNUNET_CONFIGURATION_Handle *kcfg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time when the key update is executed. Either the actual current time, or a
|
* Time when the key update is executed. Either the actual current time, or a
|
||||||
@ -204,6 +204,12 @@ static struct TALER_MasterPublicKeyP master_public_key;
|
|||||||
*/
|
*/
|
||||||
static struct GNUNET_TIME_Absolute lookahead_sign_stamp;
|
static struct GNUNET_TIME_Absolute lookahead_sign_stamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return value from main().
|
||||||
|
*/
|
||||||
|
static int global_ret;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the name of the directory we use to store signing
|
* Obtain the name of the directory we use to store signing
|
||||||
@ -860,61 +866,23 @@ exchange_keys_update_denomkeys ()
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main function of the taler-exchange-keyup tool. This tool is used
|
* Main function that will be run.
|
||||||
* to create the signing and denomination keys for the exchange. It uses
|
|
||||||
* the long-term offline private key and writes the (additional) key
|
|
||||||
* files to the respective exchange directory (from where they can then be
|
|
||||||
* copied to the online server). Note that we need (at least) the
|
|
||||||
* most recent generated previous keys so as to align the validity
|
|
||||||
* periods.
|
|
||||||
*
|
*
|
||||||
* @param argc number of arguments from the command line
|
* @param cls closure
|
||||||
* @param argv command line arguments
|
* @param args remaining command-line arguments
|
||||||
* @return 0 ok, 1 on error
|
* @param cfgfile name of the configuration file used (for saving, can be NULL!)
|
||||||
|
* @param c configuration
|
||||||
*/
|
*/
|
||||||
int
|
static void
|
||||||
main (int argc,
|
run (void *cls,
|
||||||
char *const *argv)
|
char *const *args,
|
||||||
|
const char *cfgfile,
|
||||||
|
const struct GNUNET_CONFIGURATION_Handle *cfg)
|
||||||
{
|
{
|
||||||
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,
|
|
||||||
&GNUNET_GETOPT_set_filename, &masterkeyfile},
|
|
||||||
{'o', "output", "FILE",
|
|
||||||
"auditor denomination key signing request file to create", 1,
|
|
||||||
&GNUNET_GETOPT_set_filename, &auditorrequestfile},
|
|
||||||
{'t', "time", "TIMESTAMP",
|
|
||||||
"pretend it is a different time for the update", 0,
|
|
||||||
&GNUNET_GETOPT_set_string, &pretend_time_str},
|
|
||||||
GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION),
|
|
||||||
GNUNET_GETOPT_OPTION_END
|
|
||||||
};
|
|
||||||
struct GNUNET_TIME_Relative lookahead_sign;
|
struct GNUNET_TIME_Relative lookahead_sign;
|
||||||
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_priv;
|
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_priv;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
kcfg = cfg;
|
||||||
GNUNET_log_setup ("taler-exchange-keyup",
|
|
||||||
"WARNING",
|
|
||||||
NULL));
|
|
||||||
|
|
||||||
if (GNUNET_GETOPT_run ("taler-exchange-keyup",
|
|
||||||
options,
|
|
||||||
argc, argv) < 0)
|
|
||||||
return 1;
|
|
||||||
kcfg = GNUNET_CONFIGURATION_create ();
|
|
||||||
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (kcfg,
|
|
||||||
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 != pretend_time_str)
|
if (NULL != pretend_time_str)
|
||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -924,7 +892,8 @@ main (int argc,
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"timestamp `%s' invalid\n",
|
"timestamp `%s' invalid\n",
|
||||||
pretend_time_str);
|
pretend_time_str);
|
||||||
return 1;
|
global_ret = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -941,7 +910,8 @@ main (int argc,
|
|||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Master key file not given in neither configuration nor command-line\n");
|
"Master key file not given in neither configuration nor command-line\n");
|
||||||
return 1;
|
global_ret = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_filename (kcfg,
|
GNUNET_CONFIGURATION_get_value_filename (kcfg,
|
||||||
@ -952,7 +922,8 @@ main (int argc,
|
|||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"exchange",
|
"exchange",
|
||||||
"KEYDIR");
|
"KEYDIR");
|
||||||
return 1;
|
global_ret = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile);
|
eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile);
|
||||||
if (NULL == eddsa_priv)
|
if (NULL == eddsa_priv)
|
||||||
@ -960,7 +931,8 @@ main (int argc,
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Failed to initialize master key from file `%s'\n",
|
"Failed to initialize master key from file `%s'\n",
|
||||||
masterkeyfile);
|
masterkeyfile);
|
||||||
return 1;
|
global_ret = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
master_priv.eddsa_priv = *eddsa_priv;
|
master_priv.eddsa_priv = *eddsa_priv;
|
||||||
GNUNET_free (eddsa_priv);
|
GNUNET_free (eddsa_priv);
|
||||||
@ -977,7 +949,8 @@ main (int argc,
|
|||||||
"Failed to open `%s' for writing: %s\n",
|
"Failed to open `%s' for writing: %s\n",
|
||||||
auditorrequestfile,
|
auditorrequestfile,
|
||||||
STRERROR (errno));
|
STRERROR (errno));
|
||||||
return 1;
|
global_ret = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -995,7 +968,8 @@ main (int argc,
|
|||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"exchange",
|
"exchange",
|
||||||
"master_public_key");
|
"master_public_key");
|
||||||
return 1;
|
global_ret = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (0 !=
|
if (0 !=
|
||||||
memcmp (&master_public_key,
|
memcmp (&master_public_key,
|
||||||
@ -1006,7 +980,8 @@ main (int argc,
|
|||||||
"exchange",
|
"exchange",
|
||||||
"master_public_key",
|
"master_public_key",
|
||||||
_("does not match with private key"));
|
_("does not match with private key"));
|
||||||
return 1;
|
global_ret = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1019,7 +994,8 @@ main (int argc,
|
|||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"exchange_keys",
|
"exchange_keys",
|
||||||
"lookahead_sign");
|
"lookahead_sign");
|
||||||
return GNUNET_SYSERR;
|
global_ret = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (0 == lookahead_sign.rel_value_us)
|
if (0 == lookahead_sign.rel_value_us)
|
||||||
{
|
{
|
||||||
@ -1027,7 +1003,8 @@ main (int argc,
|
|||||||
"exchange_keys",
|
"exchange_keys",
|
||||||
"lookahead_sign",
|
"lookahead_sign",
|
||||||
_("must not be zero"));
|
_("must not be zero"));
|
||||||
return GNUNET_SYSERR;
|
global_ret = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
GNUNET_TIME_round_rel (&lookahead_sign);
|
GNUNET_TIME_round_rel (&lookahead_sign);
|
||||||
lookahead_sign_stamp = GNUNET_TIME_absolute_add (now,
|
lookahead_sign_stamp = GNUNET_TIME_absolute_add (now,
|
||||||
@ -1036,16 +1013,66 @@ main (int argc,
|
|||||||
|
|
||||||
/* finally, do actual work */
|
/* finally, do actual work */
|
||||||
if (GNUNET_OK != exchange_keys_update_signkeys ())
|
if (GNUNET_OK != exchange_keys_update_signkeys ())
|
||||||
return 1;
|
{
|
||||||
|
global_ret = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (GNUNET_OK != exchange_keys_update_denomkeys ())
|
if (GNUNET_OK != exchange_keys_update_denomkeys ())
|
||||||
return 1;
|
{
|
||||||
|
global_ret = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (NULL != auditor_output_file)
|
if (NULL != auditor_output_file)
|
||||||
{
|
{
|
||||||
FCLOSE (auditor_output_file);
|
FCLOSE (auditor_output_file);
|
||||||
auditor_output_file = NULL;
|
auditor_output_file = NULL;
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main function of the taler-exchange-keyup tool. This tool is used
|
||||||
|
* to create the signing and denomination keys for the exchange. It uses
|
||||||
|
* the long-term offline private key and writes the (additional) key
|
||||||
|
* files to the respective exchange directory (from where they can then be
|
||||||
|
* copied to the online server). Note that we need (at least) the
|
||||||
|
* most recent generated previous keys so as to align the validity
|
||||||
|
* periods.
|
||||||
|
*
|
||||||
|
* @param argc number of arguments from the command line
|
||||||
|
* @param argv command line arguments
|
||||||
|
* @return 0 ok, 1 on error
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
main (int argc,
|
||||||
|
char *const *argv)
|
||||||
|
{
|
||||||
|
const struct GNUNET_GETOPT_CommandLineOption options[] = {
|
||||||
|
{'m', "master-key", "FILE",
|
||||||
|
"master key file (private key)", 1,
|
||||||
|
&GNUNET_GETOPT_set_filename, &masterkeyfile},
|
||||||
|
{'o', "output", "FILE",
|
||||||
|
"auditor denomination key signing request file to create", 1,
|
||||||
|
&GNUNET_GETOPT_set_filename, &auditorrequestfile},
|
||||||
|
{'t', "time", "TIMESTAMP",
|
||||||
|
"pretend it is a different time for the update", 0,
|
||||||
|
&GNUNET_GETOPT_set_string, &pretend_time_str},
|
||||||
|
GNUNET_GETOPT_OPTION_END
|
||||||
|
};
|
||||||
|
|
||||||
|
GNUNET_assert (GNUNET_OK ==
|
||||||
|
GNUNET_log_setup ("taler-exchange-keyup",
|
||||||
|
"WARNING",
|
||||||
|
NULL));
|
||||||
|
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_PROGRAM_run (argc, argv,
|
||||||
|
"taler-exchange-keyup",
|
||||||
|
"Setup signing and denomination keys for a Taler exchange",
|
||||||
|
options,
|
||||||
|
&run, NULL))
|
||||||
|
return 1;
|
||||||
|
return global_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end of taler-exchange-keyup.c */
|
/* end of taler-exchange-keyup.c */
|
||||||
|
@ -104,7 +104,7 @@ TALER_b2s (const void *buf,
|
|||||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
|
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_config_get_denom (struct GNUNET_CONFIGURATION_Handle *cfg,
|
TALER_config_get_denom (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||||
const char *section,
|
const char *section,
|
||||||
const char *option,
|
const char *option,
|
||||||
struct TALER_Amount *denom);
|
struct TALER_Amount *denom);
|
||||||
|
@ -69,7 +69,7 @@ TALER_b2s (const void *buf,
|
|||||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
|
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_config_get_denom (struct GNUNET_CONFIGURATION_Handle *cfg,
|
TALER_config_get_denom (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||||
const char *section,
|
const char *section,
|
||||||
const char *option,
|
const char *option,
|
||||||
struct TALER_Amount *denom)
|
struct TALER_Amount *denom)
|
||||||
|
Loading…
Reference in New Issue
Block a user