"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/firewall/core/io/functions.py" between
firewalld-1.0.1.tar.gz and firewalld-1.0.2.tar.gz

About: firewalld provides a dynamically managed firewall with support for network/firewall zones to define the trust level of network connections or interfaces.

functions.py  (firewalld-1.0.1):functions.py  (firewalld-1.0.2)
skipping to change at line 27 skipping to change at line 27
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import os import os
from firewall import config from firewall import config
from firewall.errors import FirewallError from firewall.errors import FirewallError
from firewall.core.fw_config import FirewallConfig
from firewall.core.io.zone import zone_reader from firewall.core.io.zone import zone_reader
from firewall.core.io.service import service_reader from firewall.core.io.service import service_reader
from firewall.core.io.ipset import ipset_reader from firewall.core.io.ipset import ipset_reader
from firewall.core.io.icmptype import icmptype_reader from firewall.core.io.icmptype import icmptype_reader
from firewall.core.io.helper import helper_reader from firewall.core.io.helper import helper_reader
from firewall.core.io.policy import policy_reader from firewall.core.io.policy import policy_reader
from firewall.core.io.direct import Direct from firewall.core.io.direct import Direct
from firewall.core.io.lockdown_whitelist import LockdownWhitelist from firewall.core.io.lockdown_whitelist import LockdownWhitelist
from firewall.core.io.firewalld_conf import firewalld_conf from firewall.core.io.firewalld_conf import firewalld_conf
def check_config(fw=None): def check_config(fw):
fw_config = FirewallConfig(fw)
readers = { readers = {
"ipset" : (ipset_reader, [config.FIREWALLD_IPSETS, config.ETC_FIREWALLD_ "ipset": {"reader": ipset_reader,
IPSETS]), "add": fw_config.add_ipset,
"helper" : (helper_reader, [config.FIREWALLD_HELPERS, config.ETC_FIREWAL "dirs": [config.FIREWALLD_IPSETS, config.ETC_FIREWALLD_IPSE
LD_HELPERS]), TS],
"icmptype" : (icmptype_reader, [config.FIREWALLD_ICMPTYPES, config.ETC_F },
IREWALLD_ICMPTYPES]), "helper": {"reader": helper_reader,
"service" : (service_reader, [config.FIREWALLD_SERVICES, config.ETC_FIRE "add": fw_config.add_helper,
WALLD_SERVICES]), "dirs": [config.FIREWALLD_HELPERS, config.ETC_FIREWALLD_HEL
"zone" : (zone_reader, [config.FIREWALLD_ZONES, config.ETC_FIREWALLD_ZON PERS],
ES]), },
"policy" : (policy_reader, [config.FIREWALLD_POLICIES, config.ETC_FIREWA "icmptype": {"reader": icmptype_reader,
LLD_POLICIES]), "add": fw_config.add_icmptype,
"dirs": [config.FIREWALLD_ICMPTYPES, config.ETC_FIREWALLD_I
CMPTYPES],
},
"service": {"reader": service_reader,
"add": fw_config.add_service,
"dirs": [config.FIREWALLD_SERVICES, config.ETC_FIREWALLD_SE
RVICES],
},
"zone": {"reader": zone_reader,
"add": fw_config.add_zone,
"dirs": [config.FIREWALLD_ZONES, config.ETC_FIREWALLD_ZONES
],
},
"policy": {"reader": policy_reader,
"add": fw_config.add_policy_object,
"dirs": [config.FIREWALLD_POLICIES, config.ETC_FIREWALLD_PO
LICIES],
},
} }
for reader in readers.keys(): for reader in readers.keys():
for dir in readers[reader][1]: for _dir in readers[reader]["dirs"]:
if not os.path.isdir(dir): if not os.path.isdir(_dir):
continue continue
for file in sorted(os.listdir(dir)): for file in sorted(os.listdir(_dir)):
if file.endswith(".xml"): if file.endswith(".xml"):
try: try:
obj = readers[reader][0](file, dir) obj = readers[reader]["reader"](file, _dir)
if fw and reader in ["zone", "policy"]: if reader in ["zone", "policy"]:
obj.fw_config = fw.config obj.fw_config = fw_config
obj.check_config(obj.export_config()) obj.check_config(obj.export_config())
readers[reader]["add"](obj)
except FirewallError as error: except FirewallError as error:
raise FirewallError(error.code, "'%s': %s" % (file, erro r.msg)) raise FirewallError(error.code, "'%s': %s" % (file, erro r.msg))
except Exception as msg: except Exception as msg:
raise Exception("'%s': %s" % (file, msg)) raise Exception("'%s': %s" % (file, msg))
if os.path.isfile(config.FIREWALLD_DIRECT): if os.path.isfile(config.FIREWALLD_DIRECT):
try: try:
obj = Direct(config.FIREWALLD_DIRECT) obj = Direct(config.FIREWALLD_DIRECT)
obj.read() obj.read()
obj.check_config(obj.export_config()) obj.check_config(obj.export_config())
except FirewallError as error: except FirewallError as error:
 End of changes. 7 change blocks. 
19 lines changed or deleted 40 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)