/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-03-30 07:09:35 UTC
  • Revision ID: teddy@recompile.se-20190330070935-mo98cdxyfj8r2ukp
mandos-ctl: Fix grammar.

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