[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r8386: Refactor dirserv_parse_fingerprint_file(fname) into dirserv_ (in tor/trunk: . src/or)



Author: weasel
Date: 2006-09-14 00:53:23 -0400 (Thu, 14 Sep 2006)
New Revision: 8386

Modified:
   tor/trunk/
   tor/trunk/src/or/dirserv.c
   tor/trunk/src/or/main.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/router.c
Log:
 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.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /local/or/tor/trunk [r9736] on 17f730b7-d419-0410-b50f-85ee4b70197a

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2006-09-13 22:24:43 UTC (rev 8385)
+++ tor/trunk/src/or/dirserv.c	2006-09-14 04:53:23 UTC (rev 8386)
@@ -122,24 +122,31 @@
   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 {

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2006-09-13 22:24:43 UTC (rev 8385)
+++ tor/trunk/src/or/main.c	2006-09-14 04:53:23 UTC (rev 8386)
@@ -1036,7 +1036,6 @@
 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 @@
   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.");
     }

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2006-09-13 22:24:43 UTC (rev 8385)
+++ tor/trunk/src/or/or.h	2006-09-14 04:53:23 UTC (rev 8386)
@@ -2095,7 +2095,7 @@
 
 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);

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2006-09-13 22:24:43 UTC (rev 8385)
+++ tor/trunk/src/or/router.c	2006-09-14 04:53:23 UTC (rev 8386)
@@ -353,9 +353,7 @@
   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;
   }