|
@@ -756,6 +756,10 @@ DEFAULTS = {
|
|
|
'controlling_pid': (int(os.environ.get('CHUTNEY_CONTROLLING_PID', 0))
|
|
|
if 'CHUTNEY_CONTROLLING_PID' in os.environ
|
|
|
else None),
|
|
|
+ # a DNS config file (for ServerDNSResolvConfFile)
|
|
|
+ 'dns_conf': (os.environ.get('CHUTNEY_DNS_CONF', '/etc/resolv.conf')
|
|
|
+ if 'CHUTNEY_DNS_CONF' in os.environ
|
|
|
+ else None),
|
|
|
}
|
|
|
|
|
|
|
|
@@ -775,6 +779,10 @@ class TorEnviron(chutney.Templating.Environ):
|
|
|
hs_hostname: the hostname of the key generated by a hidden service
|
|
|
owning_controller_process: the __OwningControllerProcess torrc line,
|
|
|
disabled if tor should continue after the script exits
|
|
|
+ server_dns_resolv_conf: the ServerDNSResolvConfFile torrc line,
|
|
|
+ disabled if tor should use the default DNS conf.
|
|
|
+ If the dns_conf file is missing, this option is also disabled:
|
|
|
+ otherwise, exits would not work due to tor bug #21900.
|
|
|
|
|
|
Environment fields used:
|
|
|
nodenum: chutney's internal node number for the node
|
|
@@ -792,6 +800,8 @@ class TorEnviron(chutney.Templating.Environ):
|
|
|
hs-hostname (note hyphen): cached hidden service hostname value
|
|
|
controlling_pid: the PID of the controlling process. After this
|
|
|
process exits, the child tor processes will exit
|
|
|
+ dns_conf: the path to a DNS config file for Tor Exits. If this file
|
|
|
+ is empty or unreadable, Tor will try 127.0.0.1:53.
|
|
|
"""
|
|
|
|
|
|
def __init__(self, parent=None, **kwargs):
|
|
@@ -867,6 +877,34 @@ class TorEnviron(chutney.Templating.Environ):
|
|
|
else:
|
|
|
return ocp_line
|
|
|
|
|
|
+ # the default resolv.conf path is set at compile time
|
|
|
+ # there's no easy way to get it out of tor, so we use the typical value
|
|
|
+ DEFAULT_DNS_RESOLV_CONF = "/etc/resolv.conf"
|
|
|
+ # if we can't find the specified file, use this one as a substitute
|
|
|
+ OFFLINE_DNS_RESOLV_CONF = "/dev/null"
|
|
|
+
|
|
|
+ def _get_server_dns_resolv_conf(self, my):
|
|
|
+ if my['dns_conf'] == "":
|
|
|
+ # if the user asked for tor's default
|
|
|
+ return "#ServerDNSResolvConfFile using tor's compile-time default"
|
|
|
+ elif my['dns_conf'] is None:
|
|
|
+ # if there is no DNS conf file set
|
|
|
+ print("CHUTNEY_DNS_CONF not specified, using '%s'."
|
|
|
+ % (DEFAULT_DNS_RESOLV_CONF))
|
|
|
+ dns_conf = DEFAULT_DNS_RESOLV_CONF
|
|
|
+ else:
|
|
|
+ dns_conf = my['dns_conf']
|
|
|
+ dns_conf = os.path.abspath(my['dns_conf'])
|
|
|
+ # work around Tor bug #21900, where exits fail when the DNS conf
|
|
|
+ # file does not exist, or is a broken symlink
|
|
|
+ # (os.path.exists returns False for broken symbolic links)
|
|
|
+ if not os.path.exists(dns_conf):
|
|
|
+ # Issue a warning so the user notices
|
|
|
+ print("CHUTNEY_DNS_CONF '%s' does not exist, using '%s'."
|
|
|
+ % (dns_conf, OFFLINE_DNS_RESOLV_CONF))
|
|
|
+ dns_conf = OFFLINE_DNS_RESOLV_CONF
|
|
|
+ return "ServerDNSResolvConfFile %s" % (dns_conf)
|
|
|
+
|
|
|
|
|
|
class Network(object):
|
|
|
|