mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
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
This commit is contained in:
parent
7f1fa9aab5
commit
984e8f6efb
@ -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 {
|
||||
|
@ -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.");
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user