aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorDaniel Pinto <danielpinto52@gmail.com>2020-08-01 00:03:06 +0100
committerDaniel Pinto <danielpinto52@gmail.com>2020-08-01 01:08:37 +0100
commit1474ab33956eefd9b75ef9a3e238ec7f855b8c7e (patch)
tree194509f3fd3314a7f3a7c8c4b4208f14712f9b64 /src/app
parent700e8a8bb070d20ce6febde0c20dd9acde911856 (diff)
downloadtor-1474ab33956eefd9b75ef9a3e238ec7f855b8c7e.tar.gz
tor-1474ab33956eefd9b75ef9a3e238ec7f855b8c7e.zip
Add --format argument to --key-expiration option. #30045
Diffstat (limited to 'src/app')
-rw-r--r--src/app/config/config.c35
-rw-r--r--src/app/config/or_options_st.h5
2 files changed, 40 insertions, 0 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c
index a70c1d651e..1c6d4acd3e 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -2468,6 +2468,8 @@ static const struct {
{ .name="--key-expiration",
.takes_argument=ARGUMENT_OPTIONAL,
.command=CMD_KEY_EXPIRATION },
+ { .name="--format",
+ .takes_argument=ARGUMENT_NECESSARY },
{ .name="--newpass" },
{ .name="--no-passphrase" },
{ .name="--passphrase-fd",
@@ -4425,6 +4427,39 @@ options_init_from_torrc(int argc, char **argv)
}
}
+ const config_line_t *format_line = config_line_find(cmdline_only_options,
+ "--format");
+ if (format_line) {
+ if (command == CMD_KEY_EXPIRATION) {
+ const char *v = format_line->value;
+ // keep the same order as enum key_expiration_format
+ const char *formats[] = { "iso8601", "timestamp" };
+ const int formats_len = sizeof(formats) / sizeof(formats[0]);
+ int format = -1;
+ for (int i = 0; i < formats_len; i++) {
+ if (!strcmp(v, formats[i])) {
+ format = i;
+ break;
+ }
+ }
+
+ if (format < 0) {
+ log_err(LD_CONFIG, "Invalid --format value %s", escaped(v));
+ retval = -1;
+ goto err;
+ } else {
+ get_options_mutable()->key_expiration_format = format;
+ }
+ } else {
+ log_err(LD_CONFIG, "--format specified without --key-expiration!");
+ retval = -1;
+ goto err;
+ }
+ } else {
+ get_options_mutable()->key_expiration_format =
+ KEY_EXPIRATION_FORMAT_ISO8601;
+ }
+
if (config_line_find(cmdline_only_options, "--newpass")) {
if (command == CMD_KEYGEN) {
get_options_mutable()->change_key_passphrase = 1;
diff --git a/src/app/config/or_options_st.h b/src/app/config/or_options_st.h
index 68be5711ce..774b476476 100644
--- a/src/app/config/or_options_st.h
+++ b/src/app/config/or_options_st.h
@@ -945,6 +945,11 @@ struct or_options_t {
int OfflineMasterKey;
enum {
+ KEY_EXPIRATION_FORMAT_ISO8601 = 0,
+ KEY_EXPIRATION_FORMAT_TIMESTAMP
+ } key_expiration_format;
+
+ enum {
FORCE_PASSPHRASE_AUTO=0,
FORCE_PASSPHRASE_ON,
FORCE_PASSPHRASE_OFF