Skip to content

Commit

Permalink
Agent: Stop the server process if the reactor is not running
Browse files Browse the repository at this point in the history
Just because the Twisted reactor failed to start doesn't mean that the
server process is not running. The server process should be stopped
before raising the LDAPServerStartError, otherwise the server or process
may be left running indefinitely.

Fixes #2820
  • Loading branch information
mssalvatore committed Jan 12, 2023
1 parent 4494875 commit fa75f4c
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from ldaptor.protocols.ldap.ldapserver import LDAPServer
from twisted.internet.protocol import ServerFactory

from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT

# WARNING: It was observed that this LDAP server would raise an exception and fail to start if
# multiple Python threads attempt to start multiple LDAP servers simultaneously. It was
# thought that since each LDAP server is started in its own process, there would be no
Expand Down Expand Up @@ -118,6 +120,8 @@ def run(self):
reactor_running = self._reactor_startup_completed.wait(REACTOR_START_TIMEOUT_SEC)

if not reactor_running:
logger.error("The LDAP server failed to start, stopping the server process...")
self.stop(timeout=LONG_REQUEST_TIMEOUT)
raise LDAPServerStartError("An unknown error prevented the LDAP server from starting")

logger.debug("The LDAP exploit server has successfully started")
Expand Down

0 comments on commit fa75f4c

Please sign in to comment.