def __init__(self, silent=False): """ Gather all the information we need about this node. """ self.silent = silent try: self.cwrite('Determining configuration root path...') # Gather information about this node. self.config_root = determine_config_root() if not self.config_root: self.error = True self.cwriteline('[Error]', 'Unable to determine configuration root.') return self.cwriteline( '[OK]', 'Configuration root set to "{0}"'.format(self.config_root)) # Check to see if our configuration path is in a home directory. if os.path.expanduser('~') in self.config_root: _logger.warning( 'Not running as root, setting configuration path to "{0}"'. format(self.config_root)) _logger.warning( 'Since we are not running as root, system firewall settings will not be changed.' ) # Change the default path for pid and log file to config_root. self.pid_file = os.path.join(self.config_root, 'sdc.pid') self.log_file = os.path.join(self.config_root, 'sdc.log') if not self._check_for_external_progs(): self.error = True elif not self._init_system_check(): self.error = True elif not self._firewall_check(): self.error = True elif not self._get_machine_id(): self.error = True except: self.error = True
def __init__(self, config_file=None): """ Initialize the configuration object with the most reasonable values for the default settings. :param config_file: Use alternate configuration file. """ self._config_root = determine_config_root() # Set the configuration file path and name. if config_file: self._config_file = config_file self._config_root = os.path.split(config_file)[0] else: self._config_file = os.path.join(self._config_root, 'sdc.conf') # Set the default file paths based on if we are running as root or not. if os.getuid() == 0: self.set(self._config_section, 'pidfile', '/var/run/silentdune/sdc.pid') self.set(self._config_section, 'logfile', '/var/log/silentdune.log') else: self.set(self._config_section, 'pidfile', os.path.join(self._config_root, 'sdc.pid')) self.set(self._config_section, 'logfile', os.path.join(self._config_root, 'silentdune.log')) # self.set(self._config_section, 'user', 'silentdune') # self.set(self._config_section, 'group', 'silentdune') # # Set the previous firewall service to the currently running firewall. # self.set(self._config_section, 'previous_firewall_service', get_active_firewall()) # Set the section heading comments self.set_comment( self._config_section, 'settings', _('; Silent Dune Client Configuration File\n' # noqa '; This file was automatically generated by the installer.\n' '; Run "sdc-install --help" to configure this file.\n')) # Set the section item comments self.set_comment( self._config_section, 'pidfile', _('; The path and file name for the PID file.\n')) # noqa
def __init__(self, config_file=None): """ Initialize the configuration object with the most reasonable values for the default settings. :param config_file: Use alternate configuration file. """ self._config_root = determine_config_root() # Set the configuration file path and name. if config_file: self._config_file = config_file self._config_root = os.path.split(config_file)[0] else: self._config_file = os.path.join(self._config_root, 'sdc.conf') # Set the default file paths based on if we are running as root or not. if os.getuid() == 0: self.set(self._config_section, 'pidfile', '/var/run/silentdune/sdc.pid') self.set(self._config_section, 'logfile', '/var/log/silentdune/sdc-firewall.log') else: self.set(self._config_section, 'pidfile', os.path.join(self._config_root, 'sdc.pid')) self.set(self._config_section, 'logfile', os.path.join(self._config_root, 'sdc-firewall.log')) # self.set(self._config_section, 'user', 'silentdune') # self.set(self._config_section, 'group', 'silentdune') # Set the previous firewall service to the currently running firewall. self.set(self._config_section, 'previous_firewall_service', get_active_firewall()) # Set the section heading comments self.set_comment(self._config_section, 'settings', _('; Silent Dune Client Configuration File\n' # noqa '; This file was automatically generated by the installer.\n')) # Set the section item comments self.set_comment(self._config_section, 'pidfile', _('; The path and file name for the PID file.\n')) # noqa self.set_comment(self._config_section, 'user', _('; The local user the service should run as.\n' # noqa '; Default: silentdune.\n')) self.set_comment(self._config_section, 'group', _('; The local group the service should run as.\n' # noqa '; Default: silentdune.\n')) self.set_comment(self._config_section, 'previous_firewall_service', _('; The previous firewall service. Warning: Changing this value may\n' # noqa '; compromise security on this system if the Silent Dune client is\n' '; uninstalled.\n'))
def __init__(self, config_file=None): """ Initialize the configuration object with the most reasonable values for the default settings. :param config_file: Use alternate configuration file. """ self._config_root = determine_config_root() # Set the configuration file path and name. if config_file: self._config_file = config_file self._config_root = os.path.split(config_file)[0] else: self._config_file = os.path.join(self._config_root, "sdc.conf") # Set the default file paths based on if we are running as root or not. if os.getuid() == 0: self.set(self._config_section, "pidfile", "/var/run/silentdune/sdc.pid") self.set(self._config_section, "logfile", "/var/log/silentdune.log") else: self.set(self._config_section, "pidfile", os.path.join(self._config_root, "sdc.pid")) self.set(self._config_section, "logfile", os.path.join(self._config_root, "silentdune.log")) # self.set(self._config_section, 'user', 'silentdune') # self.set(self._config_section, 'group', 'silentdune') # # Set the previous firewall service to the currently running firewall. # self.set(self._config_section, 'previous_firewall_service', get_active_firewall()) # Set the section heading comments self.set_comment( self._config_section, "settings", _( "; Silent Dune Client Configuration File\n" # noqa "; This file was automatically generated by the installer.\n" '; Run "sdc-install --help" to configure this file.\n' ), ) # Set the section item comments self.set_comment(self._config_section, "pidfile", _("; The path and file name for the PID file.\n")) # noqa
def __init__(self, console_debug=False): """ Gather all the information we need about this node. """ self.console_debug = console_debug if sys.platform == "linux" or sys.platform == "linux2": self.platform = 'linux' elif sys.platform == "darwin": self.platform = 'osx' # OS X elif sys.platform == "win32": self.platform = 'windows' # Gather information about this node. self.config_root = determine_config_root() if not self.config_root: if self.console_debug: print('Error: Unable to determine configuration root.') self.error = True return # Check to see if our configuration path is in a home directory. if os.path.expanduser('~') in self.config_root: _logger.warning('Not running as root, setting configuration path to "{0}"'.format(self.config_root)) _logger.warning('Since we are not running as root, system firewall settings will not be changed.') # Change the default path for pid and log file to config_root. self.pid_file = os.path.join(self.config_root, 'sdc.pid') self.log_file = os.path.join(self.config_root, 'sdc.log') if not self._check_for_external_progs(): self.error = True elif not self._init_system_check(): self.error = True elif not self._firewall_check(): self.error = True elif not self._get_machine_id(): self.error = True
def __init__(self, silent=False): """ Gather all the information we need about this node. """ self.silent = silent try: self.cwrite('Determining configuration root path...') # Gather information about this node. self.config_root = determine_config_root() if not self.config_root: self.error = True self.cwriteline('[Error]', 'Unable to determine configuration root.') return self.cwriteline('[OK]', 'Configuration root set to "{0}"'.format(self.config_root)) # Check to see if our configuration path is in a home directory. if os.path.expanduser('~') in self.config_root: _logger.warning('Not running as root, setting configuration path to "{0}"'.format(self.config_root)) _logger.warning('Since we are not running as root, system firewall settings will not be changed.') # Change the default path for pid and log file to config_root. self.pid_file = os.path.join(self.config_root, 'sdc.pid') self.log_file = os.path.join(self.config_root, 'sdc.log') if not self._check_for_external_progs(): self.error = True elif not self._init_system_check(): self.error = True elif not self._firewall_check(): self.error = True elif not self._get_machine_id(): self.error = True except: self.error = True
def __init__(self, console_debug=False): """ Gather all the information we need about this node. """ self.console_debug = console_debug if sys.platform == "linux" or sys.platform == "linux2": self.platform = 'linux' elif sys.platform == "darwin": self.platform = 'osx' # OS X elif sys.platform == "win32": self.platform = 'windows' # Gather information about this node. self.config_root = determine_config_root() if not self.config_root: if self.console_debug: print('Error: Unable to determine configuration root.') self.error = True return # Check to see if our configuration path is in a home directory. if os.path.expanduser('~') in self.config_root: _logger.warning('Not running as root, setting configuration path to "{0}"'.format(self.config_root)) _logger.warning('Since we are not running as root, system firewall settings will not be changed.') # Change the default path for pid and log file to config_root. self.pid_file = os.path.join(self.config_root, 'sdc.pid') self.log_file = os.path.join(self.config_root, 'sdc.log') if not self._check_for_external_progs(): self.error = True elif not self._init_system_check(): self.error = True elif not self._firewall_check(): self.error = True elif not self._get_machine_id(): self.error = True