Beispiel #1
0
def test(username=config_user.USER, password=config_user.PASSWORD):
    try:
        imap = imaplib.IMAP4('localhost', 143)
        imap.login(username, password)
        show_ok('Cyrus')
    except socket.error, e:
        show_ko('Cyrus', 'Try: systemctl restart cyrus-imapd.service', e)
Beispiel #2
0
def test(server='127.0.0.1', port=12345):
    try:
        s = socket.socket()
        s.connect((server, port))
        show_ok('OpenDMARC')
    except socket.error, e:
        show_ko('OpenDMARC', 'Try: systemctl restart opendmarc.service', e)
Beispiel #3
0
def test(ntp_server='127.0.0.1'):
    try:
        c = ntplib.NTPClient()
        response = c.request(ntp_server)
        if DEBUG:
            print(ctime(response.tx_time))
        show_ok('Ntpd')
    except ntplib.NTPException, e:
        show_ko('Ntpd', 'Try: systemctl restart ntp.service', e)
Beispiel #4
0
def test(socket='/var/run/clamav/clamd.ctl'):
    try:
        client = clamd.ClamdUnixSocket(socket)
        client.ping()
        show_ok('ClamavDeamon')
    except clamd.ConnectionError, e:
        show_ko('ClamavDeamon',
                'Try: systemctl restart clamav-daemon.socket',
                e)
Beispiel #5
0
def test(server='127.0.0.1', port='80'):
    try:
        r = requests.get('http://{}:{}/'.format(server, port))
        if r.status_code == 200:
            show_ok('Nginx')
        else:
            show_ko('Nginx', 'Try: systemctl restart nginx.service')
    except requests.exceptions.ConnectionError, e:
        show_ko('Nginx', 'Try: systemctl restart nginx.service', e)
Beispiel #6
0
def test(uid=UID, password=PASSWORD, server='ldap://localhost'):
    try:
        LDAP = ldap.initialize(server)
        LDAP.bind_s(uid, password)
        show_ok('LDAP')
    except ldap.INVALID_CREDENTIALS:
        show_ko('LDAP', 'Your username or password is incorrect.')
    except ldap.LDAPError, e:
        if type(e.message) == dict and 'desc' in e.message:
            error = e.message['desc']
        else:
            error = e
        show_ko('LDAP', 'Try: systemctl restart slapd.service', error)
Beispiel #7
0
def test(username=config_user.USER,
         password=config_user.PASSWORD,
         server='localhost',
         port=587):
    try:
        smtp = smtplib.SMTP()
        smtp.connect(server, port)
        smtp.ehlo()
        smtp.starttls()
        smtp.ehlo()
        smtp.login(username, password)
        show_ok('Postfix')
    except smtplib.SMTPResponseException, e:
        show_ko('Postfix', 'Try: systemctl restart postfix.service', e)
Beispiel #8
0
def test(test_mode=False):
    command = 'nslcd --check'
    process_exec = subprocess.Popen(command,
                                    shell=True,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)
    process_exec.wait()
    if test_mode:
        returncode = 1
    else:
        returncode = process_exec.returncode

    if returncode == 0:
        show_ok('nslcd')
    else:
        show_ko('nslcd', 'Try: systemctl restart nslcd.service')
Beispiel #9
0
def test(base='/var/www/www', script='/ping.php', server='127.0.0.1:9000'):
    command = 'SCRIPT_NAME={script} SCRIPT_FILENAME={base}{script} REQUEST_METHOD=GET cgi-fcgi -bind -connect {server}'.format(
        base=base, script=script, server=server)
    if DEBUG:
        print(command)
    process_exec = subprocess.Popen(command,
                                    shell=True,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)
    process_exec.wait()
    returncode = process_exec.returncode
    if DEBUG:
        print(returncode)

    if returncode == 0:
        show_ok('php5-fpm')
    else:
        error = '\n'.join(process_exec.stderr.readlines())
        show_ko('php5-fpm', 'Try: systemctl restart php5-fpm.service', error)
Beispiel #10
0
def test(username=config_user.USER, password=config_user.PASSWORD,
         mux='/var/run/saslauthd/mux'):
    cmd = '/usr/sbin/testsaslauthd -u {} -p {} -f {}'.format(username,
                                                             password,
                                                             mux)
    p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
                         close_fds=True)
    p.wait()
    if p.returncode == 0:
        show_ok('SASL')
    else:
        hint = []
        error = []
        error.append('Failed with mux: {}'.format(mux))
        for line in p.stdout.readlines():
            error.append(line)
        if mux == '/var/run/saslauthd/mux':
            hint.append('Try: ln -s /var/spool/postfix/var/run/saslauthd /var/run/saslauthd')
        hint.append('Try: systemctl restart saslauthd.service')
        show_ko('SASL',
                '\n'.join(hint),
                '\n'.join(error))
Beispiel #11
0
def test(socket_path='/var/spool/postfix/spamass/spamass.sock'):
    if os.path.exists(socket_path):
        show_ok('Spamassassin-milter')
    else:
        show_ko('Spamassassin-milter',
                'Try: systemctl restart spamass-milter.service')
Beispiel #12
0
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import imaplib
import socket

import config_user

from common import show_ok, show_ko


def test(username=config_user.USER, password=config_user.PASSWORD):
    try:
        imap = imaplib.IMAP4('localhost', 143)
        imap.login(username, password)
        show_ok('Cyrus')
    except socket.error, e:
        show_ko('Cyrus', 'Try: systemctl restart cyrus-imapd.service', e)
    except imaplib.IMAP4.error, e:
        show_ko('Cyrus', 'Try: systemctl restart cyrus-imapd.service', e)


if __name__ == '__main__':
    test()
    print('=' * 80)
    test(password=config_user.BAD_PASSWORD)
Beispiel #13
0
def test(socket_path='/var/spool/postfix/clamav/clamav-milter.ctl'):
    if os.path.exists(socket_path):
        show_ok('Clamav-milter')
    else:
        show_ko('Clamav-milter',
                'Try: systemctl restart clamav-milter.service')
Beispiel #14
0
from common import show_ok, show_ko


def test(username=config_user.USER,
         password=config_user.PASSWORD,
         server='localhost',
         port=587):
    try:
        smtp = smtplib.SMTP()
        smtp.connect(server, port)
        smtp.ehlo()
        smtp.starttls()
        smtp.ehlo()
        smtp.login(username, password)
        show_ok('Postfix')
    except smtplib.SMTPResponseException, e:
        show_ko('Postfix', 'Try: systemctl restart postfix.service', e)
    except smtplib.SMTPAuthenticationError, e:
        show_ko('Postfix', 'Try: systemctl restart postfix.service', e)
    except socket.error, e:
        show_ko('Postfix', 'Try: systemctl restart postfix.service', e)


if __name__ == '__main__':
    test()
    print('=' * 80)
    test(password=config_user.BAD_PASSWORD)
    print('=' * 80)
    test(port=588)