Skip to content

Commit 28d18dc

Browse files
committed
Merge pull request #776 from exoscale/fix/firewall-sysctl
sysctl: don't modify /etc/sysctl.confTo configure firewall rules, CloudStack modifies `/etc/sysctl.conf` and execute those modifications. This may be harmful for several reasons: 1. `/etc/sysctl.conf` may be managed by some configuration management system. Such a system will constantly restore the previous version. 2. `/etc/sysctl.conf` may contain additional properties that have been changed later by some system administrator (for example, once a firewall has been configured, forwarding may have been activated while it is disabled in `/etc/sysctl.conf`). Executing the file again at a later time may disrupt the system. 3. Entries are added again and again. `/etc/sysctl.conf` will contain the same directives repeated several times. Using a configuration file is not needed as `sysctl` is able to directly modify sysctl values with `-w` flag. Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch> * pr/776: sysctl: don't modify /etc/sysctl.conf Signed-off-by: Wido den Hollander <wido@widodh.nl>
2 parents 1bc8b6b + f2b8f2e commit 28d18dc

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmSecurityGroupModule.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,9 @@ def cleanup_rules():
7575
@staticmethod
7676
def add_fw_framework(bridge_name):
7777
try:
78-
cfo = ConfigFileOps("/etc/sysctl.conf")
79-
cfo.addEntry("net.bridge.bridge-nf-call-arptables", "1")
80-
cfo.addEntry("net.bridge.bridge-nf-call-iptables", "1")
81-
cfo.addEntry("net.bridge.bridge-nf-call-ip6tables", "1")
82-
cfo.save()
83-
84-
execute("sysctl -p /etc/sysctl.conf")
78+
execute("sysctl -w net.bridge.bridge-nf-call-arptables=1")
79+
execute("sysctl -w net.bridge.bridge-nf-call-iptables=1")
80+
execute("sysctl -w net.bridge.bridge-nf-call-ip6tables=1")
8581
except:
8682
logging.debug("failed to turn on bridge netfilter")
8783
return False

scripts/vm/network/security_group.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -960,13 +960,9 @@ def getBrfw(brname):
960960

961961
def addFWFramework(brname):
962962
try:
963-
cfo = configFileOps("/etc/sysctl.conf")
964-
cfo.addEntry("net.bridge.bridge-nf-call-arptables", "1")
965-
cfo.addEntry("net.bridge.bridge-nf-call-iptables", "1")
966-
cfo.addEntry("net.bridge.bridge-nf-call-ip6tables", "1")
967-
cfo.save()
968-
969-
execute("sysctl -p /etc/sysctl.conf")
963+
execute("sysctl -w net.bridge.bridge-nf-call-arptables=1")
964+
execute("sysctl -w net.bridge.bridge-nf-call-iptables=1")
965+
execute("sysctl -w net.bridge.bridge-nf-call-ip6tables=1")
970966
except:
971967
logging.debug("failed to turn on bridge netfilter")
972968
return False

0 commit comments

Comments
 (0)