/mandos/release

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

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2019-08-30 21:10:13 UTC
  • mto: This revision was merged to the branch mainline in revision 392.
  • Revision ID: teddy@recompile.se-20190830211013-7bt0qseq97dpt7oy
Update Python 3 compatibility

* mandos (rfc3339_duration_to_delta): Change doctest string to not
                                      depend on exact repr() string
                                      representation of values and
                                      instead do value comparisons.
  (string_to_delta): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python3 -bI
 
1
#!/usr/bin/python
2
2
# -*- mode: python; after-save-hook: (lambda () (let ((command (if (fboundp 'file-local-name) (file-local-name (buffer-file-name)) (or (file-remote-p (buffer-file-name) 'localname) (buffer-file-name))))) (if (= (progn (if (get-buffer "*Test*") (kill-buffer "*Test*")) (process-file-shell-command (format "%s --check" (shell-quote-argument command)) nil "*Test*")) 0) (let ((w (get-buffer-window "*Test*"))) (if w (delete-window w))) (progn (with-current-buffer "*Test*" (compilation-mode)) (display-buffer "*Test*" '(display-buffer-in-side-window)))))); coding: utf-8 -*-
3
3
#
4
4
# Mandos server - give out binary blobs to connecting clients.
91
91
 
92
92
if sys.version_info.major == 2:
93
93
    __metaclass__ = type
94
 
    str = unicode
95
94
 
96
95
# Show warnings by default
97
96
if not sys.warnoptions:
123
122
            # No value found
124
123
            SO_BINDTODEVICE = None
125
124
 
 
125
if sys.version_info.major == 2:
 
126
    str = unicode
 
127
 
126
128
if sys.version_info < (3, 2):
127
129
    configparser.Configparser = configparser.SafeConfigParser
128
130
 
129
 
version = "1.8.9"
 
131
version = "1.8.8"
130
132
stored_state_file = "clients.pickle"
131
133
 
132
134
logger = logging.getLogger()
201
203
            output = subprocess.check_output(["gpgconf"])
202
204
            for line in output.splitlines():
203
205
                name, text, path = line.split(b":")
204
 
                if name == b"gpg":
 
206
                if name == "gpg":
205
207
                    self.gpg = path
206
208
                    break
207
209
        except OSError as e:
212
214
                          '--force-mdc',
213
215
                          '--quiet']
214
216
        # Only GPG version 1 has the --no-use-agent option.
215
 
        if self.gpg == b"gpg" or self.gpg.endswith(b"/gpg"):
 
217
        if self.gpg == "gpg" or self.gpg.endswith("/gpg"):
216
218
            self.gnupgargs.append("--no-use-agent")
217
219
 
218
220
    def __enter__(self):
1051
1053
        # Read return code from connection (see call_pipe)
1052
1054
        returncode = connection.recv()
1053
1055
        connection.close()
1054
 
        if self.checker is not None:
1055
 
            self.checker.join()
 
1056
        self.checker.join()
1056
1057
        self.checker_callback_tag = None
1057
1058
        self.checker = None
1058
1059
 
1411
1412
                raise ValueError("Byte arrays not supported for non-"
1412
1413
                                 "'ay' signature {!r}"
1413
1414
                                 .format(prop._dbus_signature))
1414
 
            value = dbus.ByteArray(bytes(value))
 
1415
            value = dbus.ByteArray(b''.join(chr(byte)
 
1416
                                            for byte in value))
1415
1417
        prop(value)
1416
1418
 
1417
1419
    @dbus.service.method(dbus.PROPERTIES_IFACE,
3249
3251
                             if isinstance(s, bytes)
3250
3252
                             else s) for s in
3251
3253
                            value["client_structure"]]
3252
 
                        # .name, .host, and .checker_command
3253
 
                        for k in ("name", "host", "checker_command"):
 
3254
                        # .name & .host
 
3255
                        for k in ("name", "host"):
3254
3256
                            if isinstance(value[k], bytes):
3255
3257
                                value[k] = value[k].decode("utf-8")
3256
3258
                        if "key_id" not in value:
3266
3268
                        for key, value in
3267
3269
                        bytes_old_client_settings.items()}
3268
3270
                    del bytes_old_client_settings
3269
 
                    # .host and .checker_command
 
3271
                    # .host
3270
3272
                    for value in old_client_settings.values():
3271
 
                        for attribute in ("host", "checker_command"):
3272
 
                            if isinstance(value[attribute], bytes):
3273
 
                                value[attribute] = (value[attribute]
3274
 
                                                    .decode("utf-8"))
 
3273
                        if isinstance(value["host"], bytes):
 
3274
                            value["host"] = (value["host"]
 
3275
                                             .decode("utf-8"))
3275
3276
            os.remove(stored_state_path)
3276
3277
        except IOError as e:
3277
3278
            if e.errno == errno.ENOENT: