Skip to content

Commit

Permalink
qubes-firewall: call firewall-user-script at service startup
Browse files Browse the repository at this point in the history
Call it just after creating base chains in iptables/nftables. This allow
the user to modify how those rules are plugged in, add custom rules at
beginning/end etc.

Fixes QubesOS/qubes-issues#3260
  • Loading branch information
marmarek committed Feb 5, 2018
1 parent c6cdbf8 commit 6c33652
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions qubesagent/firewall.py
Expand Up @@ -62,6 +62,13 @@ def apply_rules(self, source_addr, rules):
'''Apply rules in given source address'''
raise NotImplementedError

def run_user_script(self):
'''Run user script in /rw/config'''
user_script_path = '/rw/config/qubes-firewall-user-script'
if os.path.isfile(user_script_path) and \
os.access(user_script_path, os.X_OK):
subprocess.call([user_script_path])

def read_rules(self, target):
'''Read rules from QubesDB and return them as a list of dicts'''
entries = self.qdb.multiread('/qubes-firewall/{}/'.format(target))
Expand Down Expand Up @@ -133,6 +140,7 @@ def dns_addresses(family=None):
def main(self):
self.terminate_requested = False
self.init()
self.run_user_script()
# initial load
for source_addr in self.list_targets():
self.handle_addr(source_addr)
Expand Down

0 comments on commit 6c33652

Please sign in to comment.