1 --- /usr/tmp/clean/avahi-0.6.25/avahi-daemon/main.c 2008-12-12 21:36:15.000000000 +0000 2 +++ avahi-0.6.25/avahi-daemon/main.c 2009-08-04 08:17:02.469032000 +0100 3 @@ -75,7 +75,9 @@ 4 5 #include "setproctitle.h" 6 #include "main.h" 7 +#ifndef HAVE_BONJOUR 8 #include "simple-protocol.h" 9 +#endif 10 #include "static-services.h" 11 #include "static-hosts.h" 12 #include "ini-file-parser.h" 13 @@ -132,11 +134,13 @@ 14 #define RESOLV_CONF "/etc/resolv.conf" 15 #define BROWSE_DOMAINS_MAX 16 16 17 +#ifndef HAVE_BONJOUR 18 static AvahiSEntryGroup *dns_servers_entry_group = NULL; 19 static AvahiSEntryGroup *resolv_conf_entry_group = NULL; 20 21 static char **resolv_conf_name_servers = NULL; 22 static char **resolv_conf_search_domains = NULL; 23 +#endif 24 25 static DaemonConfig config; 26 27 @@ -148,6 +152,7 @@ 28 return strlen(s) >= l && strncmp(s, prefix, l) == 0; 29 } 30 31 +#ifndef HAVE_BONJOUR 32 static int load_resolv_conf(void) { 33 int ret = -1; 34 FILE *f; 35 @@ -331,6 +336,7 @@ 36 37 avahi_server_set_browse_domains(avahi_server, l); 38 } 39 +#endif 40 41 static void server_callback(AvahiServer *s, AvahiServerState state, void *userdata) { 42 DaemonConfig *c = userdata; 43 @@ -356,7 +362,7 @@ 44 45 static_service_add_to_server(); 46 static_hosts_add_to_server(); 47 - 48 +#ifndef HAVE_BONJOUR 49 remove_dns_server_entry_groups(); 50 51 if (c->publish_resolv_conf && resolv_conf_name_servers && resolv_conf_name_servers[0]) 52 @@ -366,6 +372,7 @@ 53 dns_servers_entry_group = add_dns_servers(s, dns_servers_entry_group, c->publish_dns_servers); 54 55 simple_protocol_restart_queries(); 56 +#endif 57 break; 58 59 case AVAHI_SERVER_COLLISION: { 60 @@ -375,7 +382,9 @@ 61 62 static_service_remove_from_server(); 63 static_hosts_remove_from_server(); 64 +#ifndef HAVE_BONJOUR 65 remove_dns_server_entry_groups(); 66 +#endif 67 68 n = avahi_alternative_host_name(avahi_server_get_host_name(s)); 69 avahi_log_warn("Host name conflict, retrying with <%s>", n); 70 @@ -397,7 +406,9 @@ 71 72 static_service_remove_from_server(); 73 static_hosts_remove_from_server(); 74 +#ifndef HAVE_BONJOUR 75 remove_dns_server_entry_groups(); 76 +#endif 77 78 break; 79 80 @@ -417,9 +428,11 @@ 81 " -r --reload Request a running daemon to reload static services\n" 82 " -c --check Return 0 if a daemon is already running\n" 83 " -V --version Show version\n" 84 +#ifndef HAVE_BONJOUR 85 " -f --file=FILE Load the specified configuration file instead of\n" 86 " "AVAHI_CONFIG_FILE"\n" 87 " --no-rlimits Don't enforce resource limits\n" 88 +#endif 89 " --no-drop-root Don't drop privileges\n" 90 #ifdef ENABLE_CHROOT 91 " --no-chroot Don't chroot()\n" 92 @@ -448,11 +461,15 @@ 93 { "daemonize", no_argument, NULL, 'D' }, 94 { "kill", no_argument, NULL, 'k' }, 95 { "version", no_argument, NULL, 'V' }, 96 +#ifndef HAVE_BONJOUR 97 { "file", required_argument, NULL, 'f' }, 98 +#endif 99 { "reload", no_argument, NULL, 'r' }, 100 { "check", no_argument, NULL, 'c' }, 101 { "syslog", no_argument, NULL, 's' }, 102 +#ifndef HAVE_BONJOUR 103 { "no-rlimits", no_argument, NULL, OPTION_NO_RLIMITS }, 104 +#endif 105 { "no-drop-root", no_argument, NULL, OPTION_NO_DROP_ROOT }, 106 #ifdef ENABLE_CHROOT 107 { "no-chroot", no_argument, NULL, OPTION_NO_CHROOT }, 108 @@ -464,7 +481,11 @@ 109 110 assert(c); 111 112 +#ifdef HAVE_BONJOUR 113 + while ((o = getopt_long(argc, argv, "hDkVrcs", long_options, NULL)) >= 0) { 114 +#else 115 while ((o = getopt_long(argc, argv, "hDkVf:rcs", long_options, NULL)) >= 0) { 116 +#endif 117 118 switch(o) { 119 case 's': 120 @@ -482,6 +503,7 @@ 121 case 'V': 122 c->command = DAEMON_VERSION; 123 break; 124 +#ifndef HAVE_BONJOUR 125 case 'f': 126 avahi_free(c->config_file); 127 c->config_file = avahi_strdup(optarg); 128 @@ -489,12 +511,15 @@ 129 case 'r': 130 c->command = DAEMON_RELOAD; 131 break; 132 +#endif 133 case 'c': 134 c->command = DAEMON_CHECK; 135 break; 136 +#ifndef HAVE_BONJOUR 137 case OPTION_NO_RLIMITS: 138 c->set_rlimits = 0; 139 break; 140 +#endif 141 case OPTION_NO_DROP_ROOT: 142 c->drop_root = 0; 143 break; 144 @@ -528,6 +553,7 @@ 145 return *s == 'y' || *s == 'Y' || *s == '1' || *s == 't' || *s == 'T'; 146 } 147 148 +#ifndef HAVE_BONJOUR 149 static int load_config_file(DaemonConfig *c) { 150 int r = -1; 151 AvahiIniFile *f; 152 @@ -739,6 +765,7 @@ 153 154 return r; 155 } 156 +#endif 157 158 static void log_function(AvahiLogLevel level, const char *txt) { 159 160 @@ -859,6 +886,7 @@ 161 static_service_add_to_server(); 162 static_hosts_add_to_server(); 163 164 +#ifndef HAVE_BONJOUR 165 if (resolv_conf_entry_group) 166 avahi_s_entry_group_reset(resolv_conf_entry_group); 167 168 @@ -869,6 +897,7 @@ 169 170 if (config.publish_resolv_conf && resolv_conf_name_servers && resolv_conf_name_servers[0]) 171 resolv_conf_entry_group = add_dns_servers(avahi_server, resolv_conf_entry_group, resolv_conf_name_servers); 172 +#endif 173 } 174 175 #ifdef HAVE_INOTIFY 176 @@ -956,8 +985,12 @@ 177 break; 178 179 case SIGUSR1: 180 +#ifdef HAVE_BONJOUR 181 + avahi_log_info("Got SIGUSR1, ignoring recor."); 182 +#else 183 avahi_log_info("Got SIGUSR1, dumping record data."); 184 avahi_server_dump(avahi_server, dump, NULL); 185 +#endif 186 break; 187 188 default: 189 @@ -985,8 +1018,10 @@ 190 191 assert(c); 192 193 +#ifndef HAVE_BONJOUR 194 if (!(nss_support = avahi_nss_support())) 195 avahi_log_warn("WARNING: No NSS support for mDNS detected, consider installing nss-mdns!"); 196 +#endif 197 198 if (!(simple_poll_api = avahi_simple_poll_new())) { 199 avahi_log_error("Failed to create main loop object."); 200 @@ -1005,8 +1040,10 @@ 201 goto finish; 202 } 203 204 +#ifndef HAVE_BONJOUR 205 if (simple_protocol_setup(poll_api) < 0) 206 goto finish; 207 +#endif 208 209 #ifdef HAVE_DBUS 210 if (c->enable_dbus) { 211 @@ -1070,7 +1107,9 @@ 212 } 213 #endif 214 215 +#ifndef HAVE_BONJOUR 216 load_resolv_conf(); 217 +#endif 218 #ifdef ENABLE_CHROOT 219 static_service_load(config.use_chroot); 220 static_hosts_load(config.use_chroot); 221 @@ -1084,8 +1123,10 @@ 222 goto finish; 223 } 224 225 +#ifndef HAVE_BONJOUR 226 update_wide_area_servers(); 227 update_browse_domains(); 228 +#endif 229 230 if (c->daemonize) { 231 daemon_retval_send(0); 232 @@ -1114,10 +1155,12 @@ 233 234 static_hosts_remove_from_server(); 235 static_hosts_free_all(); 236 +#ifndef HAVE_BONJOUR 237 238 remove_dns_server_entry_groups(); 239 240 simple_protocol_shutdown(); 241 +#endif 242 243 #ifdef HAVE_DBUS 244 if (c->enable_dbus) 245 @@ -1428,8 +1471,10 @@ 246 goto finish; 247 } 248 249 +#ifndef HAVE_BONJOUR 250 if (load_config_file(&config) < 0) 251 goto finish; 252 +#endif 253 254 if (config.daemonize) { 255 daemon_retval_init(); 256 @@ -1516,9 +1561,13 @@ 257 258 avahi_server_config_free(&config.server_config); 259 avahi_free(config.config_file); 260 +#ifdef HAVE_BONJOUR 261 + assert(config.publish_dns_servers == NULL); 262 +#else 263 avahi_strfreev(config.publish_dns_servers); 264 avahi_strfreev(resolv_conf_name_servers); 265 avahi_strfreev(resolv_conf_search_domains); 266 +#endif 267 268 if (wrote_pid_file) { 269 #ifdef ENABLE_CHROOT 270