Skip to content

Segmentation fault during commit after insert rule #232

@codecat555

Description

@codecat555

Hi,

I've been hitting an error and segmentation fault which has been hard to nail down. I finally boiled it down to a minimal test case. Would you please take a look?

Here's the code -

import sys
import iptc

if sys.argv[0] == 4:
    table = iptc.Table(iptc.Table.FILTER, autocommit=False)
else:
    table = iptc.Table6(iptc.Table6.FILTER, autocommit=False)

chain = iptc.Chain(table, 'INPUT')

table.refresh()

rule = iptc.Rule()
rule.protocol = 'ip'
rule.create_target('ACCEPT')

chain.insert_rule(rule, 1)

table.commit()

Here's how I am running it -

[root@your ~]# cat iptables.minimal
iptables -P INPUT ACCEPT
iptables -F
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -L -v --line-numbers
[root@cmcrae-6 ~]# bash iptables.minimal; python showit4.py 4
Chain INPUT (policy DROP 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination
1        0     0 ACCEPT     all  --  lo     any     anywhere             anywhere
2        1    52 ACCEPT     all  --  any    any     anywhere             anywhere             state RELATED,ESTABLISHED
3        0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:ssh
4        0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:http
5        0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:https
6        0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:ftp

Chain FORWARD (policy DROP 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination

Chain RH-Firewall-1-INPUT (0 references)
num   pkts bytes target     prot opt in     out     source               destination
Segmentation fault
[root@cmcrae-6 ~]#

System -

CentOS Linux release 7.2.1511 (Core)
iptables-services-1.4.21-16.el7.x86_64
iptables-1.4.21-16.el7.x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions