/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:
586
586
        def __init__(self, socket, credentials=None):
587
587
            self._c_object = gnutls.session_t()
588
588
            gnutls_flags = gnutls.CLIENT
589
 
            if gnutls.check_version("3.5.6"):
 
589
            if gnutls.check_version(b"3.5.6"):
590
590
                gnutls_flags |= gnutls.NO_TICKETS
591
591
            if gnutls.has_rawpk:
592
592
                gnutls_flags |= gnutls.ENABLE_RAWPK
794
794
                                                    ctypes.c_size_t)]
795
795
        openpgp_crt_get_fingerprint.restype = _error_code
796
796
 
797
 
    if check_version("3.6.4"):
 
797
    if check_version(b"3.6.4"):
798
798
        certificate_type_get2 = _library.gnutls_certificate_type_get2
799
799
        certificate_type_get2.argtypes = [session_t, ctypes.c_int]
800
800
        certificate_type_get2.restype = _error_code
2287
2287
            approval_required = False
2288
2288
            try:
2289
2289
                if gnutls.has_rawpk:
2290
 
                    fpr = ""
 
2290
                    fpr = b""
2291
2291
                    try:
2292
2292
                        key_id = self.key_id(
2293
2293
                            self.peer_certificate(session))
2297
2297
                    logger.debug("Key ID: %s", key_id)
2298
2298
 
2299
2299
                else:
2300
 
                    key_id = ""
 
2300
                    key_id = b""
2301
2301
                    try:
2302
2302
                        fpr = self.fingerprint(
2303
2303
                            self.peer_certificate(session))
3244
3244
                        for k in ("name", "host"):
3245
3245
                            if isinstance(value[k], bytes):
3246
3246
                                value[k] = value[k].decode("utf-8")
3247
 
                        if not value.has_key("key_id"):
 
3247
                        if "key_id" not in value:
3248
3248
                            value["key_id"] = ""
3249
 
                        elif not value.has_key("fingerprint"):
 
3249
                        elif "fingerprint" not in value:
3250
3250
                            value["fingerprint"] = ""
3251
3251
                    #  old_client_settings
3252
3252
                    # .keys()