]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Documentation and tests for 10060
authorNick Mathewson <nickm@torproject.org>
Thu, 7 Nov 2013 19:42:58 +0000 (14:42 -0500)
committerNick Mathewson <nickm@torproject.org>
Thu, 7 Nov 2013 19:42:58 +0000 (14:42 -0500)
changes/ticket10060
doc/tor.1.txt
src/test/test_cmdline_args.py

index 6ad0feb04b2f600e5989854264e5f5d0e5954e78..867c46436ba441e6a7e202169cc1c71e52c84fca 100644 (file)
@@ -1,6 +1,5 @@
   o Minor features:
-    - Adding --allow-missing-torrc commandline option 
-      that allows Tor to run if configuration file specified
-      by -f is not available, but default torrc is. 
+    - Adding --allow-missing-torrc commandline option that allows Tor to
+      run if configuration file specified by -f is not available.
       Implements ticket 10060.
 
index 82f4e33763e28eb8d71f95e8e624abcfaedbf0d9..b457ee5a7ea48a19d76f9fca065047031d8ff66e 100644 (file)
@@ -55,6 +55,11 @@ COMMAND-LINE OPTIONS
     configuration file, and by those on the command line. (Default:
     @CONFDIR@/torrc-defaults.)
 
+[[opt-ignore-missing-torrc]] **--ignore-missing-torrc**::
+    Specifies that Tor should treat a missing torrc file as though it
+    were empty. Ordinarily, Tor does this for missing default torrc files,
+    but not for those specified on the command line.
+
 [[opt-hash-password]] **--hash-password** __PASSWORD__::
     Generates a hashed password for control port access.
 
index 2213bb5702b6a79a62d4e21de9e22fc4a64ac3af..e8edaa026375866eaefafce7fa164e4c7d751a93 100755 (executable)
@@ -60,6 +60,10 @@ def strip_log_junk(line):
         return ""+line
     return m.group(2).strip()
 
+def randstring(entropy_bytes):
+    s = os.urandom(entropy_bytes)
+    return binascii.b2a_hex(s)
+
 class CmdlineTests(unittest.TestCase):
 
     def test_version(self):
@@ -247,5 +251,17 @@ class CmdlineTests(unittest.TestCase):
                            "ORPort 9003",
                            "SocksPort 9090"])
 
+    def test_missing_torrc(self):
+        fname = "nonexistent_file_"+randstring(8)
+        out = run_tor(["-f", fname, "--verify-config"], failure=True)
+        ln = [ strip_log_junk(l) for l in lines(out) ]
+        self.assert_("Unable to open configuration file" in ln[-2])
+        self.assert_("Reading config failed" in ln[-1])
+
+        out = run_tor(["-f", fname, "--verify-config", "--ignore-missing-torrc"])
+        ln = [ strip_log_junk(l) for l in lines(out) ]
+        self.assert_(", using reasonable defaults" in ln[-2])
+        self.assert_("Configuration was valid" in ln[-1])
+
 if __name__ == '__main__':
     unittest.main()