/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: 2013-10-22 19:46:35 UTC
  • Revision ID: teddy@recompile.se-20131022194635-ll6jyg1snrxwe94o
* TODO

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-2014 Teddy Hogeborn
15
 
# Copyright © 2008-2014 Björn Påhlsson
 
14
# Copyright © 2008-2013 Teddy Hogeborn
 
15
# Copyright © 2008-2013 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.2"
 
91
version = "1.6.1"
92
92
stored_state_file = "clients.pickle"
93
93
 
94
94
logger = logging.getLogger()
690
690
        # If a checker exists, make sure it is not a zombie
691
691
        try:
692
692
            pid, status = os.waitpid(self.checker.pid, os.WNOHANG)
693
 
        except AttributeError:
694
 
            pass
695
 
        except OSError as error:
696
 
            if error.errno != errno.ECHILD:
697
 
                raise
 
693
        except (AttributeError, OSError) as error:
 
694
            if (isinstance(error, OSError)
 
695
                and error.errno != errno.ECHILD):
 
696
                raise error
698
697
        else:
699
698
            if pid:
700
699
                logger.warning("Checker was a zombie")
934
933
            # The byte_arrays option is not supported yet on
935
934
            # signatures other than "ay".
936
935
            if prop._dbus_signature != "ay":
937
 
                raise ValueError("Byte arrays not supported for non-"
938
 
                                 "'ay' signature {0!r}"
939
 
                                 .format(prop._dbus_signature))
 
936
                raise ValueError
940
937
            value = dbus.ByteArray(b''.join(chr(byte)
941
938
                                            for byte in value))
942
939
        prop(value)
1705
1702
            logger.debug("Protocol version: %r", line)
1706
1703
            try:
1707
1704
                if int(line.strip().split()[0]) > 1:
1708
 
                    raise RuntimeError(line)
 
1705
                    raise RuntimeError
1709
1706
            except (ValueError, IndexError, RuntimeError) as error:
1710
1707
                logger.error("Unknown protocol version: %s", error)
1711
1708
                return
1918
1915
    
1919
1916
    def add_pipe(self, parent_pipe, proc):
1920
1917
        """Dummy function; override as necessary"""
1921
 
        raise NotImplementedError()
 
1918
        raise NotImplementedError
1922
1919
 
1923
1920
 
1924
1921
class IPv6_TCPServer(MultiprocessingMixInWithPipe,
2261
2258
            else:
2262
2259
                raise ValueError("Unknown suffix {0!r}"
2263
2260
                                 .format(suffix))
2264
 
        except IndexError as e:
 
2261
        except (ValueError, IndexError) as e:
2265
2262
            raise ValueError(*(e.args))
2266
2263
        timevalue += delta
2267
2264
    return timevalue
2460
2457
                                        or None))
2461
2458
    if not foreground:
2462
2459
        pidfilename = "/run/mandos.pid"
2463
 
        if not os.path.isdir("/run/."):
2464
 
            pidfilename = "/var/run/mandos.pid"
2465
2460
        pidfile = None
2466
2461
        try:
2467
2462
            pidfile = open(pidfilename, "w")
2484
2479
        os.setuid(uid)
2485
2480
    except OSError as error:
2486
2481
        if error.errno != errno.EPERM:
2487
 
            raise
 
2482
            raise error
2488
2483
    
2489
2484
    if debug:
2490
2485
        # Enable all possible GnuTLS debugging
2795
2790
            else:
2796
2791
                logger.warning("Could not save persistent state:",
2797
2792
                               exc_info=e)
2798
 
                raise
 
2793
                raise e
2799
2794
        
2800
2795
        # Delete all clients, and settings from config
2801
2796
        while tcp_server.clients: