patches/avahi-07-daemon.diff
author yippi
Mon, 27 Sep 2010 21:07:51 +0000
changeset 20108 51df67ca9307
parent 16202 4dc494005b3f
child 21365 ead32bf37db7
permissions -rw-r--r--
I had these modules listed as being owned by me, but they are really owned by wangke, correcting.

--- /usr/tmp/clean/avahi-0.6.25/avahi-daemon/main.c	2008-12-12 21:36:15.000000000 +0000
+++ avahi-0.6.25/avahi-daemon/main.c	2009-08-04 08:17:02.469032000 +0100
@@ -75,7 +75,9 @@
 
 #include "setproctitle.h"
 #include "main.h"
+#ifndef HAVE_BONJOUR
 #include "simple-protocol.h"
+#endif
 #include "static-services.h"
 #include "static-hosts.h"
 #include "ini-file-parser.h"
@@ -132,11 +134,13 @@
 #define RESOLV_CONF "/etc/resolv.conf"
 #define BROWSE_DOMAINS_MAX 16
 
+#ifndef HAVE_BONJOUR
 static AvahiSEntryGroup *dns_servers_entry_group = NULL;
 static AvahiSEntryGroup *resolv_conf_entry_group = NULL;
 
 static char **resolv_conf_name_servers = NULL;
 static char **resolv_conf_search_domains = NULL;
+#endif
 
 static DaemonConfig config;
 
@@ -148,6 +152,7 @@
     return strlen(s) >= l && strncmp(s, prefix, l) == 0;
 }
 
+#ifndef HAVE_BONJOUR
 static int load_resolv_conf(void) {
     int ret = -1;
     FILE *f;
@@ -331,6 +336,7 @@
 
     avahi_server_set_browse_domains(avahi_server, l);
 }
