Below is the file 'client/plugins/iptables.py' from this revision. You can also download the file.


import os
from phonehome import urgency
from config import install_path

def run():
    iptables_prog = "/sbin/iptables"
    if not os.access(iptables_prog, os.X_OK):
	return [(urgency['info'], 'iptables not available (not installed?)')]

    # for now, just check that there are rules
    iptables_command = '%s -L INPUT -n' % iptables_prog

    if os.access(os.path.join(install_path, 'etc', 'no_iptables_ok'), os.R_OK):
        return [(urgency['info'], 'skipped iptables check, no_firewall_ok found.')]

    fd = os.popen(iptables_command)
    result = fd.read()
    fd.close()

    line_count = len(result.split('\n'))
    if line_count > 3:
	return []
    else:
	return [(urgency['warning'], 'no iptables rules in chain "INPUT"')]