/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: 2020-11-30 18:08:38 UTC
  • mfrom: (237.7.775 trunk)
  • Revision ID: teddy@recompile.se-20201130180838-g7c6mhbvenlitnce
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
524
524
class AvahiServiceToSyslog(AvahiService):
525
525
    def rename(self, *args, **kwargs):
526
526
        """Add the new name to the syslog messages"""
527
 
        ret = super(AvahiServiceToSyslog, self).rename(*args, **kwargs)
 
527
        ret = super(AvahiServiceToSyslog, self).rename(*args,
 
528
                                                       **kwargs)
528
529
        syslogger.setFormatter(logging.Formatter(
529
530
            'Mandos ({}) [%(process)d]: %(levelname)s: %(message)s'
530
531
            .format(self.name)))
774
775
 
775
776
        x509_crt_fmt_t = ctypes.c_int
776
777
 
777
 
        # All the function declarations below are from gnutls/abstract.h
 
778
        # All the function declarations below are from
 
779
        # gnutls/abstract.h
778
780
        pubkey_init = _library.gnutls_pubkey_init
779
781
        pubkey_init.argtypes = [ctypes.POINTER(pubkey_t)]
780
782
        pubkey_init.restype = _error_code
794
796
        pubkey_deinit.argtypes = [pubkey_t]
795
797
        pubkey_deinit.restype = None
796
798
    else:
797
 
        # All the function declarations below are from gnutls/openpgp.h
 
799
        # All the function declarations below are from
 
800
        # gnutls/openpgp.h
798
801
 
799
802
        openpgp_crt_init = _library.gnutls_openpgp_crt_init
800
803
        openpgp_crt_init.argtypes = [ctypes.POINTER(openpgp_crt_t)]
806
809
                                       openpgp_crt_fmt_t]
807
810
        openpgp_crt_import.restype = _error_code
808
811
 
809
 
        openpgp_crt_verify_self = _library.gnutls_openpgp_crt_verify_self
810
 
        openpgp_crt_verify_self.argtypes = [openpgp_crt_t, ctypes.c_uint,
811
 
                                            ctypes.POINTER(ctypes.c_uint)]
 
812
        openpgp_crt_verify_self = \
 
813
            _library.gnutls_openpgp_crt_verify_self
 
814
        openpgp_crt_verify_self.argtypes = [
 
815
            openpgp_crt_t,
 
816
            ctypes.c_uint,
 
817
            ctypes.POINTER(ctypes.c_uint),
 
818
        ]
812
819
        openpgp_crt_verify_self.restype = _error_code
813
820
 
814
821
        openpgp_crt_deinit = _library.gnutls_openpgp_crt_deinit
2468
2475
        buf = ctypes.create_string_buffer(32)
2469
2476
        buf_len = ctypes.c_size_t(len(buf))
2470
2477
        # Get the key ID from the raw public key into the buffer
2471
 
        gnutls.pubkey_get_key_id(pubkey,
2472
 
                                 gnutls.KEYID_USE_SHA256,
2473
 
                                 ctypes.cast(ctypes.byref(buf),
2474
 
                                             ctypes.POINTER(ctypes.c_ubyte)),
2475
 
                                 ctypes.byref(buf_len))
 
2478
        gnutls.pubkey_get_key_id(
 
2479
            pubkey,
 
2480
            gnutls.KEYID_USE_SHA256,
 
2481
            ctypes.cast(ctypes.byref(buf),
 
2482
                        ctypes.POINTER(ctypes.c_ubyte)),
 
2483
            ctypes.byref(buf_len))
2476
2484
        # Deinit the certificate
2477
2485
        gnutls.pubkey_deinit(pubkey)
2478
2486
 
2723
2731
            address = request[3]
2724
2732
 
2725
2733
            for c in self.clients.values():
2726
 
                if key_id == "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855":
 
2734
                if key_id == ("E3B0C44298FC1C149AFBF4C8996FB924"
 
2735
                              "27AE41E4649B934CA495991B7852B855"):
2727
2736
                    continue
2728
2737
                if key_id and c.key_id == key_id:
2729
2738
                    client = c
2781
2790
def rfc3339_duration_to_delta(duration):
2782
2791
    """Parse an RFC 3339 "duration" and return a datetime.timedelta
2783
2792
 
2784
 
    >>> rfc3339_duration_to_delta("P7D") == datetime.timedelta(7)
2785
 
    True
2786
 
    >>> rfc3339_duration_to_delta("PT60S") == datetime.timedelta(0, 60)
2787
 
    True
2788
 
    >>> rfc3339_duration_to_delta("PT60M") == datetime.timedelta(0, 3600)
2789
 
    True
2790
 
    >>> rfc3339_duration_to_delta("PT24H") == datetime.timedelta(1)
2791
 
    True
2792
 
    >>> rfc3339_duration_to_delta("P1W") == datetime.timedelta(7)
2793
 
    True
2794
 
    >>> rfc3339_duration_to_delta("PT5M30S") == datetime.timedelta(0, 330)
2795
 
    True
2796
 
    >>> rfc3339_duration_to_delta("P1DT3M20S") == datetime.timedelta(1, 200)
2797
 
    True
 
2793
    >>> timedelta = datetime.timedelta
 
2794
    >>> rfc3339_duration_to_delta("P7D") == timedelta(7)
 
2795
    True
 
2796
    >>> rfc3339_duration_to_delta("PT60S") == timedelta(0, 60)
 
2797
    True
 
2798
    >>> rfc3339_duration_to_delta("PT60M") == timedelta(0, 3600)
 
2799
    True
 
2800
    >>> rfc3339_duration_to_delta("PT24H") == timedelta(1)
 
2801
    True
 
2802
    >>> rfc3339_duration_to_delta("P1W") == timedelta(7)
 
2803
    True
 
2804
    >>> rfc3339_duration_to_delta("PT5M30S") == timedelta(0, 330)
 
2805
    True
 
2806
    >>> rfc3339_duration_to_delta("P1DT3M20S") == timedelta(1, 200)
 
2807
    True
 
2808
    >>> del timedelta
2798
2809
    """
2799
2810
 
2800
2811
    # Parsing an RFC 3339 duration with regular expressions is not