/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: 2014-01-20 21:50:11 UTC
  • mto: (237.7.272 trunk)
  • mto: This revision was merged to the branch mainline in revision 307.
  • Revision ID: teddy@recompile.se-20140120215011-ka70v54d3rb2pyug
Bug fix from libdir change: make plugins get setuid bit again.

* debian/mandos-client.lintian-overrides: Libdir changes.
* debian/rules (override_dh_fixperms): - '' -

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-2012 Teddy Hogeborn
15
 
# Copyright © 2008-2012 Björn Påhlsson
 
14
# Copyright © 2008-2014 Teddy Hogeborn
 
15
# Copyright © 2008-2014 Björn Påhlsson
16
16
17
17
# This program is free software: you can redistribute it and/or modify
18
18
# it under the terms of the GNU General Public License as published by
88
88
    except ImportError:
89
89
        SO_BINDTODEVICE = None
90
90
 
91
 
version = "1.6.0"
 
91
version = "1.6.2"
92
92
stored_state_file = "clients.pickle"
93
93
 
94
94
logger = logging.getLogger()
172
172
    def password_encode(self, password):
173
173
        # Passphrase can not be empty and can not contain newlines or
174
174
        # NUL bytes.  So we prefix it and hex encode it.
175
 
        return b"mandos" + binascii.hexlify(password)
 
175
        encoded = b"mandos" + binascii.hexlify(password)
 
176
        if len(encoded) > 2048:
 
177
            # GnuPG can't handle long passwords, so encode differently
 
178
            encoded = (b"mandos" + password.replace(b"\\", b"\\\\")
 
179
                       .replace(b"\n", b"\\n")
 
180
                       .replace(b"\0", b"\\x00"))
 
181
        return encoded
176
182
    
177
183
    def encrypt(self, data, password):
178
184
        passphrase = self.password_encode(password)
684
690
        # If a checker exists, make sure it is not a zombie
685
691
        try:
686
692
            pid, status = os.waitpid(self.checker.pid, os.WNOHANG)
687
 
        except (AttributeError, OSError) as error:
688
 
            if (isinstance(error, OSError)
689
 
                and error.errno != errno.ECHILD):
690
 
                raise error
 
693
        except AttributeError:
 
694
            pass
 
695
        except OSError as error:
 
696
            if error.errno != errno.ECHILD:
 
697
                raise
691
698
        else:
692
699
            if pid:
693
700
                logger.warning("Checker was a zombie")
927
934
            # The byte_arrays option is not supported yet on
928
935
            # signatures other than "ay".
929
936
            if prop._dbus_signature != "ay":
930
 
                raise ValueError
 
937
                raise ValueError("Byte arrays not supported for non-"
 
938
                                 "'ay' signature {0!r}"
 
939
                                 .format(prop._dbus_signature))
931
940
            value = dbus.ByteArray(b''.join(chr(byte)
932
941
                                            for byte in value))
933
942
        prop(value)
1696
1705
            logger.debug("Protocol version: %r", line)
1697
1706
            try:
1698
1707
                if int(line.strip().split()[0]) > 1:
1699
 
                    raise RuntimeError
 
1708
                    raise RuntimeError(line)
1700
1709
            except (ValueError, IndexError, RuntimeError) as error:
1701
1710
                logger.error("Unknown protocol version: %s", error)
1702
1711
                return
1909
1918
    
1910
1919
    def add_pipe(self, parent_pipe, proc):
1911
1920
        """Dummy function; override as necessary"""
1912
 
        raise NotImplementedError
 
1921
        raise NotImplementedError()
1913
1922
 
1914
1923
 
1915
1924
class IPv6_TCPServer(MultiprocessingMixInWithPipe,
2252
2261
            else:
2253
2262
                raise ValueError("Unknown suffix {0!r}"
2254
2263
                                 .format(suffix))
2255
 
        except (ValueError, IndexError) as e:
 
2264
        except IndexError as e:
2256
2265
            raise ValueError(*(e.args))
2257
2266
        timevalue += delta
2258
2267
    return timevalue
2343
2352
                        "port": "",
2344
2353
                        "debug": "False",
2345
2354
                        "priority":
2346
 
                        "SECURE256:!CTYPE-X.509:+CTYPE-OPENPGP:+SIGN-RSA-SHA224",
 
2355
                        "SECURE256:!CTYPE-X.509:+CTYPE-OPENPGP:+SIGN-RSA-SHA224:+SIGN-RSA-RMD160",
2347
2356
                        "servicename": "Mandos",
2348
2357
                        "use_dbus": "True",
2349
2358
                        "use_ipv6": "True",
2450
2459
                              socketfd=(server_settings["socket"]
2451
2460
                                        or None))
2452
2461
    if not foreground:
2453
 
        pidfilename = "/var/run/mandos.pid"
 
2462
        pidfilename = "/run/mandos.pid"
 
2463
        if not os.path.isdir("/run/."):
 
2464
            pidfilename = "/var/run/mandos.pid"
2454
2465
        pidfile = None
2455
2466
        try:
2456
2467
            pidfile = open(pidfilename, "w")
2473
2484
        os.setuid(uid)
2474
2485
    except OSError as error:
2475
2486
        if error.errno != errno.EPERM:
2476
 
            raise error
 
2487
            raise
2477
2488
    
2478
2489
    if debug:
2479
2490
        # Enable all possible GnuTLS debugging
2784
2795
            else:
2785
2796
                logger.warning("Could not save persistent state:",
2786
2797
                               exc_info=e)
2787
 
                raise e
 
2798
                raise
2788
2799
        
2789
2800
        # Delete all clients, and settings from config
2790
2801
        while tcp_server.clients: