=== modified file 'TODO' --- TODO 2014-06-08 02:31:50 +0000 +++ TODO 2014-06-15 02:48:49 +0000 @@ -44,8 +44,6 @@ * plugin-runner ** TODO handle printing for errors for plugins *** Hook up stderr of plugins, buffer them, and prepend "Mandos Plugin [plugin name]" -** TODO [#B] use scandirat(3) instead of readdir(3) -*** Must wait until GNU libc 2.15 ** TODO [#C] use same file name rules as run-parts(8) ** kernel command line option for debug info @@ -83,7 +81,6 @@ http://standards.freedesktop.org/secret-service/ ** TODO Remove D-Bus interfaces with old domain name :2: ** TODO Remove old string_to_delta format :2: -** TODO --no-zeroconf (only valid if port or socket is set) * mandos.xml ** Add mandos contact info in manual pages === modified file 'mandos' --- mandos 2014-06-08 17:36:33 +0000 +++ mandos 2014-06-15 02:48:49 +0000 @@ -2337,6 +2337,9 @@ help="Directory to save/restore state in") parser.add_argument("--foreground", action="store_true", help="Run in foreground", default=None) + parser.add_argument("--no-zeroconf", action="store_false", + dest="zeroconf", help="Do not use Zeroconf", + default=None) options = parser.parse_args() @@ -2360,6 +2363,7 @@ "socket": "", "statedir": "/var/lib/mandos", "foreground": "False", + "zeroconf": "True", } # Parse config file for server-global settings @@ -2392,7 +2396,7 @@ for option in ("interface", "address", "port", "debug", "priority", "servicename", "configdir", "use_dbus", "use_ipv6", "debuglevel", "restore", - "statedir", "socket", "foreground"): + "statedir", "socket", "foreground", "zeroconf"): value = getattr(options, option) if value is not None: server_settings[option] = value @@ -2403,7 +2407,7 @@ server_settings[option] = unicode(server_settings[option]) # Force all boolean options to be boolean for option in ("debug", "use_dbus", "use_ipv6", "restore", - "foreground"): + "foreground", "zeroconf"): server_settings[option] = bool(server_settings[option]) # Debug implies foreground if server_settings["debug"]: @@ -2412,6 +2416,12 @@ ################################################################## + if (not server_settings["zeroconf"] and + not (server_settings["port"] + or server_settings["socket"] != "")): + parser.error("Needs port or socket to work without" + " Zeroconf") + # For convenience debug = server_settings["debug"] debuglevel = server_settings["debuglevel"] @@ -2420,6 +2430,7 @@ stored_state_path = os.path.join(server_settings["statedir"], stored_state_file) foreground = server_settings["foreground"] + zeroconf = server_settings["zeroconf"] if debug: initlogger(debug, logging.DEBUG) @@ -2446,6 +2457,9 @@ global mandos_dbus_service mandos_dbus_service = None + socketfd = None + if server_settings["socket"] != "": + socketfd = server_settings["socket"] tcp_server = MandosServer((server_settings["address"], server_settings["port"]), ClientHandler, @@ -2455,8 +2469,7 @@ gnutls_priority= server_settings["priority"], use_dbus=use_dbus, - socketfd=(server_settings["socket"] - or None)) + socketfd=socketfd) if not foreground: pidfilename = "/run/mandos.pid" if not os.path.isdir("/run/."): @@ -2532,14 +2545,15 @@ use_dbus = False server_settings["use_dbus"] = False tcp_server.use_dbus = False - protocol = avahi.PROTO_INET6 if use_ipv6 else avahi.PROTO_INET - service = AvahiServiceToSyslog(name = - server_settings["servicename"], - servicetype = "_mandos._tcp", - protocol = protocol, bus = bus) - if server_settings["interface"]: - service.interface = (if_nametoindex - (str(server_settings["interface"]))) + if zeroconf: + protocol = avahi.PROTO_INET6 if use_ipv6 else avahi.PROTO_INET + service = AvahiServiceToSyslog(name = + server_settings["servicename"], + servicetype = "_mandos._tcp", + protocol = protocol, bus = bus) + if server_settings["interface"]: + service.interface = (if_nametoindex + (str(server_settings["interface"]))) global multiprocessing_manager multiprocessing_manager = multiprocessing.Manager() @@ -2739,7 +2753,8 @@ def cleanup(): "Cleanup function; run on exit" - service.cleanup() + if zeroconf: + service.cleanup() multiprocessing.active_children() wnull.close() @@ -2824,7 +2839,8 @@ tcp_server.server_activate() # Find out what port we got - service.port = tcp_server.socket.getsockname()[1] + if zeroconf: + service.port = tcp_server.socket.getsockname()[1] if use_ipv6: logger.info("Now listening on address %r, port %d," " flowinfo %d, scope_id %d", @@ -2836,14 +2852,15 @@ #service.interface = tcp_server.socket.getsockname()[3] try: - # From the Avahi example code - try: - service.activate() - except dbus.exceptions.DBusException as error: - logger.critical("D-Bus Exception", exc_info=error) - cleanup() - sys.exit(1) - # End of Avahi example code + if zeroconf: + # From the Avahi example code + try: + service.activate() + except dbus.exceptions.DBusException as error: + logger.critical("D-Bus Exception", exc_info=error) + cleanup() + sys.exit(1) + # End of Avahi example code gobject.io_add_watch(tcp_server.fileno(), gobject.IO_IN, lambda *args, **kwargs: === modified file 'mandos-options.xml' --- mandos-options.xml 2013-10-24 20:21:45 +0000 +++ mandos-options.xml 2014-06-15 02:48:49 +0000 @@ -123,4 +123,11 @@ implies this option. + + This option controls whether the server will announce its + existence using Zeroconf. Default is to use Zeroconf. If + Zeroconf is not used, a number or a + is required. + + === modified file 'mandos.conf' --- mandos.conf 2013-10-22 19:24:01 +0000 +++ mandos.conf 2014-06-15 02:48:49 +0000 @@ -45,3 +45,9 @@ # Whether to run in the foreground ;foreground = False + +# File descriptor number to use for network socket +;socket = + +# Whether to use ZeroConf; if false, requires port or socket +;zeroconf = True === modified file 'mandos.xml' --- mandos.xml 2013-10-26 19:05:21 +0000 +++ mandos.xml 2014-06-15 02:48:49 +0000 @@ -2,7 +2,7 @@ - + %common; ]> @@ -106,6 +106,8 @@ FD + + &COMMANDNAME; @@ -323,6 +325,13 @@ + + + + + + +