/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-05 21:03:31 UTC
  • mto: This revision was merged to the branch mainline in revision 388.
  • Revision ID: teddy@recompile.se-20190805210331-vut4mdrc129c6ycs
Override lintian warning about old debhelper format

* debian/source/lintian-overrides
  (package-uses-old-debhelper-compat-version): New; set to "10".

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
83
84
from gi.repository import GLib
84
85
from dbus.mainloop.glib import DBusGMainLoop
85
86
import ctypes
115
116
if sys.version_info.major == 2:
116
117
    str = unicode
117
118
 
118
 
version = "1.8.4"
 
119
if sys.version_info < (3, 2):
 
120
    configparser.Configparser = configparser.SafeConfigParser
 
121
 
 
122
version = "1.8.6"
119
123
stored_state_file = "clients.pickle"
120
124
 
121
125
logger = logging.getLogger()
586
590
        def __init__(self, socket, credentials=None):
587
591
            self._c_object = gnutls.session_t()
588
592
            gnutls_flags = gnutls.CLIENT
589
 
            if gnutls.check_version("3.5.6"):
 
593
            if gnutls.check_version(b"3.5.6"):
590
594
                gnutls_flags |= gnutls.NO_TICKETS
591
595
            if gnutls.has_rawpk:
592
596
                gnutls_flags |= gnutls.ENABLE_RAWPK
794
798
                                                    ctypes.c_size_t)]
795
799
        openpgp_crt_get_fingerprint.restype = _error_code
796
800
 
797
 
    if check_version("3.6.4"):
 
801
    if check_version(b"3.6.4"):
798
802
        certificate_type_get2 = _library.gnutls_certificate_type_get2
799
803
        certificate_type_get2.argtypes = [session_t, ctypes.c_int]
800
804
        certificate_type_get2.restype = _error_code
821
825
    approved:   bool(); 'None' if not yet approved/disapproved
822
826
    approval_delay: datetime.timedelta(); Time to wait for approval
823
827
    approval_duration: datetime.timedelta(); Duration of one approval
824
 
    checker:    subprocess.Popen(); a running checker process used
825
 
                                    to see if the client lives.
826
 
                                    'None' if no process is running.
 
828
    checker: multiprocessing.Process(); a running checker process used
 
829
             to see if the client lives. 'None' if no process is
 
830
             running.
827
831
    checker_callback_tag: a GLib event source tag, or None
828
832
    checker_command: string; External command which is run to check
829
833
                     if client lives.  %() expansions are done at
1036
1040
    def checker_callback(self, source, condition, connection,
1037
1041
                         command):
1038
1042
        """The checker has completed, so take appropriate actions."""
1039
 
        self.checker_callback_tag = None
1040
 
        self.checker = None
1041
1043
        # Read return code from connection (see call_pipe)
1042
1044
        returncode = connection.recv()
1043
1045
        connection.close()
 
1046
        self.checker.join()
 
1047
        self.checker_callback_tag = None
 
1048
        self.checker = None
1044
1049
 
1045
1050
        if returncode >= 0:
1046
1051
            self.last_checker_status = returncode
2287
2292
            approval_required = False
2288
2293
            try:
2289
2294
                if gnutls.has_rawpk:
2290
 
                    fpr = ""
 
2295
                    fpr = b""
2291
2296
                    try:
2292
2297
                        key_id = self.key_id(
2293
2298
                            self.peer_certificate(session))
2297
2302
                    logger.debug("Key ID: %s", key_id)
2298
2303
 
2299
2304
                else:
2300
 
                    key_id = ""
 
2305
                    key_id = b""
2301
2306
                    try:
2302
2307
                        fpr = self.fingerprint(
2303
2308
                            self.peer_certificate(session))
2997
3002
    del priority
2998
3003
 
2999
3004
    # Parse config file for server-global settings
3000
 
    server_config = configparser.SafeConfigParser(server_defaults)
 
3005
    server_config = configparser.ConfigParser(server_defaults)
3001
3006
    del server_defaults
3002
3007
    server_config.read(os.path.join(options.configdir, "mandos.conf"))
3003
 
    # Convert the SafeConfigParser object to a dict
 
3008
    # Convert the ConfigParser object to a dict
3004
3009
    server_settings = server_config.defaults()
3005
3010
    # Use the appropriate methods on the non-string config options
3006
3011
    for option in ("debug", "use_dbus", "use_ipv6", "restore",
3078
3083
                                  server_settings["servicename"])))
3079
3084
 
3080
3085
    # Parse config file with clients
3081
 
    client_config = configparser.SafeConfigParser(Client
3082
 
                                                  .client_defaults)
 
3086
    client_config = configparser.ConfigParser(Client.client_defaults)
3083
3087
    client_config.read(os.path.join(server_settings["configdir"],
3084
3088
                                    "clients.conf"))
3085
3089
 
3156
3160
        # Close all input and output, do double fork, etc.
3157
3161
        daemon()
3158
3162
 
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()
 
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()
3162
3167
 
3163
3168
    global main_loop
3164
3169
    # From the Avahi example code
3244
3249
                        for k in ("name", "host"):
3245
3250
                            if isinstance(value[k], bytes):
3246
3251
                                value[k] = value[k].decode("utf-8")
3247
 
                        if not value.has_key("key_id"):
 
3252
                        if "key_id" not in value:
3248
3253
                            value["key_id"] = ""
3249
 
                        elif not value.has_key("fingerprint"):
 
3254
                        elif "fingerprint" not in value:
3250
3255
                            value["fingerprint"] = ""
3251
3256
                    #  old_client_settings
3252
3257
                    # .keys()