/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

* plugin-runner.c (main): If debugging, print name of failed plugins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
    """
115
115
    def __init__(self, interface = avahi.IF_UNSPEC, name = None,
116
116
                 servicetype = None, port = None, TXT = None,
117
 
                 domain = "", host = "", max_renames = 32768,
118
 
                 protocol = avahi.PROTO_UNSPEC):
 
117
                 domain = "", host = "", max_renames = 32768):
119
118
        self.interface = interface
120
119
        self.name = name
121
120
        self.type = servicetype
125
124
        self.host = host
126
125
        self.rename_count = 0
127
126
        self.max_renames = max_renames
128
 
        self.protocol = protocol
129
127
    def rename(self):
130
128
        """Derived from the Avahi example code"""
131
129
        if self.rename_count >= self.max_renames:
160
158
                     service.name, service.type)
161
159
        group.AddService(
162
160
                self.interface,         # interface
163
 
                self.protocol,          # protocol
 
161
                avahi.PROTO_INET6,      # protocol
164
162
                dbus.UInt32(0),         # flags
165
163
                self.name, self.type,
166
164
                self.domain, self.host,
414
412
                                             (self.checker.pid,
415
413
                                              self.checker_callback,
416
414
                                              data=command))
417
 
                # The checker may have completed before the gobject
418
 
                # watch was added.  Check for this.
419
 
                pid, status = os.waitpid(self.checker.pid, os.WNOHANG)
420
 
                if pid:
421
 
                    gobject.source_remove(self.checker_callback_tag)
422
 
                    self.checker_callback(pid, status, command)
423
415
            except OSError, error:
424
416
                logger.error(u"Failed to start subprocess: %s",
425
417
                             error)
740
732
 
741
733
class IPv6_TCPServer(SocketServer.ForkingMixIn,
742
734
                     SocketServer.TCPServer, object):
743
 
    """IPv6-capable TCP server.  Accepts 'None' as address and/or port.
 
735
    """IPv6 TCP server.  Accepts 'None' as address and/or port.
744
736
    Attributes:
745
737
        settings:       Server settings
746
738
        clients:        Set() of Client objects
754
746
        if "clients" in kwargs:
755
747
            self.clients = kwargs["clients"]
756
748
            del kwargs["clients"]
757
 
        if "use_ipv6" in kwargs:
758
 
            if not kwargs["use_ipv6"]:
759
 
                self.address_family = socket.AF_INET
760
 
            del kwargs["use_ipv6"]
761
749
        self.enabled = False
762
750
        super(IPv6_TCPServer, self).__init__(*args, **kwargs)
763
751
    def server_bind(self):
781
769
        # Only bind(2) the socket if we really need to.
782
770
        if self.server_address[0] or self.server_address[1]:
783
771
            if not self.server_address[0]:
784
 
                if self.address_family == socket.AF_INET6:
785
 
                    any_address = "::" # in6addr_any
786
 
                else:
787
 
                    any_address = socket.INADDR_ANY
788
 
                self.server_address = (any_address,
 
772
                in6addr_any = "::"
 
773
                self.server_address = (in6addr_any,
789
774
                                       self.server_address[1])
790
775
            elif not self.server_address[1]:
791
776
                self.server_address = (self.server_address[0],
938
923
                      dest="use_dbus",
939
924
                      help="Do not provide D-Bus system bus"
940
925
                      " interface")
941
 
    parser.add_option("--no-ipv6", action="store_false",
942
 
                      dest="use_ipv6", help="Do not use IPv6")
943
926
    options = parser.parse_args()[0]
944
927
    
945
928
    if options.check:
956
939
                        "SECURE256:!CTYPE-X.509:+CTYPE-OPENPGP",
957
940
                        "servicename": "Mandos",
958
941
                        "use_dbus": "True",
959
 
                        "use_ipv6": "True",
960
942
                        }
961
943
    
962
944
    # Parse config file for server-global settings
970
952
                                                        "debug")
971
953
    server_settings["use_dbus"] = server_config.getboolean("DEFAULT",
972
954
                                                           "use_dbus")
973
 
    server_settings["use_ipv6"] = server_config.getboolean("DEFAULT",
974
 
                                                           "use_ipv6")
975
955
    if server_settings["port"]:
976
956
        server_settings["port"] = server_config.getint("DEFAULT",
977
957
                                                       "port")
981
961
    # options, if set.
982
962
    for option in ("interface", "address", "port", "debug",
983
963
                   "priority", "servicename", "configdir",
984
 
                   "use_dbus", "use_ipv6"):
 
964
                   "use_dbus"):
985
965
        value = getattr(options, option)
986
966
        if value is not None:
987
967
            server_settings[option] = value
991
971
    # For convenience
992
972
    debug = server_settings["debug"]
993
973
    use_dbus = server_settings["use_dbus"]
994
 
    use_ipv6 = server_settings["use_ipv6"]
995
974
    
996
975
    if not debug:
997
976
        syslogger.setLevel(logging.WARNING)
1018
997
                                 server_settings["port"]),
1019
998
                                TCP_handler,
1020
999
                                settings=server_settings,
1021
 
                                clients=clients, use_ipv6=use_ipv6)
 
1000
                                clients=clients)
1022
1001
    pidfilename = "/var/run/mandos.pid"
1023
1002
    try:
1024
1003
        pidfile = open(pidfilename, "w")
1060
1039
         .gnutls_global_set_log_function(debug_gnutls))
1061
1040
    
1062
1041
    global service
1063
 
    protocol = avahi.PROTO_INET6 if use_ipv6 else avahi.PROTO_INET
1064
1042
    service = AvahiService(name = server_settings["servicename"],
1065
 
                           servicetype = "_mandos._tcp",
1066
 
                           protocol = protocol)
 
1043
                           servicetype = "_mandos._tcp", )
1067
1044
    if server_settings["interface"]:
1068
1045
        service.interface = (if_nametoindex
1069
1046
                             (server_settings["interface"]))
1196
1173
    
1197
1174
    # Find out what port we got
1198
1175
    service.port = tcp_server.socket.getsockname()[1]
1199
 
    if use_ipv6:
1200
 
        logger.info(u"Now listening on address %r, port %d,"
1201
 
                    " flowinfo %d, scope_id %d"
1202
 
                    % tcp_server.socket.getsockname())
1203
 
    else:                       # IPv4
1204
 
        logger.info(u"Now listening on address %r, port %d"
1205
 
                    % tcp_server.socket.getsockname())
 
1176
    logger.info(u"Now listening on address %r, port %d, flowinfo %d,"
 
1177
                u" scope_id %d" % tcp_server.socket.getsockname())
1206
1178
    
1207
1179
    #service.interface = tcp_server.socket.getsockname()[3]
1208
1180