]> git.meshlink.io Git - catta/blobdiff - avahi-daemon/main.c
add experimental mdns fuzzer
[catta] / avahi-daemon / main.c
index a903e63c8649a9c71fc8c82344a658f9d2e4f1d5..da198686b6c289db6f605e494e9d4550133d88f5 100644 (file)
@@ -101,7 +101,8 @@ typedef struct {
     int use_chroot;
 #endif
     int modify_proc_title;
-    
+
+    int disable_user_service_publishing;
     int publish_resolv_conf;
     char ** publish_dns_servers;
     int debug;
@@ -521,6 +522,10 @@ static int load_config_file(DaemonConfig *c) {
                     c->server_config.publish_domain = is_yes(p->value);
                 else if (strcasecmp(p->key, "publish-resolv-conf-dns-servers") == 0)
                     c->publish_resolv_conf = is_yes(p->value);
+                else if (strcasecmp(p->key, "disable-publishing") == 0)
+                    c->server_config.disable_publishing = is_yes(p->value);
+                else if (strcasecmp(p->key, "disable-user-service-publishing") == 0)
+                    c->disable_user_service_publishing = is_yes(p->value);
                 else if (strcasecmp(p->key, "add-service-cookie") == 0)
                     c->server_config.add_service_cookie = is_yes(p->value);
                 else if (strcasecmp(p->key, "publish-dns-servers") == 0) {
@@ -698,6 +703,7 @@ static int run_server(DaemonConfig *c) {
     int error;
     const AvahiPoll *poll_api = NULL;
     AvahiWatch *sig_watch = NULL;
+    int retval_is_sent = 0;
 
     assert(c);
 
@@ -723,7 +729,7 @@ static int run_server(DaemonConfig *c) {
 
 #ifdef HAVE_DBUS
     if (c->enable_dbus) {
-        if (dbus_protocol_setup(poll_api) < 0) {
+        if (dbus_protocol_setup(poll_api, config.disable_user_service_publishing) < 0) {
 
             if (c->fail_on_missing_dbus)
                 goto finish;
@@ -742,14 +748,14 @@ static int run_server(DaemonConfig *c) {
             goto finish;
         }
         
+        avahi_log_info("Successfully called chroot().");
         chdir("/");
         
         if (avahi_caps_drop_all() < 0) {
             avahi_log_error("Failed to drop capabilities.");
             goto finish;
         }
-
-        avahi_log_info("chroot() successful.");
+        avahi_log_info("Successfully dropped remaining capabilities.");
     }
     
 #endif
@@ -768,8 +774,10 @@ static int run_server(DaemonConfig *c) {
 
     update_wide_area_servers();
 
-    if (c->daemonize)
+    if (c->daemonize) {
         daemon_retval_send(0);
+       retval_is_sent = 1;
+    }
 
     for (;;) {
         if ((r = avahi_simple_poll_iterate(simple_poll_api, -1)) < 0) {
@@ -814,7 +822,7 @@ finish:
         simple_poll_api = NULL;
     }
 
-    if (r != 0 && c->daemonize)
+    if (!retval_is_sent && c->daemonize)
         daemon_retval_send(1);
     
     return r;
@@ -963,7 +971,8 @@ static void enforce_rlimits(void) {
         set_one_rlimit(RLIMIT_NPROC, config.rlimit_nproc, "RLIMIT_NPROC");
 #endif
 
-#ifdef RLIMIT_MEMLOCK
+    /* the sysctl() call from iface-pfroute.c needs locked memory on FreeBSD */
+#if defined(RLIMIT_MEMLOCK) && !defined(__FreeBSD__)
     /* We don't need locked memory */
     set_one_rlimit(RLIMIT_MEMLOCK, 0, "RLIMIT_MEMLOCK");
 #endif
@@ -1012,7 +1021,8 @@ int main(int argc, char *argv[]) {
     config.use_chroot = 1;
 #endif
     config.modify_proc_title = 1;
-    
+
+    config.disable_user_service_publishing = 0;
     config.publish_dns_servers = NULL;
     config.publish_resolv_conf = 0;
     config.use_syslog = 0;