~jdstrand/ufw/ufw-xenial

« back to all changes in this revision

Viewing changes to src/backend_iptables.py

  • Committer: Jamie Strandboge
  • Date: 2012-07-06 19:29:50 UTC
  • Revision ID: jamie@canonical.com-20120706192950-1whf5yyzv2v2xc6c
Release 0.32-0ubuntu1

* New upstream release featuring Python 3 port (LP: #1001657)
* debian/control:
  - clean up Depends and Build-Depends
  - Build-Depends on python3
  - add python-ufw for installing python2 modules
  - add X-Python3-Version: >= 3.2
  - update Vcs-Bzr
* add debian/python-ufw.install
* debian/rules:
  - use --install-layout=deb
  - adjust PYTHON to use python3
  - adjust PYVERS to use py3versions
  - add PYTHON2
  - run tests for both PYTHON and PYTHON2
  - run setup.py with both PYTHON and PYTHON2
  - use dh_python3 for ufw
  - use dh_python2 for python-ufw
* debian/ufw.lintian-overrides
  - remove old unneeded override
  - add postrm-does-not-call-updaterc.d-for-init.d-script since Ubuntu's
    debhelper adds code to postinst that does nothing on Ubuntu, but doesn't
    add the corresponding code to postrm
* New upstream release (Closes: 663677, Closes: 625681)
* debian/control: update to standards 3.9.3
* convert to source format 3.0 (quilt)
* 0001-optimize-boot.patch: only read in /etc/ufw/ufw.conf when disabled
* debian/rules: adjust to only install the application profiles when not
  Ubuntu
* debian/po/da.po: add Danish translation of debconf templates. Thanks to
  Joe Dalton (Closes: 666557)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
'''backend_iptables.py: iptables backend for ufw'''
2
2
#
3
 
# Copyright 2008-2011 Canonical Ltd.
 
3
# Copyright 2008-2012 Canonical Ltd.
4
4
#
5
5
#    This program is free software: you can redistribute it and/or modify
6
6
#    it under the terms of the GNU General Public License version 3,
277
277
                show_proto = False
278
278
                tupl = r.get_app_tuple()
279
279
 
280
 
                if app_rules.has_key(tupl):
 
280
                if tupl in app_rules:
281
281
                    debug("Skipping found tuple '%s'" % (tupl))
282
282
                    continue
283
283
                else:
392
392
            str_to = _("To")
393
393
            str_from = _("From")
394
394
            str_action = _("Action")
395
 
            rules_header = "%-26s %-12s%s\n" % \
396
 
                            (str_to.decode("utf-8", 'ignore'), \
397
 
                             str_action.decode("utf-8", 'ignore'), \
398
 
                             str_from.decode("utf-8", 'ignore'))
 
395
            rules_header_fmt = "%-26s %-12s%s\n"
 
396
 
 
397
            rules_header = rules_header_fmt % (str_to, str_action, str_from)
399
398
            if show_count:
400
399
                rules_header += "     "
401
 
            rules_header += "%-26s %-12s%s\n" % \
402
 
                            ("-" * len(str_to.decode("utf-8", 'ignore')), \
403
 
                             "-" * len(str_action.decode("utf-8", 'ignore')), \
404
 
                             "-" * len(str_from.decode("utf-8", 'ignore')))
405
 
            full_str += rules_header.encode('utf-8', 'ignore')
 
400
            rules_header += rules_header_fmt % \
 
401
                            ("-" * len(str_to), \
 
402
                             "-" * len(str_action), \
 
403
                             "-" * len(str_from))
 
404
 
 
405
            full_str += rules_header
 
406
 
406
407
            if s != "":
407
408
                full_str += s
408
409
            if s != "" and str_out != "":
446
447
                debug(out)
447
448
                raise UFWError(err_msg + " ufw-init")
448
449
 
449
 
            if not self.defaults.has_key('loglevel') or \
450
 
               self.defaults['loglevel'] not in self.loglevels.keys():
 
450
            if 'loglevel' not in self.defaults or \
 
451
               self.defaults['loglevel'] not in list(self.loglevels.keys()):
451
452
                # Add the loglevel if not valid
452
453
                try:
453
454
                    self.set_loglevel("low")
1125
1126
        '''Get rules for specified logging level'''
1126
1127
        rules_t = []
1127
1128
 
1128
 
        if level not in self.loglevels.keys():
 
1129
        if level not in list(self.loglevels.keys()):
1129
1130
            err_msg = _("Invalid log level '%s'") % (level)
1130
1131
            raise UFWError(err_msg)
1131
1132