X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-daemon%2Fmain.c;h=75d01aabc25eb0ee7f1438c5cec7fab38b8fb777;hb=549a28cd15a86bd04e5bac765f2e26ef751b5cba;hp=d0db0dd1b16cceb671e01648856787fba462dc12;hpb=deb6bcac8d1e1ecec4aafaee2d27dbe467e4f461;p=catta diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c index d0db0dd..75d01aa 100644 --- a/avahi-daemon/main.c +++ b/avahi-daemon/main.c @@ -47,15 +47,20 @@ #include #include +#include +#include #include #include #include "main.h" #include "simple-protocol.h" -#include "dbus-protocol.h" #include "static-services.h" #include "ini-file-parser.h" +#ifdef HAVE_DBUS +#include "dbus-protocol.h" +#endif + AvahiServer *avahi_server = NULL; typedef enum { @@ -74,6 +79,7 @@ typedef struct { int use_syslog; char *config_file; int enable_dbus; + int fail_on_missing_dbus; int drop_root; int publish_resolv_conf; char ** publish_dns_servers; @@ -208,7 +214,7 @@ static void server_callback(AvahiServer *s, AvahiServerState state, void *userda avahi_server = s; -#ifdef ENABLE_DBUS +#ifdef HAVE_DBUS if (c->enable_dbus) dbus_protocol_server_state_changed(state); #endif @@ -254,7 +260,7 @@ static void help(FILE *f, const char *argv0) { " -f --file=FILE Load the specified configuration file instead of\n" " "AVAHI_CONFIG_FILE"\n" " --no-rlimits Don't enforce resource limits\n" - " --no-drop-root Don't drop priviliges\n" + " --no-drop-root Don't drop privileges\n" " --debug Increase verbosity\n", argv0); } @@ -269,7 +275,7 @@ static int parse_command_line(DaemonConfig *c, int argc, char *argv[]) { OPTION_DEBUG }; - static const struct option const long_options[] = { + static const struct option long_options[] = { { "help", no_argument, NULL, 'h' }, { "daemonize", no_argument, NULL, 'D' }, { "kill", no_argument, NULL, 'k' }, @@ -375,8 +381,18 @@ static int load_config_file(DaemonConfig *c) { c->server_config.check_response_ttl = is_yes(p->value); else if (strcasecmp(p->key, "use-iff-running") == 0) c->server_config.use_iff_running = is_yes(p->value); - else if (strcasecmp(p->key, "enable-dbus") == 0) - c->enable_dbus = is_yes(p->value); + else if (strcasecmp(p->key, "enable-dbus") == 0) { + + if (*(p->value) == 'w' || *(p->value) == 'W') { + c->fail_on_missing_dbus = 0; + c->enable_dbus = 1; + } else if (*(p->value) == 'y' || *(p->value) == 'Y') { + c->fail_on_missing_dbus = 1; + c->enable_dbus = 1; + } else { + c->enable_dbus = 0; + } + } else if (strcasecmp(p->key, "drop-root") == 0) c->drop_root = is_yes(p->value); else { @@ -477,7 +493,7 @@ finish: static void log_function(AvahiLogLevel level, const char *txt) { - static const int const log_level_map[] = { + static const int log_level_map[] = { LOG_ERR, LOG_WARNING, LOG_NOTICE, @@ -579,12 +595,21 @@ static int run_server(DaemonConfig *c) { if (simple_protocol_setup(poll_api) < 0) goto finish; - -#ifdef ENABLE_DBUS - if (c->enable_dbus) - if (dbus_protocol_setup(poll_api) < 0) - goto finish; + if (c->enable_dbus) { +#ifdef HAVE_DBUS + if (dbus_protocol_setup(poll_api) < 0) { + + if (c->fail_on_missing_dbus) + goto finish; + + avahi_log_warn("WARNING: Failed to contact D-BUS daemon, disabling D-BUS support."); + c->enable_dbus = 0; + } +#else + avahi_log_warn("WARNING: We are configured to enable D-BUS but it was not compiled in"); + c->enable_dbus = 0; #endif + } load_resolv_conf(c); static_service_load(); @@ -820,7 +845,13 @@ int main(int argc, char *argv[]) { config.command = DAEMON_RUN; config.daemonize = 0; config.config_file = NULL; +#ifdef HAVE_DBUS config.enable_dbus = 1; + config.fail_on_missing_dbus = 1; +#else + config.enable_dbus = 0; + config.fail_on_missing_dbus = 0; +#endif config.drop_root = 1; config.publish_dns_servers = NULL; config.publish_resolv_conf = 0;