Exemplo n.º 1
0
def check_config_dependencies(config, toolbox):
    """ Validates dependencies between config options within an [radius_server_auto] section

    Args:
        config (ConfigDict): The config object to validate dependencies on

    Returns:
        list of ConfigResults

    """
    problems = base.check_radius_secret_radius_ip_balance(config)
    problems += base.check_basic_server_config_dependencies(config, toolbox)
    return problems
def _check_config_dependencies(config, toolbox):
    dependency_problems = base.check_basic_server_config_dependencies(config, toolbox)

    # ssl_port needs ssl_key_path and ssl_cert_path to work
    if toolbox.test_config_has_value(config, 'ssl_port'):
        for key in ('ssl_key_path', 'ssl_cert_path'):
            if not toolbox.test_config_has_value(config, key):
                dependency_problems.append(config_results.MissingKey(level=config_results.ConfigResultLevel.Warning, key=key))

    # ssl_key_path and ssl_cert_path are both or neither
    if toolbox.test_config_has_value(config, 'ssl_key_path') \
            and not toolbox.test_config_has_value(config, 'ssl_cert_path'):
        dependency_problems.append(config_results.MissingKey(key='ssl_cert_path'))

    if toolbox.test_config_has_value(config, 'ssl_cert_path') \
            and not toolbox.test_config_has_value(config, 'ssl_key_path'):
        dependency_problems.append(config_results.MissingKey(key='ssl_key_path'))

    # allow_unlimited_binds = true means exempt_primary_bind must be false
    if toolbox.test_is_bool(config, 'allow_unlimited_binds') and config.get_bool('allow_unlimited_binds', False) \
            and toolbox.test_is_bool(config, 'exempt_primary_bind') and config.get_bool('exempt_primary_bind', False):
        dependency_problems.append(config_results.IncompatibleKeys(key1='allow_unlimited_binds', key2='exempt_primary_bind'))

    return dependency_problems
def check_config_dependencies(config, toolbox):
    problems = base.check_radius_secret_radius_ip_balance(config)
    problems += base.check_basic_server_config_dependencies(config, toolbox)
    return problems