X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-daemon%2Fmain.c;h=7f5d1484182a6f0d53b18e40622e85d58abb20bd;hb=adfa1d85bce393fa549b72fa1dd650eb3c74f8d8;hp=1fc3895ca39c9dcd8ff886fbf1978ff5aba12199;hpb=f1167112d926b189fe189599576e8588923f036c;p=catta diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c index 1fc3895..7f5d148 100644 --- a/avahi-daemon/main.c +++ b/avahi-daemon/main.c @@ -47,6 +47,8 @@ #include #include +#include +#include #include #include @@ -77,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; @@ -217,7 +220,7 @@ static void server_callback(AvahiServer *s, AvahiServerState state, void *userda #endif if (state == AVAHI_SERVER_RUNNING) { - avahi_log_info("Server startup complete. Host name is <%s>", avahi_server_get_host_name_fqdn(s)); + avahi_log_info("Server startup complete. Host name is %s. Local service cookie is %u.", avahi_server_get_host_name_fqdn(s), avahi_server_get_local_service_cookie(s)); static_service_add_to_server(); remove_dns_server_entry_groups(); @@ -257,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); } @@ -378,10 +381,21 @@ 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, "drop-root") == 0) + 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 if (strcasecmp(p->key, "add-service-cookie") == 0) + c->server_config.add_service_cookie = is_yes(p->value); else { avahi_log_error("Invalid configuration key \"%s\" in group \"%s\"\n", p->key, g->name); goto finish; @@ -582,12 +596,21 @@ static int run_server(DaemonConfig *c) { if (simple_protocol_setup(poll_api) < 0) goto finish; - + if (c->enable_dbus) { #ifdef HAVE_DBUS - if (c->enable_dbus) - if (dbus_protocol_setup(poll_api) < 0) - goto finish; + 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(); @@ -823,7 +846,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;