]> git.meshlink.io Git - catta/blobdiff - avahi-daemon/main.c
* Yeh, I should like.. test my changes before I commit them, that would be a goodd...
[catta] / avahi-daemon / main.c
index e249304d4d603bb2e0fd29c1e89beda51c8ba161..6110cbcd13dae3403cc0cf9879b702542b0dff3b 100644 (file)
 
 #include <avahi-common/malloc.h>
 #include <avahi-common/simple-watch.h>
+#include <avahi-common/error.h>
+#include <avahi-common/alternative.h>
 #include <avahi-core/core.h>
 #include <avahi-core/log.h>
 
 #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 {
@@ -73,7 +78,10 @@ typedef struct {
     int daemonize;
     int use_syslog;
     char *config_file;
+#ifdef HAVE_DBUS
     int enable_dbus;
+    int fail_on_missing_dbus;
+#endif
     int drop_root;
     int publish_resolv_conf;
     char ** publish_dns_servers;
@@ -208,7 +216,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 +262,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);
 }
@@ -375,8 +383,22 @@ 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;
+                    }
+#ifdef HAVE_DBUS                
+                    if (c->enable_dbus == 1) 
+                        avahi_log_warn("Avahi was compiled without d-bus support but you requested it was enabled in the config file");
+#endif
+                }
                 else if (strcasecmp(p->key, "drop-root") == 0)
                     c->drop_root = is_yes(p->value);
                 else {
@@ -580,10 +602,16 @@ static int run_server(DaemonConfig *c) {
     if (simple_protocol_setup(poll_api) < 0)
         goto finish;
     
-#ifdef 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;
+        }
 #endif
     
     load_resolv_conf(c);
@@ -820,7 +848,10 @@ 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;
+#endif
     config.drop_root = 1;
     config.publish_dns_servers = NULL;
     config.publish_resolv_conf = 0;