|
|
36ae71 |
commit 2f435f7ab1e85bf958fd3ad933f6837bdcd5c5c3
|
|
|
36ae71 |
Author: Thomas Woerner <twoerner@redhat.com>
|
|
|
36ae71 |
Date: Tue Feb 11 14:11:07 2014 +0100
|
|
|
36ae71 |
|
|
|
36ae71 |
firewall-cmd: Create and remove permanent zones, services and icmptypes
|
|
|
36ae71 |
|
|
|
36ae71 |
diff --git a/doc/xml/firewall-cmd.xml b/doc/xml/firewall-cmd.xml
|
|
|
36ae71 |
index 41132ff..b1b1a15 100644
|
|
|
36ae71 |
--- a/doc/xml/firewall-cmd.xml
|
|
|
36ae71 |
+++ b/doc/xml/firewall-cmd.xml
|
|
|
36ae71 |
@@ -10,7 +10,7 @@
|
|
|
36ae71 |
|
|
|
36ae71 |
This file is part of firewalld.
|
|
|
36ae71 |
|
|
|
36ae71 |
- Copyright (C) 2010-2013 Red Hat, Inc.
|
|
|
36ae71 |
+ Copyright (C) 2010-2014 Red Hat, Inc.
|
|
|
36ae71 |
Authors:
|
|
|
36ae71 |
Thomas Woerner <twoerner@redhat.com>
|
|
|
36ae71 |
|
|
|
36ae71 |
@@ -271,6 +271,24 @@
|
|
|
36ae71 |
</para>
|
|
|
36ae71 |
</listitem>
|
|
|
36ae71 |
</varlistentry>
|
|
|
36ae71 |
+
|
|
|
36ae71 |
+ <varlistentry>
|
|
|
36ae71 |
+ <term><option>--permanent</option> <option>--new-zone</option>=<replaceable>zone</replaceable></term>
|
|
|
36ae71 |
+ <listitem>
|
|
|
36ae71 |
+ <para>
|
|
|
36ae71 |
+ Add a new permanent zone.
|
|
|
36ae71 |
+ </para>
|
|
|
36ae71 |
+ </listitem>
|
|
|
36ae71 |
+ </varlistentry>
|
|
|
36ae71 |
+
|
|
|
36ae71 |
+ <varlistentry>
|
|
|
36ae71 |
+ <term><option>--permanent</option> <option>--delete-zone</option>=<replaceable>zone</replaceable></term>
|
|
|
36ae71 |
+ <listitem>
|
|
|
36ae71 |
+ <para>
|
|
|
36ae71 |
+ Delete an existing permanent zone.
|
|
|
36ae71 |
+ </para>
|
|
|
36ae71 |
+ </listitem>
|
|
|
36ae71 |
+ </varlistentry>
|
|
|
36ae71 |
</variablelist>
|
|
|
36ae71 |
</refsect2>
|
|
|
36ae71 |
|
|
|
36ae71 |
@@ -698,6 +716,52 @@
|
|
|
36ae71 |
</variablelist>
|
|
|
36ae71 |
</refsect2>
|
|
|
36ae71 |
|
|
|
36ae71 |
+ <refsect2 id="service_options">
|
|
|
36ae71 |
+ <title>Service Options</title>
|
|
|
36ae71 |
+ <variablelist>
|
|
|
36ae71 |
+ <varlistentry>
|
|
|
36ae71 |
+ <term><option>--permanent</option> <option>--new-service</option>=<replaceable>service</replaceable></term>
|
|
|
36ae71 |
+ <listitem>
|
|
|
36ae71 |
+ <para>
|
|
|
36ae71 |
+ Add a new permanent service.
|
|
|
36ae71 |
+ </para>
|
|
|
36ae71 |
+ </listitem>
|
|
|
36ae71 |
+ </varlistentry>
|
|
|
36ae71 |
+
|
|
|
36ae71 |
+ <varlistentry>
|
|
|
36ae71 |
+ <term><option>--permanent</option> <option>--delete-service</option>=<replaceable>service</replaceable></term>
|
|
|
36ae71 |
+ <listitem>
|
|
|
36ae71 |
+ <para>
|
|
|
36ae71 |
+ Delete an existing permanent service.
|
|
|
36ae71 |
+ </para>
|
|
|
36ae71 |
+ </listitem>
|
|
|
36ae71 |
+ </varlistentry>
|
|
|
36ae71 |
+ </variablelist>
|
|
|
36ae71 |
+ </refsect2>
|
|
|
36ae71 |
+
|
|
|
36ae71 |
+ <refsect2 id="icmptype_options">
|
|
|
36ae71 |
+ <title>Internet Control Message Protocol (ICMP) type Options</title>
|
|
|
36ae71 |
+ <variablelist>
|
|
|
36ae71 |
+ <varlistentry>
|
|
|
36ae71 |
+ <term><option>--permanent</option> <option>--new-icmptype</option>=<replaceable>icmptype</replaceable></term>
|
|
|
36ae71 |
+ <listitem>
|
|
|
36ae71 |
+ <para>
|
|
|
36ae71 |
+ Add a new permanent icmptype.
|
|
|
36ae71 |
+ </para>
|
|
|
36ae71 |
+ </listitem>
|
|
|
36ae71 |
+ </varlistentry>
|
|
|
36ae71 |
+
|
|
|
36ae71 |
+ <varlistentry>
|
|
|
36ae71 |
+ <term><option>--permanent</option> <option>--delete-icmptype</option>=<replaceable>icmptype</replaceable></term>
|
|
|
36ae71 |
+ <listitem>
|
|
|
36ae71 |
+ <para>
|
|
|
36ae71 |
+ Delete an existing permanent icmptype.
|
|
|
36ae71 |
+ </para>
|
|
|
36ae71 |
+ </listitem>
|
|
|
36ae71 |
+ </varlistentry>
|
|
|
36ae71 |
+ </variablelist>
|
|
|
36ae71 |
+ </refsect2>
|
|
|
36ae71 |
+
|
|
|
36ae71 |
<refsect2 id="direct_options">
|
|
|
36ae71 |
<title>Direct Options</title>
|
|
|
36ae71 |
<para>
|
|
|
36ae71 |
diff --git a/src/firewall-cmd b/src/firewall-cmd
|
|
|
36ae71 |
index bdb7dbe..3316883 100755
|
|
|
36ae71 |
--- a/src/firewall-cmd
|
|
|
36ae71 |
+++ b/src/firewall-cmd
|
|
|
36ae71 |
@@ -29,7 +29,7 @@ import argparse
|
|
|
36ae71 |
import dbus
|
|
|
36ae71 |
import os
|
|
|
36ae71 |
|
|
|
36ae71 |
-from firewall.client import FirewallClient
|
|
|
36ae71 |
+from firewall.client import *
|
|
|
36ae71 |
from firewall.errors import *
|
|
|
36ae71 |
from firewall.functions import joinArgs
|
|
|
36ae71 |
|
|
|
36ae71 |
@@ -86,9 +86,23 @@ Zone Options
|
|
|
36ae71 |
--get-zone-of-source=<source>[/<mask>]
|
|
|
36ae71 |
Print name of the zone the source[/mask] is bound to [P]
|
|
|
36ae71 |
--list-all-zones List everything added for or enabled in all zones [P]
|
|
|
36ae71 |
+ --new-zone=<zone> Add a new zone [P only]
|
|
|
36ae71 |
+ --delete-zone=<zone> Delete an existing zone [P only]
|
|
|
36ae71 |
--zone=<zone> Use this zone to set or query options, else default zone
|
|
|
36ae71 |
Usable for options maked with [Z]
|
|
|
36ae71 |
|
|
|
36ae71 |
+IcmpType Options
|
|
|
36ae71 |
+ --new-icmptype=<icmptype>
|
|
|
36ae71 |
+ Add a new icmptype [P only]
|
|
|
36ae71 |
+ --delete-icmptype=<icmptype>
|
|
|
36ae71 |
+ Delete and existing icmptype [P only]
|
|
|
36ae71 |
+
|
|
|
36ae71 |
+Service Options
|
|
|
36ae71 |
+ --new-service=<service>
|
|
|
36ae71 |
+ Add a new service [P only]
|
|
|
36ae71 |
+ --delete-service=<service>
|
|
|
36ae71 |
+ Delete and existing service [P only]
|
|
|
36ae71 |
+
|
|
|
36ae71 |
Options to Adapt and Query Zones
|
|
|
36ae71 |
--list-all List everything added for or enabled in a zone [P] [Z]
|
|
|
36ae71 |
--list-services List services added for a zone [P] [Z]
|
|
|
36ae71 |
@@ -373,6 +387,14 @@ parser_group_standalone.add_argument("--get-zone-of-interface", metavar="<iface>
|
|
|
36ae71 |
parser_group_standalone.add_argument("--get-zone-of-source", metavar="<source>")
|
|
|
36ae71 |
parser_group_standalone.add_argument("--list-all-zones", action="store_true")
|
|
|
36ae71 |
|
|
|
36ae71 |
+parser_group_config = parser.add_mutually_exclusive_group()
|
|
|
36ae71 |
+parser_group_config.add_argument("--new-icmptype", metavar="<icmptype>")
|
|
|
36ae71 |
+parser_group_config.add_argument("--delete-icmptype", metavar="<icmptype>")
|
|
|
36ae71 |
+parser_group_config.add_argument("--new-service", metavar="<service>")
|
|
|
36ae71 |
+parser_group_config.add_argument("--delete-service", metavar="<service>")
|
|
|
36ae71 |
+parser_group_config.add_argument("--new-zone", metavar="<zone>")
|
|
|
36ae71 |
+parser_group_config.add_argument("--delete-zone", metavar="<zone>")
|
|
|
36ae71 |
+
|
|
|
36ae71 |
parser_group_lockdown_whitelist = parser.add_mutually_exclusive_group()
|
|
|
36ae71 |
parser_group_lockdown_whitelist.add_argument("--list-lockdown-whitelist-commands", action="store_true")
|
|
|
36ae71 |
parser_group_lockdown_whitelist.add_argument("--add-lockdown-whitelist-command", metavar="<command>")
|
|
|
36ae71 |
@@ -512,6 +534,7 @@ options_zone_adapt_query = \
|
|
|
36ae71 |
a.add_rich_rule or a.remove_rich_rule or a.query_rich_rule or \
|
|
|
36ae71 |
a.add_masquerade or a.remove_masquerade or a.query_masquerade or \
|
|
|
36ae71 |
a.list_services or a.list_ports or a.list_icmp_blocks or \
|
|
|
36ae71 |
+ a.list_forward_ports or a.list_rich_rules or a.list_all or \
|
|
|
36ae71 |
a.list_forward_ports or a.list_rich_rules or a.list_all
|
|
|
36ae71 |
|
|
|
36ae71 |
options_zone_ops = options_zone_interfaces_sources or \
|
|
|
36ae71 |
@@ -521,6 +544,10 @@ options_zone = a.zone or a.timeout or options_zone_ops
|
|
|
36ae71 |
|
|
|
36ae71 |
options_permanent = a.permanent or options_config or a.zone or options_zone_ops
|
|
|
36ae71 |
|
|
|
36ae71 |
+options_permanent_only = a.new_icmptype or a.delete_icmptype or \
|
|
|
36ae71 |
+ a.new_service or a.delete_service or \
|
|
|
36ae71 |
+ a.new_zone or a.delete_zone
|
|
|
36ae71 |
+
|
|
|
36ae71 |
options_direct = a.passthrough or \
|
|
|
36ae71 |
a.add_chain or a.remove_chain or a.query_chain or \
|
|
|
36ae71 |
a.get_chains or a.get_all_chains or \
|
|
|
36ae71 |
@@ -543,15 +570,18 @@ options_list_get = a.help or a.version or a.list_all or a.list_all_zones or \
|
|
|
36ae71 |
# Check various impossible combinations of options
|
|
|
36ae71 |
|
|
|
36ae71 |
if not (options_standalone or options_zone or \
|
|
|
36ae71 |
- options_permanent or options_direct or options_direct_permanent):
|
|
|
36ae71 |
+ options_permanent or options_direct or options_direct_permanent or \
|
|
|
36ae71 |
+ options_permanent_only):
|
|
|
36ae71 |
__fail(parser.format_usage() + "No option specified.")
|
|
|
36ae71 |
|
|
|
36ae71 |
if options_standalone and (options_zone or options_permanent or \
|
|
|
36ae71 |
- options_direct or options_direct_permanent):
|
|
|
36ae71 |
+ options_direct or options_direct_permanent or \
|
|
|
36ae71 |
+ options_permanent_only):
|
|
|
36ae71 |
__fail(parser.format_usage() +
|
|
|
36ae71 |
"Can't use stand-alone options with other options.")
|
|
|
36ae71 |
|
|
|
36ae71 |
-if (options_direct or options_direct_permanent) and (options_zone):
|
|
|
36ae71 |
+if (options_direct or options_direct_permanent or options_permanent_only) and \
|
|
|
36ae71 |
+ (options_zone):
|
|
|
36ae71 |
__fail(parser.format_usage() +
|
|
|
36ae71 |
"Can't use 'direct' options with other options.")
|
|
|
36ae71 |
|
|
|
36ae71 |
@@ -564,6 +594,10 @@ if options_direct_permanent and not a.permanent:
|
|
|
36ae71 |
__fail(parser.format_usage() +
|
|
|
36ae71 |
"Option can be used only with --permanent.")
|
|
|
36ae71 |
|
|
|
36ae71 |
+if options_permanent_only and not a.permanent:
|
|
|
36ae71 |
+ __fail(parser.format_usage() +
|
|
|
36ae71 |
+ "Option can be used only with --permanent.")
|
|
|
36ae71 |
+
|
|
|
36ae71 |
if options_config and options_zone:
|
|
|
36ae71 |
__fail(parser.format_usage() +
|
|
|
36ae71 |
"Wrong usage of --get-zones | --get-services | --get-icmptypes.")
|
|
|
36ae71 |
@@ -625,6 +659,30 @@ if a.permanent:
|
|
|
36ae71 |
l = [fw.config().getIcmpType(i).get_property("name") for i in icmptypes]
|
|
|
36ae71 |
__print_and_exit(" ".join(sorted(l)))
|
|
|
36ae71 |
|
|
|
36ae71 |
+ elif a.new_zone:
|
|
|
36ae71 |
+ config = fw.config()
|
|
|
36ae71 |
+ config.addZone(a.new_zone, FirewallClientZoneSettings())
|
|
|
36ae71 |
+
|
|
|
36ae71 |
+ elif a.delete_zone:
|
|
|
36ae71 |
+ zone = fw.config().getZoneByName(a.delete_zone)
|
|
|
36ae71 |
+ zone.remove()
|
|
|
36ae71 |
+
|
|
|
36ae71 |
+ elif a.new_service:
|
|
|
36ae71 |
+ config = fw.config()
|
|
|
36ae71 |
+ config.addService(a.new_service, FirewallClientServiceSettings())
|
|
|
36ae71 |
+
|
|
|
36ae71 |
+ elif a.delete_service:
|
|
|
36ae71 |
+ service = fw.config().getServiceByName(a.delete_service)
|
|
|
36ae71 |
+ service.remove()
|
|
|
36ae71 |
+
|
|
|
36ae71 |
+ elif a.new_icmptype:
|
|
|
36ae71 |
+ config = fw.config()
|
|
|
36ae71 |
+ config.addIcmpType(a.new_icmptype, FirewallClientIcmpTypeSettings())
|
|
|
36ae71 |
+
|
|
|
36ae71 |
+ elif a.delete_icmptype:
|
|
|
36ae71 |
+ icmptype = fw.config().getIcmpTypeByName(a.delete_icmptype)
|
|
|
36ae71 |
+ icmptype.remove()
|
|
|
36ae71 |
+
|
|
|
36ae71 |
# lockdown whitelist
|
|
|
36ae71 |
|
|
|
36ae71 |
elif options_lockdown_whitelist:
|
|
|
36ae71 |
|
|
|
36ae71 |
commit b270c28945aa0f96e82f2f11a29370a3d57ded03
|
|
|
36ae71 |
Author: Thomas Woerner <twoerner@redhat.com>
|
|
|
36ae71 |
Date: Tue Feb 11 13:00:16 2014 +0100
|
|
|
36ae71 |
|
|
|
36ae71 |
FirewallClientZoneSettings: Set proper default target
|
|
|
36ae71 |
|
|
|
36ae71 |
The default target was set to "" instread of DEFAULT_ZONE_TARGET.
|
|
|
36ae71 |
|
|
|
36ae71 |
diff --git a/src/firewall/client.py b/src/firewall/client.py
|
|
|
36ae71 |
index c557b4f..3168887 100644
|
|
|
36ae71 |
--- a/src/firewall/client.py
|
|
|
36ae71 |
+++ b/src/firewall/client.py
|
|
|
36ae71 |
@@ -30,6 +30,7 @@ import slip.dbus
|
|
|
36ae71 |
|
|
|
36ae71 |
from firewall.config import *
|
|
|
36ae71 |
from firewall.config.dbus import *
|
|
|
36ae71 |
+from firewall.core.base import DEFAULT_ZONE_TARGET
|
|
|
36ae71 |
from firewall.dbus_utils import dbus_to_python
|
|
|
36ae71 |
import dbus
|
|
|
36ae71 |
from decorator import decorator
|
|
|
36ae71 |
@@ -79,8 +80,8 @@ class FirewallClientZoneSettings(object):
|
|
|
36ae71 |
if settings:
|
|
|
36ae71 |
self.settings = settings
|
|
|
36ae71 |
else:
|
|
|
36ae71 |
- self.settings = ["", "", "", False, "", [], [], [], False, [],
|
|
|
36ae71 |
- [], [], []]
|
|
|
36ae71 |
+ self.settings = ["", "", "", False, DEFAULT_ZONE_TARGET, [], [],
|
|
|
36ae71 |
+ [], False, [], [], [], []]
|
|
|
36ae71 |
|
|
|
36ae71 |
@handle_exceptions
|
|
|
36ae71 |
def __repr__(self):
|
|
|
36ae71 |
|
|
|
36ae71 |
commit 89e034763e98024a81b3018cecd3058af9cce84f
|
|
|
36ae71 |
Author: Thomas Woerner <twoerner@redhat.com>
|
|
|
36ae71 |
Date: Tue Feb 11 14:11:28 2014 +0100
|
|
|
36ae71 |
|
|
|
36ae71 |
Fixed creation and deletion of zones, services and icmptypes over D-Bus signals
|
|
|
36ae71 |
|
|
|
36ae71 |
diff --git a/src/firewall-config b/src/firewall-config
|
|
|
36ae71 |
index 363e89c..a00a794 100755
|
|
|
36ae71 |
--- a/src/firewall-config
|
|
|
36ae71 |
+++ b/src/firewall-config
|
|
|
36ae71 |
@@ -1,7 +1,7 @@
|
|
|
36ae71 |
#!/usr/bin/python
|
|
|
36ae71 |
# -*- coding: utf-8 -*-
|
|
|
36ae71 |
#
|
|
|
36ae71 |
-# Copyright (C) 2011-2012 Red Hat, Inc.
|
|
|
36ae71 |
+# Copyright (C) 2011-2014 Red Hat, Inc.
|
|
|
36ae71 |
#
|
|
|
36ae71 |
# Authors:
|
|
|
36ae71 |
# Thomas Woerner <twoerner@redhat.com>
|
|
|
36ae71 |
@@ -912,7 +912,6 @@ class FirewallConfig(object):
|
|
|
36ae71 |
self.fw.connect("direct:rule-removed", self.direct_rule_removed_cb)
|
|
|
36ae71 |
self.fw.connect("config:direct:updated", self.direct_updated_cb)
|
|
|
36ae71 |
|
|
|
36ae71 |
- # TODO: zone-added, zone-removed
|
|
|
36ae71 |
self.fw.connect("config:zone-added", self.conf_zone_added_cb)
|
|
|
36ae71 |
self.fw.connect("config:zone-updated", self.conf_zone_updated_cb)
|
|
|
36ae71 |
self.fw.connect("config:zone-removed", self.conf_zone_removed_cb)
|
|
|
36ae71 |
@@ -1580,7 +1579,7 @@ class FirewallConfig(object):
|
|
|
36ae71 |
def conf_zone_added_cb(self, zone):
|
|
|
36ae71 |
if self.runtime_view:
|
|
|
36ae71 |
return
|
|
|
36ae71 |
- self.load_zones()
|
|
|
36ae71 |
+ self.zoneStore.append([zone, Pango.Weight.NORMAL])
|
|
|
36ae71 |
|
|
|
36ae71 |
def conf_zone_updated_cb(self, zone):
|
|
|
36ae71 |
if self.runtime_view or zone != self.get_active_zone():
|
|
|
36ae71 |
@@ -3500,20 +3499,20 @@ class FirewallConfig(object):
|
|
|
36ae71 |
def conf_service_added_cb(self, service):
|
|
|
36ae71 |
if self.runtime_view:
|
|
|
36ae71 |
return
|
|
|
36ae71 |
- self.serviceStore.append([False, service])
|
|
|
36ae71 |
+ self.serviceConfServiceStore.append([service])
|
|
|
36ae71 |
|
|
|
36ae71 |
- def conf_service_updated_cb(self, zone):
|
|
|
36ae71 |
+ def conf_service_updated_cb(self, service):
|
|
|
36ae71 |
self.onChangeService()
|
|
|
36ae71 |
|
|
|
36ae71 |
def conf_service_removed_cb(self, service):
|
|
|
36ae71 |
if self.runtime_view:
|
|
|
36ae71 |
return
|
|
|
36ae71 |
- iter = self.serviceStore.get_iter_first()
|
|
|
36ae71 |
+ iter = self.serviceConfServiceStore.get_iter_first()
|
|
|
36ae71 |
while iter:
|
|
|
36ae71 |
- if self.serviceStore.get_value(iter, 1) == service:
|
|
|
36ae71 |
- self.serviceStore.remove(iter)
|
|
|
36ae71 |
+ if self.serviceConfServiceStore.get_value(iter, 0) == service:
|
|
|
36ae71 |
+ self.serviceConfServiceStore.remove(iter)
|
|
|
36ae71 |
break
|
|
|
36ae71 |
- iter = self.serviceStore.iter_next(iter)
|
|
|
36ae71 |
+ iter = self.serviceConfServiceStore.iter_next(iter)
|
|
|
36ae71 |
|
|
|
36ae71 |
def onServiceConfAddService(self, *args):
|
|
|
36ae71 |
self.add_edit_service(True)
|
|
|
36ae71 |
@@ -4066,7 +4065,7 @@ class FirewallConfig(object):
|
|
|
36ae71 |
return
|
|
|
36ae71 |
if not self.show_icmp_types:
|
|
|
36ae71 |
return
|
|
|
36ae71 |
- self.icmpStore.append([False, icmp])
|
|
|
36ae71 |
+ self.icmpDialogIcmpStore.append([icmp])
|
|
|
36ae71 |
|
|
|
36ae71 |
def conf_icmp_updated_cb(self, zone):
|
|
|
36ae71 |
if self.runtime_view:
|
|
|
36ae71 |
@@ -4080,12 +4079,12 @@ class FirewallConfig(object):
|
|
|
36ae71 |
return
|
|
|
36ae71 |
if not self.show_icmp_types:
|
|
|
36ae71 |
return
|
|
|
36ae71 |
- iter = self.icmpStore.get_iter_first()
|
|
|
36ae71 |
+ iter = self.icmpDialogIcmpStore.get_iter_first()
|
|
|
36ae71 |
while iter:
|
|
|
36ae71 |
- if self.icmpStore.get_value(iter, 1) == icmp:
|
|
|
36ae71 |
- self.icmpStore.remove(iter)
|
|
|
36ae71 |
+ if self.icmpDialogIcmpStore.get_value(iter, 0) == icmp:
|
|
|
36ae71 |
+ self.icmpDialogIcmpStore.remove(iter)
|
|
|
36ae71 |
break
|
|
|
36ae71 |
- iter = self.icmpStore.iter_next(iter)
|
|
|
36ae71 |
+ iter = self.icmpDialogIcmpStore.iter_next(iter)
|
|
|
36ae71 |
|
|
|
36ae71 |
def lockdown_check_cb(self, *args):
|
|
|
36ae71 |
if self.fw.queryLockdown():
|