Skip to content

Commit e49a59d

Browse files
committed
bug 8314 - Iptables is being appended with same set of rules again and again on each re-installation of the management
server: master branch status 8314: resolved fixed
1 parent f36265c commit e49a59d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

client/bindir/cloud-setup-management.in

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ chkconfig = Command("chkconfig")
134134
updatercd = Command("update-rc.d")
135135
ufw = Command("ufw")
136136
iptables = Command("iptables")
137+
iptables_save = Command("iptables-save")
137138
augtool = Command("augtool")
138139
kvmok = Command("kvm-ok")
139140
ifconfig = Command("ifconfig")
@@ -234,7 +235,13 @@ if Fedora or CentOS:
234235
if ":on" in o.stdout and os.path.exists("/etc/sysconfig/iptables"):
235236
stderr("Setting up firewall rules to permit traffic to CloudStack services")
236237
service.iptables.start() ; print o.stdout + o.stderr
237-
for p in ports: iptables("-I","INPUT","1","-p","tcp","--dport",p,"-j","ACCEPT")
238+
o = iptables_save()
239+
for p in ports:
240+
r = "INPUT -p tcp -m tcp --dport %s -j ACCEPT" % p
241+
if r in o.stdout:
242+
continue
243+
iptables("-I","INPUT","1","-p","tcp","--dport",p,"-j","ACCEPT")
244+
238245
o = service.iptables.save() ; print o.stdout + o.stderr
239246
else:
240247
stderr("No need to set up iptables as the service is unconfigured or not set to start up at boot")

0 commit comments

Comments
 (0)