def _parse_ssl_version(content):
    _, assignment, _ = lib.parse_sysconfig_spamassassin(content)
    if re.search(r'(?<![\w-])--ssl-version(=|\s+)sslv3(?![\w-])', assignment):
        return 'sslv3'
    if re.search(r'(?<![\w-])--ssl-version(=|\s+)tlsv1(?![\w-])', assignment):
        return 'tlsv1'
    return None
def _rewrite_spamd_option(content, ops):
    pre_assignment, assignment, post_assignment = \
        utils.parse_sysconfig_spamassassin(content)
    if assignment:
        value = re.sub(r'^\s*' + utils.SYSCONFIG_VARIABLE + r'\s*=(.*)$',
                       r'\1', assignment)
        for op in ops:
            value = op(value)
        assignment = utils.SYSCONFIG_VARIABLE + '=' + value
    res = '\n'.join(filter(None, (pre_assignment, assignment, post_assignment)))
    if res and not res.endswith('\n'):
        res += '\n'
    return res
예제 #3
0
def test_parse_sysconfig_spamassassin_empty():
    content = ''
    pre, assignment, post = lib.parse_sysconfig_spamassassin(content)
    assert pre == ''
    assert assignment == ''
    assert post == ''
예제 #4
0
def test_parse_sysconfig_spamassassin_begins_with_assignment():
    content = 'SPAMDOPTIONS="foo"\n# bar\n'
    pre, assignment, post = lib.parse_sysconfig_spamassassin(content)
    assert pre == ''
    assert assignment == 'SPAMDOPTIONS="foo"'
    assert post == '# bar\n'
예제 #5
0
def test_parse_sysconfig_spamassassin_no_assignment():
    content = '# foo\n'
    pre, assignment, post = lib.parse_sysconfig_spamassassin(content)
    assert pre == '# foo\n'
    assert assignment == ''
    assert post == ''