(family, table, name)
| 11 | |
| 12 | |
| 13 | def ipt_chain_exists(family, table, name): |
| 14 | if family == socket.AF_INET6: |
| 15 | cmd = 'ip6tables' |
| 16 | elif family == socket.AF_INET: |
| 17 | cmd = 'iptables' |
| 18 | else: |
| 19 | raise Exception('Unsupported family "%s"' % family_to_string(family)) |
| 20 | argv = [cmd, '-w', '-t', table, '-nL'] |
| 21 | try: |
| 22 | output = ssubprocess.check_output(argv, env=get_env()) |
| 23 | for line in output.decode('ASCII', errors='replace').split('\n'): |
| 24 | if line.startswith('Chain %s ' % name): |
| 25 | return True |
| 26 | except ssubprocess.CalledProcessError as e: |
| 27 | raise Fatal('%r returned %d' % (argv, e.returncode)) |
| 28 | |
| 29 | |
| 30 | def ipt(family, table, *args): |
no test coverage detected