4 This file is part of avahi.
6 avahi is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
11 avahi is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with avahi; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
40 #include <sys/resource.h>
42 #include <libdaemon/dfork.h>
43 #include <libdaemon/dsignal.h>
44 #include <libdaemon/dlog.h>
45 #include <libdaemon/dpid.h>
47 #include <avahi-core/core.h>
48 #include <avahi-core/log.h>
49 #include <avahi-glib/glib-malloc.h>
50 #include <avahi-glib/glib-watch.h>
53 #include "simple-protocol.h"
54 #include "dbus-protocol.h"
55 #include "static-services.h"
57 AvahiServer *avahi_server = NULL;
69 AvahiServerConfig server_config;
70 DaemonCommand command;
76 gboolean publish_resolv_conf;
77 gchar ** publish_dns_servers;
81 gboolean rlimit_as_set, rlimit_core_set, rlimit_data_set, rlimit_fsize_set, rlimit_nofile_set, rlimit_stack_set;
82 rlim_t rlimit_as, rlimit_core, rlimit_data, rlimit_fsize, rlimit_nofile, rlimit_stack;
85 gboolean rlimit_nproc_set;
90 #define RESOLV_CONF "/etc/resolv.conf"
92 static AvahiSEntryGroup *dns_servers_entry_group = NULL;
93 static AvahiSEntryGroup *resolv_conf_entry_group = NULL;
95 static gchar **resolv_conf = NULL;
97 static DaemonConfig config;
99 #define MAX_NAME_SERVERS 10
101 static gint load_resolv_conf(const DaemonConfig *c) {
106 g_strfreev(resolv_conf);
109 if (!c->publish_resolv_conf)
112 if (!(f = fopen(RESOLV_CONF, "r"))) {
113 avahi_log_warn("Failed to open "RESOLV_CONF".");
117 resolv_conf = g_new0(gchar*, MAX_NAME_SERVERS+1);
119 while (!feof(f) && i < MAX_NAME_SERVERS) {
123 if (!(fgets(ln, sizeof(ln), f)))
126 ln[strcspn(ln, "\r\n#")] = 0;
127 p = ln + strspn(ln, "\t ");
129 if (g_str_has_prefix(p, "nameserver")) {
131 p += strspn(p, "\t ");
132 p[strcspn(p, "\t ")] = 0;
133 resolv_conf[i++] = strdup(p);
142 g_strfreev(resolv_conf);
152 static AvahiSEntryGroup* add_dns_servers(AvahiServer *s, AvahiSEntryGroup* g, gchar **l) {
159 g = avahi_s_entry_group_new(s, NULL, NULL);
161 g_assert(avahi_s_entry_group_is_empty(g));
163 for (p = l; *p; p++) {
166 if (!avahi_address_parse(*p, AF_UNSPEC, &a))
167 avahi_log_warn("Failed to parse address '%s', ignoring.", *p);
169 if (avahi_server_add_dns_server_address(s, g, -1, AF_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, &a, 53) < 0) {
170 avahi_s_entry_group_free(g);
171 avahi_log_error("Failed to add DNS server address: %s", avahi_strerror(avahi_server_errno(s)));
176 avahi_s_entry_group_commit(g);
181 static void remove_dns_server_entry_groups(void) {
183 if (resolv_conf_entry_group)
184 avahi_s_entry_group_reset(resolv_conf_entry_group);
186 if (dns_servers_entry_group)
187 avahi_s_entry_group_reset(dns_servers_entry_group);
190 static void server_callback(AvahiServer *s, AvahiServerState state, void *userdata) {
191 DaemonConfig *c = userdata;
198 dbus_protocol_server_state_changed(state);
201 if (state == AVAHI_SERVER_RUNNING) {
202 avahi_log_info("Server startup complete. Host name is <%s>", avahi_server_get_host_name_fqdn(s));
203 static_service_add_to_server();
205 remove_dns_server_entry_groups();
207 if (resolv_conf && resolv_conf[0])
208 resolv_conf_entry_group = add_dns_servers(s, resolv_conf_entry_group, resolv_conf);
210 if (c->publish_dns_servers && c->publish_dns_servers[0])
211 dns_servers_entry_group = add_dns_servers(s, dns_servers_entry_group, c->publish_dns_servers);
213 simple_protocol_restart_queries();
215 } else if (state == AVAHI_SERVER_COLLISION) {
218 static_service_remove_from_server();
220 remove_dns_server_entry_groups();
222 n = avahi_alternative_host_name(avahi_server_get_host_name(s));
223 avahi_log_warn("Host name conflict, retrying with <%s>", n);
224 avahi_server_set_host_name(s, n);
229 static void help(FILE *f, const gchar *argv0) {
232 " -h --help Show this help\n"
233 " -D --daemonize Daemonize after startup (implies -s)\n"
234 " -s --syslog Write log messages to syslog(3) instead of STDERR\n"
235 " -k --kill Kill a running daemon\n"
236 " -r --reload Request a running daemon to reload static services\n"
237 " -c --check Return 0 if a daemon is already running\n"
238 " -V --version Show version\n"
239 " -f --file=FILE Load the specified configuration file instead of\n"
240 " "AVAHI_CONFIG_FILE"\n"
241 " --no-rlimits Don't enforce resource limits\n"
242 " --no-drop-root Don't drop priviliges\n"
243 " --debug Increase verbosity\n",
248 static gint parse_command_line(DaemonConfig *c, int argc, char *argv[]) {
252 OPTION_NO_RLIMITS = 256,
257 static const struct option const long_options[] = {
258 { "help", no_argument, NULL, 'h' },
259 { "daemonize", no_argument, NULL, 'D' },
260 { "kill", no_argument, NULL, 'k' },
261 { "version", no_argument, NULL, 'V' },
262 { "file", required_argument, NULL, 'f' },
263 { "reload", no_argument, NULL, 'r' },
264 { "check", no_argument, NULL, 'c' },
265 { "syslog", no_argument, NULL, 's' },
266 { "no-rlimits", no_argument, NULL, OPTION_NO_RLIMITS },
267 { "no-drop-root", no_argument, NULL, OPTION_NO_DROP_ROOT },
268 { "debug", no_argument, NULL, OPTION_DEBUG },
275 while ((o = getopt_long(argc, argv, "hDkVf:rcs", long_options, NULL)) >= 0) {
279 c->use_syslog = TRUE;
282 c->command = DAEMON_HELP;
288 c->command = DAEMON_KILL;
291 c->command = DAEMON_VERSION;
294 g_free(c->config_file);
295 c->config_file = g_strdup(optarg);
298 c->command = DAEMON_RELOAD;
301 c->command = DAEMON_CHECK;
303 case OPTION_NO_RLIMITS:
304 c->no_rlimits = TRUE;
306 case OPTION_NO_DROP_ROOT:
307 c->drop_root = FALSE;
313 fprintf(stderr, "Invalid command line argument: %c\n", o);
319 fprintf(stderr, "Too many arguments\n");
326 static gboolean is_yes(const gchar *s) {
329 return *s == 'y' || *s == 'Y';
332 static gint load_config_file(DaemonConfig *c) {
336 gchar **groups = NULL, **g, **keys = NULL, *v = NULL;
340 f = g_key_file_new();
341 g_key_file_set_list_separator(f, ',');
343 if (!g_key_file_load_from_file(f, c->config_file ? c->config_file : AVAHI_CONFIG_FILE, G_KEY_FILE_NONE, &err)) {
344 fprintf(stderr, "Unable to read config file: %s\n", err->message);
348 groups = g_key_file_get_groups(f, NULL);
350 for (g = groups; *g; g++) {
351 if (g_strcasecmp(*g, "server") == 0) {
354 keys = g_key_file_get_keys(f, *g, NULL, NULL);
356 for (k = keys; *k; k++) {
358 v = g_key_file_get_value(f, *g, *k, NULL);
360 if (g_strcasecmp(*k, "host-name") == 0) {
361 g_free(c->server_config.host_name);
362 c->server_config.host_name = v;
364 } else if (g_strcasecmp(*k, "domain-name") == 0) {
365 g_free(c->server_config.domain_name);
366 c->server_config.domain_name = v;
368 } else if (g_strcasecmp(*k, "use-ipv4") == 0)
369 c->server_config.use_ipv4 = is_yes(v);
370 else if (g_strcasecmp(*k, "use-ipv6") == 0)
371 c->server_config.use_ipv6 = is_yes(v);
372 else if (g_strcasecmp(*k, "check-response-ttl") == 0)
373 c->server_config.check_response_ttl = is_yes(v);
374 else if (g_strcasecmp(*k, "use-iff-running") == 0)
375 c->server_config.use_iff_running = is_yes(v);
376 else if (g_strcasecmp(*k, "enable-dbus") == 0)
377 c->enable_dbus = is_yes(v);
378 else if (g_strcasecmp(*k, "drop-root") == 0)
379 c->drop_root = is_yes(v);
381 fprintf(stderr, "Invalid configuration key \"%s\" in group \"%s\"\n", *k, *g);
392 } else if (g_strcasecmp(*g, "publish") == 0) {
395 keys = g_key_file_get_keys(f, *g, NULL, NULL);
397 for (k = keys; *k; k++) {
399 v = g_key_file_get_string(f, *g, *k, NULL);
401 if (g_strcasecmp(*k, "publish-addresses") == 0)
402 c->server_config.publish_addresses = is_yes(v);
403 else if (g_strcasecmp(*k, "publish-hinfo") == 0)
404 c->server_config.publish_hinfo = is_yes(v);
405 else if (g_strcasecmp(*k, "publish-workstation") == 0)
406 c->server_config.publish_workstation = is_yes(v);
407 else if (g_strcasecmp(*k, "publish-domain") == 0)
408 c->server_config.publish_domain = is_yes(v);
409 else if (g_strcasecmp(*k, "publish-resolv-conf-dns-servers") == 0)
410 c->publish_resolv_conf = is_yes(v);
411 else if (g_strcasecmp(*k, "publish-dns-servers") == 0) {
412 g_strfreev(c->publish_dns_servers);
413 c->publish_dns_servers = g_key_file_get_string_list(f, *g, *k, NULL, NULL);
415 fprintf(stderr, "Invalid configuration key \"%s\" in group \"%s\"\n", *k, *g);
426 } else if (g_strcasecmp(*g, "reflector") == 0) {
429 keys = g_key_file_get_keys(f, *g, NULL, NULL);
431 for (k = keys; *k; k++) {
433 v = g_key_file_get_string(f, *g, *k, NULL);
435 if (g_strcasecmp(*k, "enable-reflector") == 0)
436 c->server_config.enable_reflector = is_yes(v);
437 else if (g_strcasecmp(*k, "reflect-ipv") == 0)
438 c->server_config.reflect_ipv = is_yes(v);
440 fprintf(stderr, "Invalid configuration key \"%s\" in group \"%s\"\n", *k, *g);
451 } else if (g_strcasecmp(*g, "rlimits") == 0) {
454 keys = g_key_file_get_keys(f, *g, NULL, NULL);
456 for (k = keys; *k; k++) {
458 v = g_key_file_get_string(f, *g, *k, NULL);
460 if (g_strcasecmp(*k, "rlimit-as") == 0) {
461 c->rlimit_as_set = TRUE;
462 c->rlimit_as = atoi(v);
463 } else if (g_strcasecmp(*k, "rlimit-core") == 0) {
464 c->rlimit_core_set = TRUE;
465 c->rlimit_core = atoi(v);
466 } else if (g_strcasecmp(*k, "rlimit-data") == 0) {
467 c->rlimit_data_set = TRUE;
468 c->rlimit_data = atoi(v);
469 } else if (g_strcasecmp(*k, "rlimit-fsize") == 0) {
470 c->rlimit_fsize_set = TRUE;
471 c->rlimit_fsize = atoi(v);
472 } else if (g_strcasecmp(*k, "rlimit-nofile") == 0) {
473 c->rlimit_nofile_set = TRUE;
474 c->rlimit_nofile = atoi(v);
475 } else if (g_strcasecmp(*k, "rlimit-stack") == 0) {
476 c->rlimit_stack_set = TRUE;
477 c->rlimit_stack = atoi(v);
479 } else if (g_strcasecmp(*k, "rlimit-nproc") == 0) {
480 c->rlimit_nproc_set = TRUE;
481 c->rlimit_nproc = atoi(v);
484 fprintf(stderr, "Invalid configuration key \"%s\" in group \"%s\"\n", *k, *g);
496 fprintf(stderr, "Invalid configuration file group \"%s\".\n", *g);
518 static void log_function(AvahiLogLevel level, const gchar *txt) {
520 static const int const log_level_map[] = {
528 g_assert(level < AVAHI_LOG_LEVEL_MAX);
531 if (!config.debug && level == AVAHI_LOG_DEBUG)
534 daemon_log(log_level_map[level], "%s", txt);
537 static void dump(const gchar *text, gpointer userdata) {
538 avahi_log_info("%s", text);
541 static gboolean signal_callback(GIOChannel *source, GIOCondition condition, gpointer data) {
543 GMainLoop *loop = data;
548 if ((sig = daemon_signal_next()) <= 0) {
549 avahi_log_error("daemon_signal_next() failed");
559 sig == SIGINT ? "SIGINT" :
560 (sig == SIGQUIT ? "SIGQUIT" : "SIGTERM"));
561 g_main_loop_quit(loop);
565 avahi_log_info("Got SIGHUP, reloading.");
566 static_service_load();
567 static_service_add_to_server();
569 if (resolv_conf_entry_group)
570 avahi_s_entry_group_reset(resolv_conf_entry_group);
572 load_resolv_conf(&config);
574 if (resolv_conf && resolv_conf[0])
575 resolv_conf_entry_group = add_dns_servers(avahi_server, resolv_conf_entry_group, resolv_conf);
580 avahi_log_info("Got SIGUSR1, dumping record data.");
581 avahi_server_dump(avahi_server, dump, NULL);
585 avahi_log_warn("Got spurious signal, ignoring.");
592 static gint run_server(DaemonConfig *c) {
593 GMainLoop *loop = NULL;
595 GIOChannel *io = NULL;
596 guint watch_id = (guint) -1;
598 AvahiGLibPoll *poll_api;
602 poll_api = avahi_glib_poll_new(NULL);
603 loop = g_main_loop_new(NULL, FALSE);
605 if (daemon_signal_init(SIGINT, SIGQUIT, SIGHUP, SIGTERM, SIGUSR1, 0) < 0) {
606 avahi_log_error("Could not register signal handlers (%s).", strerror(errno));
610 if (!(io = g_io_channel_unix_new(daemon_signal_fd()))) {
611 avahi_log_error( "Failed to create signal io channel.");
615 g_io_channel_set_close_on_unref(io, FALSE);
616 watch_id = g_io_add_watch(io, G_IO_IN, signal_callback, loop);
618 if (simple_protocol_setup(NULL) < 0)
623 if (dbus_protocol_setup(loop) < 0)
627 if (!(avahi_server = avahi_server_new(avahi_glib_poll_get(poll_api), &c->server_config, server_callback, c, &error))) {
628 avahi_log_error("Failed to create server: %s", avahi_strerror(error));
634 static_service_load();
637 daemon_retval_send(0);
641 g_main_loop_run(loop);
645 static_service_remove_from_server();
646 static_service_free_all();
647 remove_dns_server_entry_groups();
649 simple_protocol_shutdown();
653 dbus_protocol_shutdown();
657 avahi_server_free(avahi_server);
659 daemon_signal_done();
661 if (watch_id != (guint) -1)
662 g_source_remove(watch_id);
665 g_io_channel_unref(io);
668 avahi_glib_poll_free(poll_api);
671 g_main_loop_unref(loop);
673 if (r != 0 && c->daemonize)
674 daemon_retval_send(1);
679 static gint drop_root(void) {
684 if (!(pw = getpwnam(AVAHI_USER))) {
685 avahi_log_error( "Failed to find user '"AVAHI_USER"'.");
689 if (!(gr = getgrnam(AVAHI_GROUP))) {
690 avahi_log_error( "Failed to find group '"AVAHI_GROUP"'.");
694 avahi_log_info("Found user '"AVAHI_USER"' (UID %lu) and group '"AVAHI_GROUP"' (GID %lu).", (unsigned long) pw->pw_uid, (unsigned long) gr->gr_gid);
696 if (initgroups(AVAHI_USER, gr->gr_gid) != 0) {
697 avahi_log_error("Failed to change group list: %s", strerror(errno));
701 #if defined(HAVE_SETRESGID)
702 r = setresgid(gr->gr_gid, gr->gr_gid, gr->gr_gid);
703 #elif defined(HAVE_SETREGID)
704 r = setregid(gr->gr_gid, gr->gr_gid);
706 if ((r = setgid(gr->gr_gid)) >= 0)
707 r = setegid(gr->gr_gid);
711 avahi_log_error("Failed to change GID: %s", strerror(errno));
715 #if defined(HAVE_SETRESUID)
716 r = setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid);
717 #elif defined(HAVE_SETREUID)
718 r = setreuid(pw->pw_uid, pw->pw_uid);
720 if ((r = setuid(pw->pw_uid)) >= 0)
721 r = seteuid(pw->pw_uid);
725 avahi_log_error("Failed to change UID: %s", strerror(errno));
729 g_setenv("USER", pw->pw_name, 1);
730 g_setenv("LOGNAME", pw->pw_name, 1);
731 g_setenv("HOME", pw->pw_dir, 1);
733 avahi_log_info("Successfully dropped root privileges.");
738 static const char* pid_file_proc(void) {
739 return AVAHI_DAEMON_RUNTIME_DIR"/pid";
742 static gint make_runtime_dir(void) {
745 gboolean reset_umask = FALSE;
750 if (!(pw = getpwnam(AVAHI_USER))) {
751 avahi_log_error( "Failed to find user '"AVAHI_USER"'.");
755 if (!(gr = getgrnam(AVAHI_GROUP))) {
756 avahi_log_error( "Failed to find group '"AVAHI_GROUP"'.");
763 if (mkdir(AVAHI_DAEMON_RUNTIME_DIR, 0755) < 0 && errno != EEXIST) {
764 avahi_log_error("mkdir(\""AVAHI_DAEMON_RUNTIME_DIR"\"): %s", strerror(errno));
768 chown(AVAHI_DAEMON_RUNTIME_DIR, pw->pw_uid, gr->gr_gid);
770 if (stat(AVAHI_DAEMON_RUNTIME_DIR, &st) < 0) {
771 avahi_log_error("stat(): %s\n", strerror(errno));
775 if (!S_ISDIR(st.st_mode) || st.st_uid != pw->pw_uid || st.st_gid != gr->gr_gid) {
776 avahi_log_error("Failed to create runtime directory "AVAHI_DAEMON_RUNTIME_DIR".");
788 static void set_one_rlimit(int resource, rlim_t limit, const gchar *name) {
790 rl.rlim_cur = rl.rlim_max = limit;
792 if (setrlimit(resource, &rl) < 0)
793 avahi_log_warn("setrlimit(%s, {%u, %u}) failed: %s", name, (unsigned) limit, (unsigned) limit, strerror(errno));
796 static void enforce_rlimits(void) {
798 if (config.rlimit_as_set)
799 set_one_rlimit(RLIMIT_AS, config.rlimit_as, "RLIMIT_AS");
800 if (config.rlimit_core_set)
801 set_one_rlimit(RLIMIT_CORE, config.rlimit_core, "RLIMIT_CORE");
802 if (config.rlimit_data_set)
803 set_one_rlimit(RLIMIT_DATA, config.rlimit_data, "RLIMIT_DATA");
804 if (config.rlimit_fsize_set)
805 set_one_rlimit(RLIMIT_FSIZE, config.rlimit_fsize, "RLIMIT_FSIZE");
806 if (config.rlimit_nofile_set)
807 set_one_rlimit(RLIMIT_NOFILE, config.rlimit_nofile, "RLIMIT_NOFILE");
808 if (config.rlimit_stack_set)
809 set_one_rlimit(RLIMIT_STACK, config.rlimit_stack, "RLIMIT_STACK");
811 if (config.rlimit_nproc_set)
812 set_one_rlimit(RLIMIT_NPROC, config.rlimit_nproc, "RLIMIT_NPROC");
815 #ifdef RLIMIT_MEMLOCK
816 /* We don't need locked memory */
817 set_one_rlimit(RLIMIT_MEMLOCK, 0, "RLIMIT_MEMLOCK");
821 #define RANDOM_DEVICE "/dev/urandom"
823 static void init_rand_seed(void) {
827 /* Try to initialize seed from /dev/urandom, to make it a little
828 * less predictable, and to make sure that multiple machines
829 * booted at the same time choose different random seeds. */
830 if ((fd = open(RANDOM_DEVICE, O_RDONLY)) >= 0) {
831 read(fd, &seed, sizeof(seed));
835 /* If the initialization failed by some reason, we add the time to the seed*/
836 seed |= (unsigned) time(NULL);
841 int main(int argc, char *argv[]) {
844 gboolean wrote_pid_file = FALSE;
846 avahi_set_log_function(log_function);
847 avahi_set_allocator(avahi_glib_allocator());
851 avahi_server_config_init(&config.server_config);
852 config.command = DAEMON_RUN;
853 config.daemonize = FALSE;
854 config.config_file = NULL;
855 config.enable_dbus = TRUE;
856 config.drop_root = TRUE;
857 config.publish_dns_servers = NULL;
858 config.publish_resolv_conf = FALSE;
859 config.use_syslog = FALSE;
860 config.no_rlimits = FALSE;
861 config.debug = FALSE;
863 config.rlimit_as_set = FALSE;
864 config.rlimit_core_set = FALSE;
865 config.rlimit_data_set = FALSE;
866 config.rlimit_fsize_set = FALSE;
867 config.rlimit_nofile_set = FALSE;
868 config.rlimit_stack_set = FALSE;
870 config.rlimit_nproc_set = FALSE;
873 if ((argv0 = strrchr(argv[0], '/')))
878 daemon_pid_file_ident = (const char *) argv0;
879 daemon_log_ident = (char*) argv0;
880 daemon_pid_file_proc = pid_file_proc;
882 if (parse_command_line(&config, argc, argv) < 0)
885 if (config.command == DAEMON_HELP) {
888 } else if (config.command == DAEMON_VERSION) {
889 printf("%s "PACKAGE_VERSION"\n", argv0);
891 } else if (config.command == DAEMON_KILL) {
892 if (daemon_pid_file_kill_wait(SIGTERM, 5) < 0) {
893 avahi_log_warn("Failed to kill daemon: %s", strerror(errno));
899 } else if (config.command == DAEMON_RELOAD) {
900 if (daemon_pid_file_kill(SIGHUP) < 0) {
901 avahi_log_warn("Failed to kill daemon: %s", strerror(errno));
907 } else if (config.command == DAEMON_CHECK)
908 r = (daemon_pid_file_is_running() >= 0) ? 0 : 1;
909 else if (config.command == DAEMON_RUN) {
912 if (getuid() != 0 && config.drop_root) {
913 avahi_log_error("This program is intended to be run as root.");
917 if ((pid = daemon_pid_file_is_running()) >= 0) {
918 avahi_log_error("Daemon already running on PID %u", pid);
922 if (load_config_file(&config) < 0)
925 if (config.daemonize) {
926 daemon_retval_init();
928 if ((pid = daemon_fork()) < 0)
934 if ((ret = daemon_retval_wait(20)) < 0) {
935 avahi_log_error("Could not recieve return value from daemon process.");
946 if (config.use_syslog || config.daemonize)
947 daemon_log_use = DAEMON_LOG_SYSLOG;
949 if (make_runtime_dir() < 0)
952 if (config.drop_root) {
957 if (daemon_pid_file_create() < 0) {
958 avahi_log_error("Failed to create PID file: %s", strerror(errno));
960 if (config.daemonize)
961 daemon_retval_send(1);
964 wrote_pid_file = TRUE;
966 if (!config.no_rlimits)
971 avahi_log_info("%s "PACKAGE_VERSION" starting up.\n", argv0);
973 if (run_server(&config) == 0)
979 if (config.daemonize)
980 daemon_retval_done();
982 avahi_server_config_free(&config.server_config);
983 g_free(config.config_file);
984 g_strfreev(config.publish_dns_servers);
985 g_strfreev(resolv_conf);
988 daemon_pid_file_remove();