/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-08-01 19:52:59 UTC
  • Revision ID: teddy@recompile.se-20190801195259-nhu15rxjx3wz2kos
Break some long lines and refine documentation

* Makefile (LINUXVERSION): New.
  (LIBDIR): Break long line.
  (SYSTEMD, TMPFILES): Change ":=" to "=" to not run unless required.
  (run-client): Break long lines, and add two more harmless warnings
                to informational message.
  (install-server): Break long line.
  (install-client-nokey): - '' -
  (install-client): Shorten long line by using $(LINUXVERSION).
  (uninstall-client): - '' -

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
88
87
import xml.dom.minidom
89
88
import inspect
90
89
 
91
 
if sys.version_info.major == 2:
92
 
    __metaclass__ = type
93
 
 
94
90
# Try to find the value of SO_BINDTODEVICE:
95
91
try:
96
92
    # This is where SO_BINDTODEVICE is in Python 3.3 (or 3.4?) and
119
115
if sys.version_info.major == 2:
120
116
    str = unicode
121
117
 
122
 
if sys.version_info < (3, 2):
123
 
    configparser.Configparser = configparser.SafeConfigParser
124
 
 
125
 
version = "1.8.7"
 
118
version = "1.8.5"
126
119
stored_state_file = "clients.pickle"
127
120
 
128
121
logger = logging.getLogger()
186
179
    pass
187
180
 
188
181
 
189
 
class PGPEngine:
 
182
class PGPEngine(object):
190
183
    """A simple class for OpenPGP symmetric encryption & decryption"""
191
184
 
192
185
    def __init__(self):
282
275
 
283
276
 
284
277
# Pretend that we have an Avahi module
285
 
class avahi:
 
278
class avahi(object):
286
279
    """This isn't so much a class as it is a module-like namespace."""
287
280
    IF_UNSPEC = -1               # avahi-common/address.h
288
281
    PROTO_UNSPEC = -1            # avahi-common/address.h
322
315
    pass
323
316
 
324
317
 
325
 
class AvahiService:
 
318
class AvahiService(object):
326
319
    """An Avahi (Zeroconf) service.
327
320
 
328
321
    Attributes:
510
503
 
511
504
 
512
505
# Pretend that we have a GnuTLS module
513
 
class gnutls:
 
506
class gnutls(object):
514
507
    """This isn't so much a class as it is a module-like namespace."""
515
508
 
516
509
    library = ctypes.util.find_library("gnutls")
579
572
        pass
580
573
 
581
574
    # Classes
582
 
    class Credentials:
 
575
    class Credentials(object):
583
576
        def __init__(self):
584
577
            self._c_object = gnutls.certificate_credentials_t()
585
578
            gnutls.certificate_allocate_credentials(
589
582
        def __del__(self):
590
583
            gnutls.certificate_free_credentials(self._c_object)
591
584
 
592
 
    class ClientSession:
 
585
    class ClientSession(object):
593
586
        def __init__(self, socket, credentials=None):
594
587
            self._c_object = gnutls.session_t()
595
588
            gnutls_flags = gnutls.CLIENT
821
814
    connection.close()
822
815
 
823
816
 
824
 
class Client:
 
817
class Client(object):
825
818
    """A representation of a client host served by this server.
826
819
 
827
820
    Attributes:
2216
2209
    del _interface
2217
2210
 
2218
2211
 
2219
 
class ProxyClient:
 
2212
class ProxyClient(object):
2220
2213
    def __init__(self, child_pipe, key_id, fpr, address):
2221
2214
        self._pipe = child_pipe
2222
2215
        self._pipe.send(('init', key_id, fpr, address))
2495
2488
        return hex_fpr
2496
2489
 
2497
2490
 
2498
 
class MultiprocessingMixIn:
 
2491
class MultiprocessingMixIn(object):
2499
2492
    """Like socketserver.ThreadingMixIn, but with multiprocessing"""
2500
2493
 
2501
2494
    def sub_process_main(self, request, address):
2513
2506
        return proc
2514
2507
 
2515
2508
 
2516
 
class MultiprocessingMixInWithPipe(MultiprocessingMixIn):
 
2509
class MultiprocessingMixInWithPipe(MultiprocessingMixIn, object):
2517
2510
    """ adds a pipe to the MixIn """
2518
2511
 
2519
2512
    def process_request(self, request, client_address):
2534
2527
 
2535
2528
 
2536
2529
class IPv6_TCPServer(MultiprocessingMixInWithPipe,
2537
 
                     socketserver.TCPServer):
 
2530
                     socketserver.TCPServer, object):
2538
2531
    """IPv6-capable TCP server.  Accepts 'None' as address and/or port
2539
2532
 
2540
2533
    Attributes:
3005
2998
    del priority
3006
2999
 
3007
3000
    # Parse config file for server-global settings
3008
 
    server_config = configparser.ConfigParser(server_defaults)
 
3001
    server_config = configparser.SafeConfigParser(server_defaults)
3009
3002
    del server_defaults
3010
3003
    server_config.read(os.path.join(options.configdir, "mandos.conf"))
3011
 
    # Convert the ConfigParser object to a dict
 
3004
    # Convert the SafeConfigParser object to a dict
3012
3005
    server_settings = server_config.defaults()
3013
3006
    # Use the appropriate methods on the non-string config options
3014
3007
    for option in ("debug", "use_dbus", "use_ipv6", "restore",
3086
3079
                                  server_settings["servicename"])))
3087
3080
 
3088
3081
    # Parse config file with clients
3089
 
    client_config = configparser.ConfigParser(Client.client_defaults)
 
3082
    client_config = configparser.SafeConfigParser(Client
 
3083
                                                  .client_defaults)
3090
3084
    client_config.read(os.path.join(server_settings["configdir"],
3091
3085
                                    "clients.conf"))
3092
3086
 
3163
3157
        # Close all input and output, do double fork, etc.
3164
3158
        daemon()
3165
3159
 
3166
 
    if gi.version_info < (3, 10, 2):
3167
 
        # multiprocessing will use threads, so before we use GLib we
3168
 
        # need to inform GLib that threads will be used.
3169
 
        GLib.threads_init()
 
3160
    # multiprocessing will use threads, so before we use GLib we need
 
3161
    # to inform GLib that threads will be used.
 
3162
    GLib.threads_init()
3170
3163
 
3171
3164
    global main_loop
3172
3165
    # From the Avahi example code