/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2019-07-28 14:39:47 UTC
  • Revision ID: teddy@recompile.se-20190728143947-gfv94wjdal3rgk6b
Update Python 3 compatibility

* mandos (gnutls.ClientSession.__init__): Use byte string argument to
                                          check_version() instead of a
                                          unicode string.
  (gnutls): - '' -
  (ClientHandler.handle): Change default values for "fpr" and "key_id"
                          to be byte strings instead of unicode
                          strings.
  (main): Use "key in dict" instead of "dict.has_key(key)".
* mandos-ctl: Fix Emacs test runner to use "--check" instead of
              "--test".
  (rfc3339_duration_to_delta): Change doctest string to not depend on
                               exact repr() string representation of
                               values and instead do value
                               comparisons.
  (parse_pre_1_6_1_interval): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
 
81
81
import dbus
82
82
import dbus.service
83
 
import gi
84
83
from gi.repository import GLib
85
84
from dbus.mainloop.glib import DBusGMainLoop
86
85
import ctypes
116
115
if sys.version_info.major == 2:
117
116
    str = unicode
118
117
 
119
 
if sys.version_info < (3, 2):
120
 
    configparser.Configparser = configparser.SafeConfigParser
121
 
 
122
 
version = "1.8.6"
 
118
version = "1.8.4"
123
119
stored_state_file = "clients.pickle"
124
120
 
125
121
logger = logging.getLogger()
825
821
    approved:   bool(); 'None' if not yet approved/disapproved
826
822
    approval_delay: datetime.timedelta(); Time to wait for approval
827
823
    approval_duration: datetime.timedelta(); Duration of one approval
828
 
    checker: multiprocessing.Process(); a running checker process used
829
 
             to see if the client lives. 'None' if no process is
830
 
             running.
 
824
    checker:    subprocess.Popen(); a running checker process used
 
825
                                    to see if the client lives.
 
826
                                    'None' if no process is running.
831
827
    checker_callback_tag: a GLib event source tag, or None
832
828
    checker_command: string; External command which is run to check
833
829
                     if client lives.  %() expansions are done at
1040
1036
    def checker_callback(self, source, condition, connection,
1041
1037
                         command):
1042
1038
        """The checker has completed, so take appropriate actions."""
 
1039
        self.checker_callback_tag = None
 
1040
        self.checker = None
1043
1041
        # Read return code from connection (see call_pipe)
1044
1042
        returncode = connection.recv()
1045
1043
        connection.close()
1046
 
        self.checker.join()
1047
 
        self.checker_callback_tag = None
1048
 
        self.checker = None
1049
1044
 
1050
1045
        if returncode >= 0:
1051
1046
            self.last_checker_status = returncode
3002
2997
    del priority
3003
2998
 
3004
2999
    # Parse config file for server-global settings
3005
 
    server_config = configparser.ConfigParser(server_defaults)
 
3000
    server_config = configparser.SafeConfigParser(server_defaults)
3006
3001
    del server_defaults
3007
3002
    server_config.read(os.path.join(options.configdir, "mandos.conf"))
3008
 
    # Convert the ConfigParser object to a dict
 
3003
    # Convert the SafeConfigParser object to a dict
3009
3004
    server_settings = server_config.defaults()
3010
3005
    # Use the appropriate methods on the non-string config options
3011
3006
    for option in ("debug", "use_dbus", "use_ipv6", "restore",
3083
3078
                                  server_settings["servicename"])))
3084
3079
 
3085
3080
    # Parse config file with clients
3086
 
    client_config = configparser.ConfigParser(Client.client_defaults)
 
3081
    client_config = configparser.SafeConfigParser(Client
 
3082
                                                  .client_defaults)
3087
3083
    client_config.read(os.path.join(server_settings["configdir"],
3088
3084
                                    "clients.conf"))
3089
3085
 
3160
3156
        # Close all input and output, do double fork, etc.
3161
3157
        daemon()
3162
3158
 
3163
 
    if gi.version_info < (3, 10, 2):
3164
 
        # multiprocessing will use threads, so before we use GLib we
3165
 
        # need to inform GLib that threads will be used.
3166
 
        GLib.threads_init()
 
3159
    # multiprocessing will use threads, so before we use GLib we need
 
3160
    # to inform GLib that threads will be used.
 
3161
    GLib.threads_init()
3167
3162
 
3168
3163
    global main_loop
3169
3164
    # From the Avahi example code