aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerkeys.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-06-17 13:51:45 -0400
committerNick Mathewson <nickm@torproject.org>2015-06-17 13:51:45 -0400
commitc2c23d1443ba69d356a11303071e4ea5723ba1b6 (patch)
treeaaccdbf87f358380f94252d968be0ed9d3d094da /src/or/routerkeys.c
parent118bfab75b4115b5490120fe4f6445095bbc9227 (diff)
downloadtor-c2c23d1443ba69d356a11303071e4ea5723ba1b6.tar.gz
tor-c2c23d1443ba69d356a11303071e4ea5723ba1b6.zip
Handle "keygen" if datadir does not yet exist
Diffstat (limited to 'src/or/routerkeys.c')
-rw-r--r--src/or/routerkeys.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/or/routerkeys.c b/src/or/routerkeys.c
index 277dc6e4aa..f5cae44f5b 100644
--- a/src/or/routerkeys.c
+++ b/src/or/routerkeys.c
@@ -486,8 +486,19 @@ load_ed_keys(const or_options_t *options, time_t now)
if (options->command == CMD_KEYGEN)
flags |= INIT_ED_KEY_TRY_ENCRYPTED;
- char *fname =
- options_get_datadir_fname2(options, "keys", "ed25519_master_id");
+ /* Check the key directory */
+ if (check_private_dir(options->DataDirectory, CPD_CREATE, options->User)) {
+ log_err(LD_OR, "Can't create/check datadirectory %s",
+ options->DataDirectory);
+ goto err;
+ }
+ char *fname = get_datadir_fname("keys");
+ if (check_private_dir(fname, CPD_CREATE, options->User) < 0) {
+ log_err(LD_OR, "Problem creating/checking key directory %s", fname);
+ tor_free(fname);
+ goto err;
+ }
+ fname = options_get_datadir_fname2(options, "keys", "ed25519_master_id");
id = ed_key_init_from_file(
fname,
flags,