Skip to content

Commit

Permalink
Connected logger to other classes
Browse files Browse the repository at this point in the history
  • Loading branch information
p0dalirius committed Jun 24, 2024
1 parent 43100f6 commit e514ac5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
8 changes: 6 additions & 2 deletions smbclientng/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from smbclientng.core.Config import Config
from smbclientng.core.Credentials import Credentials
from smbclientng.core.InteractiveShell import InteractiveShell
from smbclientng.core.Logger import Logger
from smbclientng.core.SessionsManager import SessionsManager


Expand Down Expand Up @@ -106,7 +107,9 @@ def main():
config.not_interactive = options.not_interactive
config.startup_script = options.startup_script

sessionsManager = SessionsManager(config=config)
logger = Logger(config=config, logfile=None)

sessionsManager = SessionsManager(config=config, logger=logger)

if any([(options.auth_domain != '.'), (options.auth_username is not None), (options.auth_password is not None),(options.auth_hashes is not None)]):
credentials = Credentials(
Expand All @@ -127,7 +130,8 @@ def main():
# Start the main interactive command line
shell = InteractiveShell(
sessionsManager=sessionsManager,
config=config
config=config,
logger=logger
)
shell.run()

Expand Down
4 changes: 3 additions & 1 deletion smbclientng/core/InteractiveShell.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ class InteractiveShell(object):
running = True
modules = {}

def __init__(self, sessionsManager, config):
def __init__(self, sessionsManager, config, logger):
# Objects
self.sessionsManager = sessionsManager
self.config = config
self.logger = logger
# Internals
self.commandCompleterObject = CommandCompleter(smbSession=self.sessionsManager.current_session, config=self.config)
readline.set_completer(self.commandCompleterObject.complete)
readline.parse_and_bind("tab: complete")
Expand Down
3 changes: 2 additions & 1 deletion smbclientng/core/Module.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ class Module(object):
smbSession = None
options = None

def __init__(self, smbSession, config):
def __init__(self, smbSession, config, logger):
self.smbSession = smbSession
self.config = config
self.logger = logger

def parseArgs(self):
raise NotImplementedError("Subclasses must implement this method")
Expand Down
3 changes: 2 additions & 1 deletion smbclientng/core/SMBSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ class SMBSession(object):
test_rights(sharename): Tests read and write access rights on a share.
"""

def __init__(self, host, port, credentials, config=None):
def __init__(self, host, port, credentials, config=None, logger=None):
super(SMBSession, self).__init__()
# Objects
self.config = config
self.logger = logger

# Target server
self.host = host
Expand Down
5 changes: 3 additions & 2 deletions smbclientng/core/SessionsManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ class SessionsManager(object):
current_session_id = None
sessions = {}

def __init__(self, config):
def __init__(self, config, logger):
self.sessions = {}
self.next_session_id = 1
self.current_session = None
self.current_session_id = None

self.config = config
self.config = config,
self.logger = logger

def create_new_session(self, credentials, host, port=445):
"""
Expand Down

0 comments on commit e514ac5

Please sign in to comment.