+#endif
 
 static void server_callback(AvahiServer *s, AvahiServerState state, void *userdata) {
     DaemonConfig *c = userdata;
@@ -356,7 +362,7 @@
 
             static_service_add_to_server();
             static_hosts_add_to_server();
-
+#ifndef HAVE_BONJOUR
             remove_dns_server_entry_groups();
 
             if (c->publish_resolv_conf && resolv_conf_name_servers && resolv_conf_name_servers[0])
@@ -366,6 +372,7 @@
                 dns_servers_entry_group = add_dns_servers(s, dns_servers_entry_group, c->publish_dns_servers);
 
             simple_protocol_restart_queries();
+#endif
             break;
 
         case AVAHI_SERVER_COLLISION: {
@@ -375,7 +382,9 @@
 
             static_service_remove_from_server();
             static_hosts_remove_from_server();
+#ifndef HAVE_BONJOUR
             remove_dns_server_entry_groups();
+#endif
 
             n = avahi_alternative_host_name(avahi_server_get_host_name(s));
             avahi_log_warn("Host name conflict, retrying with <%s>", n);
@@ -397,7 +406,9 @@
 
             static_service_remove_from_server();
             static_hosts_remove_from_server();
+#ifndef HAVE_BONJOUR
             remove_dns_server_entry_groups();
+#endif
 
             break;
 
@@ -417,9 +428,11 @@
             "    -r --reload        Request a running daemon to reload static services\n"
             "    -c --check         Return 0 if a daemon is already running\n"
             "    -V --version       Show version\n"
+#ifndef HAVE_BONJOUR
             "    -f --file=FILE     Load the specified configuration file instead of\n"
             "                       "AVAHI_CONFIG_FILE"\n"
             "       --no-rlimits    Don't enforce resource limits\n"
+#endif
             "       --no-drop-root  Don't drop privileges\n"
 #ifdef ENABLE_CHROOT
             "       --no-chroot     Don't chroot()\n"
@@ -448,11 +461,15 @@
         { "daemonize",      no_argument,       NULL, 'D' },
         { "kill",           no_argument,       NULL, 'k' },
         { "version",        no_argument,       NULL, 'V' },
+#ifndef HAVE_BONJOUR
         { "file",           required_argument, NULL, 'f' },
+#endif
         { "reload",         no_argument,       NULL, 'r' },
         { "check",          no_argument,       NULL, 'c' },
         { "syslog",         no_argument,       NULL, 's' },
+#ifndef HAVE_BONJOUR
         { "no-rlimits",     no_argument,       NULL, OPTION_NO_RLIMITS },
+#endif
         { "no-drop-root",   no_argument,       NULL, OPTION_NO_DROP_ROOT },
 #ifdef ENABLE_CHROOT
         { "no-chroot",      no_argument,       NULL, OPTION_NO_CHROOT },
@@ -464,7 +481,11 @@
 
     assert(c);
 
+#ifdef HAVE_BONJOUR
+    while ((o = getopt_long(argc, argv, "hDkVrcs", long_options, NULL)) >= 0) {
+#else
     while ((o = getopt_long(argc, argv, "hDkVf:rcs", long_options, NULL)) >= 0) {
+#endif
 
         switch(o) {
             case 's':
@@ -482,6 +503,7 @@
             case 'V':
                 c->command = DAEMON_VERSION;
                 break;
+#ifndef HAVE_BONJOUR
             case 'f':
                 avahi_free(c->config_file);
                 c->config_file = avahi_strdup(optarg);
@@ -489,12 +511,15 @@
             case 'r':
                 c->command = DAEMON_RELOAD;
                 break;
+#endif
             case 'c':
                 c->command = DAEMON_CHECK;
                 break;
+#ifndef HAVE_BONJOUR
             case OPTION_NO_RLIMITS:
                 c->set_rlimits = 0;
                 break;
+#endif
             case OPTION_NO_DROP_ROOT:
                 c->drop_root = 0;
                 break;
@@ -528,6 +553,7 @@
     return *s == 'y' || *s == 'Y' || *s == '1' || *s == 't' || *s == 'T';
 }
 
+#ifndef HAVE_BONJOUR
 static int load_config_file(DaemonConfig *c) {
     int r = -1;
     AvahiIniFile *f;
@@ -739,6 +765,7 @@
 
     return r;
 }
+#endif
 
 static void log_function(AvahiLogLevel level, const char *txt) {
 
@@ -859,6 +886,7 @@
     static_service_add_to_server();
     static_hosts_add_to_server();
 
+#ifndef HAVE_BONJOUR
     if (resolv_conf_entry_group)
         avahi_s_entry_group_reset(resolv_conf_entry_group);
 
@@ -869,6 +897,7 @@
 
     if (config.publish_resolv_conf && resolv_conf_name_servers && resolv_conf_name_servers[0])
         resolv_conf_entry_group = add_dns_servers(avahi_server, resolv_conf_entry_group, resolv_conf_name_servers);
+#endif
 }
 
 #ifdef HAVE_INOTIFY
@@ -956,8 +985,12 @@
             break;
 
         case SIGUSR1:
+#ifdef HAVE_BONJOUR
+            avahi_log_info("Got SIGUSR1, ignoring recor.");
+#else
             avahi_log_info("Got SIGUSR1, dumping record data.");
             avahi_server_dump(avahi_server, dump, NULL);
+#endif
             break;
 
         default:
@@ -985,8 +1018,10 @@
 
     assert(c);
 
+#ifndef HAVE_BONJOUR
     if (!(nss_support = avahi_nss_support()))
         avahi_log_warn("WARNING: No NSS support for mDNS detected, consider installing nss-mdns!");
+#endif
 
     if (!(simple_poll_api = avahi_simple_poll_new())) {
         avahi_log_error("Failed to create main loop object.");
@@ -1005,8 +1040,10 @@
         goto finish;
     }
 
+#ifndef HAVE_BONJOUR
     if (simple_protocol_setup(poll_api) < 0)
         goto finish;
+#endif
 
 #ifdef HAVE_DBUS
     if (c->enable_dbus) {
@@ -1070,7 +1107,9 @@
     }
 #endif
 
+#ifndef HAVE_BONJOUR
     load_resolv_conf();
+#endif
 #ifdef ENABLE_CHROOT
     static_service_load(config.use_chroot);
     static_hosts_load(config.use_chroot);
@@ -1084,8 +1123,10 @@
         goto finish;
     }
 
+#ifndef HAVE_BONJOUR
     update_wide_area_servers();
     update_browse_domains();
+#endif
 
     if (c->daemonize) {
         daemon_retval_send(0);
@@ -1114,10 +1155,12 @@
 
     static_hosts_remove_from_server();
     static_hosts_free_all();
+#ifndef HAVE_BONJOUR
 
     remove_dns_server_entry_groups();
 
     simple_protocol_shutdown();
+#endif
 
 #ifdef HAVE_DBUS
     if (c->enable_dbus)
@@ -1428,8 +1471,10 @@
             goto finish;
         }
 
+#ifndef HAVE_BONJOUR
         if (load_config_file(&config) < 0)
             goto finish;
+#endif
 
         if (config.daemonize) {
             daemon_retval_init();
@@ -1516,9 +1561,13 @@
 
     avahi_server_config_free(&config.server_config);
     avahi_free(config.config_file);
+#ifdef HAVE_BONJOUR
+    assert(config.publish_dns_servers == NULL);
+#else
     avahi_strfreev(config.publish_dns_servers);
     avahi_strfreev(resolv_conf_name_servers);
     avahi_strfreev(resolv_conf_search_domains);
+#endif
 
     if (wrote_pid_file) {
 #ifdef ENABLE_CHROOT