diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-08-19 13:36:59 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-08-19 13:36:59 -0400 |
commit | 428bb2d1c8bf5f10f7f76b9861b9a3ce498e07a7 (patch) | |
tree | 094116842853ec1472a18570a3310017fe6fabc9 /src/or/config.c | |
parent | 2f5202c6362408df5aad8f57f8dfffbafcbe0833 (diff) | |
parent | 8589c4704908c6089285226db7ae361634f8b843 (diff) | |
download | tor-428bb2d1c8bf5f10f7f76b9861b9a3ce498e07a7.tar.gz tor-428bb2d1c8bf5f10f7f76b9861b9a3ce498e07a7.zip |
Merge branch 'ed25519_keygen_squashed'
Diffstat (limited to 'src/or/config.c')
-rw-r--r-- | src/or/config.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/or/config.c b/src/or/config.c index 8d0bbd8798..6e782de0e0 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1918,6 +1918,8 @@ static const struct { { "--dump-config", ARGUMENT_OPTIONAL }, { "--list-fingerprint", TAKES_NO_ARGUMENT }, { "--keygen", TAKES_NO_ARGUMENT }, + { "--no-passphrase", TAKES_NO_ARGUMENT }, + { "--passphrase-fd", ARGUMENT_NECESSARY }, { "--verify-config", TAKES_NO_ARGUMENT }, { "--ignore-missing-torrc", TAKES_NO_ARGUMENT }, { "--quiet", TAKES_NO_ARGUMENT }, @@ -4498,6 +4500,43 @@ options_init_from_torrc(int argc, char **argv) retval = options_init_from_string(cf_defaults, cf, command, command_arg, &errmsg); + if (retval < 0) + goto err; + + if (config_line_find(cmdline_only_options, "--no-passphrase")) { + if (command == CMD_KEYGEN) { + get_options_mutable()->keygen_force_passphrase = FORCE_PASSPHRASE_OFF; + } else { + log_err(LD_CONFIG, "--no-passphrase specified without --keygen!"); + exit(1); + } + } + + { + const config_line_t *fd_line = config_line_find(cmdline_only_options, + "--passphrase-fd"); + if (fd_line) { + if (get_options()->keygen_force_passphrase == FORCE_PASSPHRASE_OFF) { + log_err(LD_CONFIG, "--no-passphrase specified with --passphrase-fd!"); + exit(1); + } else if (command != CMD_KEYGEN) { + log_err(LD_CONFIG, "--passphrase-fd specified without --keygen!"); + exit(1); + } else { + const char *v = fd_line->value; + int ok = 1; + long fd = tor_parse_long(v, 10, 0, INT_MAX, &ok, NULL); + if (fd < 0 || ok == 0) { + log_err(LD_CONFIG, "Invalid --passphrase-fd value %s", escaped(v)); + exit(1); + } + get_options_mutable()->keygen_passphrase_fd = (int)fd; + get_options_mutable()->use_keygen_passphrase_fd = 1; + get_options_mutable()->keygen_force_passphrase = FORCE_PASSPHRASE_ON; + } + } + } + err: tor_free(cf); |