/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 at recompile
  • Date: 2020-07-04 08:59:37 UTC
  • Revision ID: teddy@recompile.se-20200704085937-r495zb32nfng9lnt
In initramfs-tools boots, only use setsid when available

* initramfs-tools-script: If available, use setsid to start
  mandos-to-cryptroot-unlock.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
# "AvahiService" class, and some lines in "main".
12
12
#
13
13
# Everything else is
14
 
# Copyright © 2008-2020 Teddy Hogeborn
15
 
# Copyright © 2008-2020 Björn Påhlsson
 
14
# Copyright © 2008-2019 Teddy Hogeborn
 
15
# Copyright © 2008-2019 Björn Påhlsson
16
16
#
17
17
# This file is part of Mandos.
18
18
#
143
143
if sys.version_info < (3, 2):
144
144
    configparser.Configparser = configparser.SafeConfigParser
145
145
 
146
 
version = "1.8.13"
 
146
version = "1.8.11"
147
147
stored_state_file = "clients.pickle"
148
148
 
149
149
logger = logging.getLogger()
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,
528
 
                                                       **kwargs)
 
527
        ret = super(AvahiServiceToSyslog, self).rename(*args, **kwargs)
529
528
        syslogger.setFormatter(logging.Formatter(
530
529
            'Mandos ({}) [%(process)d]: %(levelname)s: %(message)s'
531
530
            .format(self.name)))
775
774
 
776
775
        x509_crt_fmt_t = ctypes.c_int
777
776
 
778
 
        # All the function declarations below are from
779
 
        # gnutls/abstract.h
 
777
        # All the function declarations below are from gnutls/abstract.h
780
778
        pubkey_init = _library.gnutls_pubkey_init
781
779
        pubkey_init.argtypes = [ctypes.POINTER(pubkey_t)]
782
780
        pubkey_init.restype = _error_code
796
794
        pubkey_deinit.argtypes = [pubkey_t]
797
795
        pubkey_deinit.restype = None
798
796
    else:
799
 
        # All the function declarations below are from
800
 
        # gnutls/openpgp.h
 
797
        # All the function declarations below are from gnutls/openpgp.h
801
798
 
802
799
        openpgp_crt_init = _library.gnutls_openpgp_crt_init
803
800
        openpgp_crt_init.argtypes = [ctypes.POINTER(openpgp_crt_t)]
809
806
                                       openpgp_crt_fmt_t]
810
807
        openpgp_crt_import.restype = _error_code
811
808
 
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
 
        ]
 
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)]
819
812
        openpgp_crt_verify_self.restype = _error_code
820
813
 
821
814
        openpgp_crt_deinit = _library.gnutls_openpgp_crt_deinit
2475
2468
        buf = ctypes.create_string_buffer(32)
2476
2469
        buf_len = ctypes.c_size_t(len(buf))
2477
2470
        # Get the key ID from the raw public key into the buffer
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))
 
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))
2484
2476
        # Deinit the certificate
2485
2477
        gnutls.pubkey_deinit(pubkey)
2486
2478
 
2731
2723
            address = request[3]
2732
2724
 
2733
2725
            for c in self.clients.values():
2734
 
                if key_id == ("E3B0C44298FC1C149AFBF4C8996FB924"
2735
 
                              "27AE41E4649B934CA495991B7852B855"):
 
2726
                if key_id == "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855":
2736
2727
                    continue
2737
2728
                if key_id and c.key_id == key_id:
2738
2729
                    client = c
2790
2781
def rfc3339_duration_to_delta(duration):
2791
2782
    """Parse an RFC 3339 "duration" and return a datetime.timedelta
2792
2783
 
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
 
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
2809
2798
    """
2810
2799
 
2811
2800
    # Parsing an RFC 3339 duration with regular expressions is not