summaryrefslogtreecommitdiff
path: root/src/or/routerkeys.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-11-14 16:18:53 -0500
committerNick Mathewson <nickm@torproject.org>2017-12-05 19:49:28 -0500
commit7b34ab3e384b5c72e938d11e5e05c72b9d529bb8 (patch)
tree58bfece83dc694baf4e75a9127a1c7371e589824 /src/or/routerkeys.c
parent2e872f6b32edaace096180c249934c620cd3ce35 (diff)
downloadtor-7b34ab3e384b5c72e938d11e5e05c72b9d529bb8.tar.gz
tor-7b34ab3e384b5c72e938d11e5e05c72b9d529bb8.zip
Extract common code for creating the keys directory.
This had somehow gotten duplicated between router.c and routerkeys.c
Diffstat (limited to 'src/or/routerkeys.c')
-rw-r--r--src/or/routerkeys.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/or/routerkeys.c b/src/or/routerkeys.c
index 7295c19653..c6c689ecd5 100644
--- a/src/or/routerkeys.c
+++ b/src/or/routerkeys.c
@@ -813,21 +813,10 @@ load_ed_keys(const or_options_t *options, time_t now)
flags |= INIT_ED_KEY_TRY_ENCRYPTED;
/* Check/Create the key directory */
- cpd_check_t cpd_opts = CPD_CREATE;
- if (options->DataDirectoryGroupReadable)
- cpd_opts |= CPD_GROUP_READ;
- if (check_private_dir(options->DataDirectory, cpd_opts, 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;
- }
- tor_free(fname);
+ if (create_keys_directory(options) < 0)
+ return -1;
+
+ char *fname;
if (options->master_key_fname) {
fname = tor_strdup(options->master_key_fname);
flags |= INIT_ED_KEY_EXPLICIT_FNAME;