diff --git a/fakenet/listeners/FTPListener.py b/fakenet/listeners/FTPListener.py index 3b6bd5b..a2f4343 100644 --- a/fakenet/listeners/FTPListener.py +++ b/fakenet/listeners/FTPListener.py @@ -100,6 +100,16 @@ def __init__(self, config, name = 'FTPListener', logging_level = logging.INFO): # Initialize webroot directory self.ftproot_path = self.config.get('ftproot','defaultFiles') + # Try absolute path first + if not os.path.exists(self.ftproot_path): + + # Try to locate the ftproot directory relative to application path + self.ftproot_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), self.ftproot_path) + + if not os.path.exists(self.ftproot_path): + self.logger.error('Could not locate ftproot directory: %s', self.ftproot_path) + sys.exit(1) + def expand_ports(self, ports_list): ports = [] for i in ports_list.split(','):