Browse Source

r11666@catbus: nickm | 2007-02-06 13:17:24 -0500
Implement an --ignore-missing-torrc option


svn:r9501

Nick Mathewson 17 years ago
parent
commit
f4a1c17e5a
2 changed files with 11 additions and 2 deletions
  1. 4 0
      ChangeLog
  2. 7 2
      src/or/config.c

+ 4 - 0
ChangeLog

@@ -100,6 +100,10 @@ Changes in version 0.1.2.7-alpha - 2007-02-06
       create_fast cell if we don't know anything about a router.
     - Allow exit nodes to use nameservers running on ports other than 53.
     - Servers now cache reverse DNS replies.
+    - Add an --ignore-missing-torrc command-line option so that we can
+      get the "use sensible defaults if the configuration file doesn't
+      exist" behavior even when specifying a torrc location on the command
+      line.
 
   o Minor features (controller):
     - Track reasons for OR connection failure; make these reasons

+ 7 - 2
src/or/config.c

@@ -1075,7 +1075,8 @@ config_get_commandlines(int argc, char **argv, config_line_t **result)
       i += 2; /* command-line option with argument. ignore them. */
       continue;
     } else if (!strcmp(argv[i],"--list-fingerprint") ||
-               !strcmp(argv[i],"--verify-config")) {
+               !strcmp(argv[i],"--verify-config") ||
+               !strcmp(argv[i],"--ignore-missing-torrc")) {
       i += 1; /* command-line option. ignore it. */
       continue;
     } else if (!strcmp(argv[i],"--nt-service") ||
@@ -2967,6 +2968,7 @@ options_init_from_torrc(int argc, char **argv)
   char *cf=NULL, *fname=NULL, *errmsg=NULL;
   int i, retval;
   int using_default_torrc;
+  int ignore_missing_torrc;
   static char **backup_argv;
   static int backup_argc;
 
@@ -3004,6 +3006,7 @@ options_init_from_torrc(int argc, char **argv)
   /* learn config file name */
   fname = NULL;
   using_default_torrc = 1;
+  ignore_missing_torrc = 0;
   newoptions->command = CMD_RUN_TOR;
   for (i = 1; i < argc; ++i) {
     if (i < argc-1 && !strcmp(argv[i],"-f")) {
@@ -3014,6 +3017,8 @@ options_init_from_torrc(int argc, char **argv)
       fname = tor_strdup(argv[i+1]);
       using_default_torrc = 0;
       ++i;
+    } else if (!strcmp(argv[i],"--ignore-missing-torrc")) {
+      ignore_missing_torrc = 1;
     } else if (!strcmp(argv[i],"--list-fingerprint")) {
       newoptions->command = CMD_LIST_FINGERPRINT;
     } else if (!strcmp(argv[i],"--hash-password")) {
@@ -3053,7 +3058,7 @@ options_init_from_torrc(int argc, char **argv)
   /* get config lines, assign them */
   if (file_status(fname) != FN_FILE ||
       !(cf = read_file_to_str(fname,0,NULL))) {
-    if (using_default_torrc == 1) {
+    if (using_default_torrc == 1 || ignore_missing_torrc ) {
       log(LOG_NOTICE, LD_CONFIG, "Configuration file \"%s\" not present, "
           "using reasonable defaults.", fname);
       tor_free(fname); /* sets fname to NULL */