#define BROWSE_DOMAINS_MAX 16
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;
static DaemonConfig config;
return strlen(s) >= l && strncmp(s, prefix, l) == 0;
static int load_resolv_conf(void) {
avahi_server_set_browse_domains(avahi_server, l);
avahi_string_list_free(l);
static void server_callback(AvahiServer *s, AvahiServerState state, void *userdata) {
DaemonConfig *c = userdata;
static_service_add_to_server();
static_hosts_add_to_server();
remove_dns_server_entry_groups();
if (c->publish_resolv_conf && resolv_conf_name_servers && resolv_conf_name_servers[0])
dns_servers_entry_group = add_dns_servers(s, dns_servers_entry_group, c->publish_dns_servers);
simple_protocol_restart_queries();
case AVAHI_SERVER_COLLISION: {
static_service_remove_from_server();
static_hosts_remove_from_server();
remove_dns_server_entry_groups();
n = avahi_alternative_host_name(avahi_server_get_host_name(s));
static_service_remove_from_server();
static_hosts_remove_from_server();
remove_dns_server_entry_groups();
" -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"
" -f --file=FILE Load the specified configuration file instead of\n"
" --no-rlimits Don't enforce resource limits\n"
" --no-drop-root Don't drop privileges\n"
" --no-chroot Don't chroot()\n"
{ "daemonize", no_argument, NULL, 'D' },
{ "kill", no_argument, NULL, 'k' },
{ "version", no_argument, NULL, 'V' },
{ "file", required_argument, NULL, 'f' },
{ "reload", no_argument, NULL, 'r' },
{ "check", no_argument, NULL, 'c' },
{ "syslog", no_argument, NULL, 's' },
{ "no-rlimits", no_argument, NULL, OPTION_NO_RLIMITS },
{ "no-drop-root", no_argument, NULL, OPTION_NO_DROP_ROOT },
{ "no-chroot", no_argument, NULL, OPTION_NO_CHROOT },
+ while ((o = getopt_long(argc, argv, "hDkVrcs", long_options, NULL)) >= 0) {
while ((o = getopt_long(argc, argv, "hDkVf:rcs", long_options, NULL)) >= 0) {
c->command = DAEMON_VERSION;
avahi_free(c->config_file);
c->config_file = avahi_strdup(optarg);
c->command = DAEMON_RELOAD;
c->command = DAEMON_CHECK;
case OPTION_NO_DROP_ROOT:
static int load_config_file(DaemonConfig *c) {
static void log_function(AvahiLogLevel level, const char *txt) {
static_service_add_to_server();
static_hosts_add_to_server();
if (resolv_conf_entry_group)
avahi_s_entry_group_reset(resolv_conf_entry_group);
resolv_conf_entry_group = add_dns_servers(avahi_server, resolv_conf_entry_group, resolv_conf_name_servers);
+ avahi_log_info("Got SIGUSR1, ignoring recor.");
avahi_log_info("Got SIGUSR1, dumping record data.");
avahi_server_dump(avahi_server, dump, NULL);
if (!(nss_support = avahi_nss_support()))
avahi_log_warn("WARNING: No NSS support for mDNS detected, consider installing nss-mdns!");
if (!(simple_poll_api = avahi_simple_poll_new())) {
avahi_log_error("Failed to create main loop object.");
if (simple_protocol_setup(poll_api) < 0)
update_wide_area_servers();
static_hosts_remove_from_server();
remove_dns_server_entry_groups();
simple_protocol_shutdown();
if (load_config_file(&config) < 0)
avahi_strfreev(resolv_conf_name_servers);
avahi_strfreev(resolv_conf_search_domains);
+ avahi_log_info("Failed to read "AVAHI_SERVICE_DIR".");
avahi_log_error("Failed to read "AVAHI_SERVICE_DIR".");