mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 00:22:28 +02:00
Split out parent and child listeners into methods
This commit is contained in:
@@ -238,7 +238,6 @@ class StandaloneAuthenticator(object):
|
||||
self.subproc_inuse = False
|
||||
self.subproc_cantbind = False
|
||||
self.tasks = {}
|
||||
self.which = None
|
||||
self.sock = None
|
||||
self.connection = None
|
||||
self.private_key = None
|
||||
@@ -311,19 +310,10 @@ class StandaloneAuthenticator(object):
|
||||
new_ctx.use_privatekey(self.private_key)
|
||||
connection.set_context(new_ctx)
|
||||
|
||||
def start_listener(self, port, key):
|
||||
"""Create a child process which will start a TCP listener on the
|
||||
specified port to perform the specified DVSNI challenges.
|
||||
def do_parent_process(self, port):
|
||||
"""Perform the parent process side of the TCP listener task. This
|
||||
should only be called by start_listener()."""
|
||||
|
||||
:param int port: The TCP port to bind.
|
||||
:param str key: The private key to use (in PEM format).
|
||||
"""
|
||||
fork_result = os.fork()
|
||||
Crypto.Random.atfork()
|
||||
if fork_result:
|
||||
# PARENT process (still the Let's Encrypt client process)
|
||||
self.which = "parent"
|
||||
self.child_pid = fork_result
|
||||
signal.signal(signal.SIGIO, self.client_signal_handler)
|
||||
signal.signal(signal.SIGUSR1, self.client_signal_handler)
|
||||
signal.signal(signal.SIGUSR2, self.client_signal_handler)
|
||||
@@ -350,10 +340,10 @@ class StandaloneAuthenticator(object):
|
||||
"Subprocess unexpectedly timed out while trying to bind TCP "
|
||||
"port {}.".format(CONFIG.PORT))
|
||||
return False
|
||||
else:
|
||||
# CHILD process (the TCP listener subprocess)
|
||||
self.which = "child"
|
||||
self.child_pid = os.getpid()
|
||||
|
||||
def do_child_process(self, port, key):
|
||||
"""Perform the child process side of the TCP listener task. This
|
||||
should only be called by start_listener()."""
|
||||
signal.signal(signal.SIGINT, self.subproc_signal_handler)
|
||||
self.sock = socket.socket()
|
||||
try:
|
||||
@@ -423,6 +413,24 @@ class StandaloneAuthenticator(object):
|
||||
# self.connection.send(tls_generate_server_hello_done())
|
||||
# self.connection.close()
|
||||
|
||||
def start_listener(self, port, key):
|
||||
"""Create a child process which will start a TCP listener on the
|
||||
specified port to perform the specified DVSNI challenges.
|
||||
|
||||
:param int port: The TCP port to bind.
|
||||
:param str key: The private key to use (in PEM format).
|
||||
"""
|
||||
fork_result = os.fork()
|
||||
Crypto.Random.atfork()
|
||||
if fork_result:
|
||||
# PARENT process (still the Let's Encrypt client process)
|
||||
self.child_pid = fork_result
|
||||
self.do_parent_process(port)
|
||||
else:
|
||||
# CHILD process (the TCP listener subprocess)
|
||||
self.child_pid = os.getpid()
|
||||
self.do_child_process(port, key)
|
||||
|
||||
# IAuthenticator method implementations follow
|
||||
|
||||
def get_chall_pref(self, unused_domain):
|
||||
|
||||
Reference in New Issue
Block a user