diff options
author | Peter Palfrader <peter@palfrader.org> | 2006-09-14 04:53:23 +0000 |
---|---|---|
committer | Peter Palfrader <peter@palfrader.org> | 2006-09-14 04:53:23 +0000 |
commit | 984e8f6efb9dd50b5848545f12c6c81e4173fe5d (patch) | |
tree | 661a5212ff4dc555d53174b7d5e0810e4e4fae8b /src | |
parent | 7f1fa9aab50767e65780d49490249d6b583ef397 (diff) | |
download | tor-984e8f6efb9dd50b5848545f12c6c81e4173fe5d.tar.gz tor-984e8f6efb9dd50b5848545f12c6c81e4173fe5d.zip |
r9736@danube: weasel | 2006-09-14 05:53:06 +0200
Refactor dirserv_parse_fingerprint_file(fname) into dirserv_load_fingerprint_file():
There is not need to put together the path to the approved-routers file in more than one place.
svn:r8386
Diffstat (limited to 'src')
-rw-r--r-- | src/or/dirserv.c | 23 | ||||
-rw-r--r-- | src/or/main.c | 8 | ||||
-rw-r--r-- | src/or/or.h | 2 | ||||
-rw-r--r-- | src/or/router.c | 4 |
4 files changed, 19 insertions, 18 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index b2342be22e..f01a7d5ff0 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -122,24 +122,31 @@ dirserv_add_own_fingerprint(const char *nickname, crypto_pk_env_t *pk) return 0; } -/** Parse the nickname-\>fingerprint mappings stored in the file named - * <b>fname</b>. The file format is line-based, with each non-blank - * holding one nickname, some space, and a fingerprint for that - * nickname. On success, replace the current fingerprint list with - * the contents of <b>fname</b> and return 0. On failure, leave the - * current fingerprint list untouched, and return -1. */ +/** Load the nickname-\>fingerprint mappings stored in the approved-routers + * file. The file format is line-based, with each non-blank holding one + * nickname, some space, and a fingerprint for that nickname. On success, + * replace the current fingerprint list with the new list and return 0. On + * failure, leave the current fingerprint list untouched, and + * return -1. */ int -dirserv_parse_fingerprint_file(const char *fname) +dirserv_load_fingerprint_file() { + char fname[512]; char *cf; char *nickname, *fingerprint; smartlist_t *fingerprint_list_new; int result; config_line_t *front=NULL, *list; + or_options_t *options = get_options(); + + tor_snprintf(fname, sizeof(fname), + "%s/approved-routers", options->DataDirectory); + log_info(LD_GENERAL, + "Reloading approved fingerprints from \"%s\"...", fname); cf = read_file_to_str(fname, 0); if (!cf) { - if (get_options()->NamingAuthoritativeDir) { + if (options->NamingAuthoritativeDir) { log_warn(LD_FS, "Cannot open fingerprint file '%s'. Failing.", fname); return -1; } else { diff --git a/src/or/main.c b/src/or/main.c index 118a82c9a7..97fe98ba9d 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1036,7 +1036,6 @@ got_libevent_error(void) static int do_hup(void) { - char keydir[512]; or_options_t *options = get_options(); log_notice(LD_GENERAL,"Received reload signal (hup). Reloading config."); @@ -1056,11 +1055,8 @@ do_hup(void) options = get_options(); /* they have changed now */ if (authdir_mode(options)) { /* reload the approved-routers file */ - tor_snprintf(keydir, sizeof(keydir), - "%s/approved-routers", options->DataDirectory); - log_info(LD_GENERAL, - "Reloading approved fingerprints from \"%s\"...", keydir); - if (dirserv_parse_fingerprint_file(keydir) < 0) { + if (dirserv_load_fingerprint_file() < 0) { + /* warnings are logged from dirserv_load_fingerprint_file() directly */ log_info(LD_GENERAL, "Error reloading fingerprints. " "Continuing with old list."); } diff --git a/src/or/or.h b/src/or/or.h index eed3578168..43f13328ae 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2095,7 +2095,7 @@ char *directory_dump_request_log(void); int connection_dirserv_flushed_some(dir_connection_t *conn); int dirserv_add_own_fingerprint(const char *nickname, crypto_pk_env_t *pk); -int dirserv_parse_fingerprint_file(const char *fname); +int dirserv_load_fingerprint_file(); void dirserv_free_fingerprint_list(void); const char *dirserv_get_nickname_by_digest(const char *digest); int dirserv_add_descriptor(const char *desc, const char **msg); diff --git a/src/or/router.c b/src/or/router.c index 0fb8cf2b73..7c42ff77a0 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -353,9 +353,7 @@ init_keys(void) if (!authdir_mode(options)) return 0; /* 6. [authdirserver only] load approved-routers file */ - tor_snprintf(keydir,sizeof(keydir),"%s/approved-routers", datadir); - log_info(LD_DIRSERV,"Loading approved fingerprints from \"%s\"...",keydir); - if (dirserv_parse_fingerprint_file(keydir) < 0) { + if (dirserv_load_fingerprint_file() < 0) { log_err(LD_GENERAL,"Error loading fingerprints"); return -1; } |