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;
196 /** This function is possibly called before the global variable
197 * avahi_server has been set, therefore we do it explicitly */
203 dbus_protocol_server_state_changed(state);
206 if (state == AVAHI_SERVER_RUNNING) {
207 avahi_log_info("Server startup complete. Host name is <%s>", avahi_server_get_host_name_fqdn(s));
208 static_service_add_to_server();
210 remove_dns_server_entry_groups();
212 if (resolv_conf && resolv_conf[0])
213 resolv_conf_entry_group = add_dns_servers(s, resolv_conf_entry_group, resolv_conf);
215 if (c->publish_dns_servers && c->publish_dns_servers[0])
216 dns_servers_entry_group = add_dns_servers(s, dns_servers_entry_group, c->publish_dns_servers);
218 simple_protocol_restart_queries();
220 } else if (state == AVAHI_SERVER_COLLISION) {
223 static_service_remove_from_server();
225 remove_dns_server_entry_groups();
227 n = avahi_alternative_host_name(avahi_server_get_host_name(s));
228 avahi_log_warn("Host name conflict, retrying with <%s>", n);
229 avahi_server_set_host_name(s, n);
234 static void help(FILE *f, const gchar *argv0) {
237 " -h --help Show this help\n"
238 " -D --daemonize Daemonize after startup (implies -s)\n"
239 " -s --syslog Write log messages to syslog(3) instead of STDERR\n"
240 " -k --kill Kill a running daemon\n"
241 " -r --reload Request a running daemon to reload static services\n"
242 " -c --check Return 0 if a daemon is already running\n"
243 " -V --version Show version\n"
244 " -f --file=FILE Load the specified configuration file instead of\n"
245 " "AVAHI_CONFIG_FILE"\n"
246 " --no-rlimits Don't enforce resource limits\n"
247 " --no-drop-root Don't drop priviliges\n"
248 " --debug Increase verbosity\n",
253 static gint parse_command_line(DaemonConfig *c, int argc, char *argv[]) {
257 OPTION_NO_RLIMITS = 256,
262 static const struct option const long_options[] = {
263 { "help", no_argument, NULL, 'h' },
264 { "daemonize", no_argument, NULL, 'D' },
265 { "kill", no_argument, NULL, 'k' },
266 { "version", no_argument, NULL, 'V' },
267 { "file", required_argument, NULL, 'f' },
268 { "reload", no_argument, NULL, 'r' },
269 { "check", no_argument, NULL, 'c' },
270 { "syslog", no_argument, NULL, 's' },
271 { "no-rlimits", no_argument, NULL, OPTION_NO_RLIMITS },
272 { "no-drop-root", no_argument, NULL, OPTION_NO_DROP_ROOT },
273 { "debug", no_argument, NULL, OPTION_DEBUG },
280 while ((o = getopt_long(argc, argv, "hDkVf:rcs", long_options, NULL)) >= 0) {
284 c->use_syslog = TRUE;
287 c->command = DAEMON_HELP;
293 c->command = DAEMON_KILL;
296 c->command = DAEMON_VERSION;
299 g_free(c->config_file);
300 c->config_file = g_strdup(optarg);
303 c->command = DAEMON_RELOAD;
306 c->command = DAEMON_CHECK;
308 case OPTION_NO_RLIMITS:
309 c->no_rlimits = TRUE;
311 case OPTION_NO_DROP_ROOT:
312 c->drop_root = FALSE;
318 fprintf(stderr, "Invalid command line argument: %c\n", o);
324 fprintf(stderr, "Too many arguments\n");
331 static gboolean is_yes(const gchar *s) {
334 return *s == 'y' || *s == 'Y';
337 static gint load_config_file(DaemonConfig *c) {
341 gchar **groups = NULL, **g, **keys = NULL, *v = NULL;
345 f = g_key_file_new();
346 g_key_file_set_list_separator(f, ',');
348 if (!g_key_file_load_from_file(f, c->config_file ? c->config_file : AVAHI_CONFIG_FILE, G_KEY_FILE_NONE, &err)) {
349 fprintf(stderr, "Unable to read config file: %s\n", err->message);
353 groups = g_key_file_get_groups(f, NULL);
355 for (g = groups; *g; g++) {
356 if (g_strcasecmp(*g, "server") == 0) {
359 keys = g_key_file_get_keys(f, *g, NULL, NULL);
361 for (k = keys; *k; k++) {
363 v = g_key_file_get_value(f, *g, *k, NULL);
365 if (g_strcasecmp(*k, "host-name") == 0) {
366 g_free(c->server_config.host_name);
367 c->server_config.host_name = v;
369 } else if (g_strcasecmp(*k, "domain-name") == 0) {
370 g_free(c->server_config.domain_name);
371 c->server_config.domain_name = v;
373 } else if (g_strcasecmp(*k, "use-ipv4") == 0)
374 c->server_config.use_ipv4 = is_yes(v);
375 else if (g_strcasecmp(*k, "use-ipv6") == 0)
376 c->server_config.use_ipv6 = is_yes(v);
377 else if (g_strcasecmp(*k, "check-response-ttl") == 0)
378 c->server_config.check_response_ttl = is_yes(v);
379 else if (g_strcasecmp(*k, "use-iff-running") == 0)
380 c->server_config.use_iff_running = is_yes(v);
381 else if (g_strcasecmp(*k, "enable-dbus") == 0)
382 c->enable_dbus = is_yes(v);
383 else if (g_strcasecmp(*k, "drop-root") == 0)
384 c->drop_root = is_yes(v);
386 fprintf(stderr, "Invalid configuration key \"%s\" in group \"%s\"\n", *k, *g);
397 } else if (g_strcasecmp(*g, "publish") == 0) {
400 keys = g_key_file_get_keys(f, *g, NULL, NULL);
402 for (k = keys; *k; k++) {
404 v = g_key_file_get_string(f, *g, *k, NULL);
406 if (g_strcasecmp(*k, "publish-addresses") == 0)
407 c->server_config.publish_addresses = is_yes(v);
408 else if (g_strcasecmp(*k, "publish-hinfo") == 0)
409 c->server_config.publish_hinfo = is_yes(v);
410 else if (g_strcasecmp(*k, "publish-workstation") == 0)
411 c->server_config.publish_workstation = is_yes(v);
412 else if (g_strcasecmp(*k, "publish-domain") == 0)
413 c->server_config.publish_domain = is_yes(v);
414 else if (g_strcasecmp(*k, "publish-resolv-conf-dns-servers") == 0)
415 c->publish_resolv_conf = is_yes(v);
416 else if (g_strcasecmp(*k, "publish-dns-servers") == 0) {
417 g_strfreev(c->publish_dns_servers);
418 c->publish_dns_servers = g_key_file_get_string_list(f, *g, *k, NULL, NULL);
420 fprintf(stderr, "Invalid configuration key \"%s\" in group \"%s\"\n", *k, *g);
431 } else if (g_strcasecmp(*g, "reflector") == 0) {
434 keys = g_key_file_get_keys(f, *g, NULL, NULL);
436 for (k = keys; *k; k++) {
438 v = g_key_file_get_string(f, *g, *k, NULL);
440 if (g_strcasecmp(*k, "enable-reflector") == 0)
441 c->server_config.enable_reflector = is_yes(v);
442 else if (g_strcasecmp(*k, "reflect-ipv") == 0)
443 c->server_config.reflect_ipv = is_yes(v);
445 fprintf(stderr, "Invalid configuration key \"%s\" in group \"%s\"\n", *k, *g);
456 } else if (g_strcasecmp(*g, "rlimits") == 0) {
459 keys = g_key_file_get_keys(f, *g, NULL, NULL);
461 for (k = keys; *k; k++) {
463 v = g_key_file_get_string(f, *g, *k, NULL);
465 if (g_strcasecmp(*k, "rlimit-as") == 0) {
466 c->rlimit_as_set = TRUE;
467 c->rlimit_as = atoi(v);
468 } else if (g_strcasecmp(*k, "rlimit-core") == 0) {
469 c->rlimit_core_set = TRUE;
470 c->rlimit_core = atoi(v);
471 } else if (g_strcasecmp(*k, "rlimit-data") == 0) {
472 c->rlimit_data_set = TRUE;
473 c->rlimit_data = atoi(v);
474 } else if (g_strcasecmp(*k, "rlimit-fsize") == 0) {
475 c->rlimit_fsize_set = TRUE;
476 c->rlimit_fsize = atoi(v);
477 } else if (g_strcasecmp(*k, "rlimit-nofile") == 0) {
478 c->rlimit_nofile_set = TRUE;
479 c->rlimit_nofile = atoi(v);
480 } else if (g_strcasecmp(*k, "rlimit-stack") == 0) {
481 c->rlimit_stack_set = TRUE;
482 c->rlimit_stack = atoi(v);
484 } else if (g_strcasecmp(*k, "rlimit-nproc") == 0) {
485 c->rlimit_nproc_set = TRUE;
486 c->rlimit_nproc = atoi(v);
489 fprintf(stderr, "Invalid configuration key \"%s\" in group \"%s\"\n", *k, *g);
501 fprintf(stderr, "Invalid configuration file group \"%s\".\n", *g);
523 static void log_function(AvahiLogLevel level, const gchar *txt) {
525 static const int const log_level_map[] = {
533 g_assert(level < AVAHI_LOG_LEVEL_MAX);
536 if (!config.debug && level == AVAHI_LOG_DEBUG)
539 daemon_log(log_level_map[level], "%s", txt);
542 static void dump(const gchar *text, gpointer userdata) {
543 avahi_log_info("%s", text);
546 static gboolean signal_callback(GIOChannel *source, GIOCondition condition, gpointer data) {
548 GMainLoop *loop = data;
553 if ((sig = daemon_signal_next()) <= 0) {
554 avahi_log_error("daemon_signal_next() failed");
564 sig == SIGINT ? "SIGINT" :
565 (sig == SIGQUIT ? "SIGQUIT" : "SIGTERM"));
566 g_main_loop_quit(loop);
570 avahi_log_info("Got SIGHUP, reloading.");
571 static_service_load();
572 static_service_add_to_server();
574 if (resolv_conf_entry_group)
575 avahi_s_entry_group_reset(resolv_conf_entry_group);
577 load_resolv_conf(&config);
579 if (resolv_conf && resolv_conf[0])
580 resolv_conf_entry_group = add_dns_servers(avahi_server, resolv_conf_entry_group, resolv_conf);
585 avahi_log_info("Got SIGUSR1, dumping record data.");
586 avahi_server_dump(avahi_server, dump, NULL);
590 avahi_log_warn("Got spurious signal, ignoring.");
597 static gint run_server(DaemonConfig *c) {
598 GMainLoop *loop = NULL;
600 GIOChannel *io = NULL;
601 guint watch_id = (guint) -1;
603 AvahiGLibPoll *poll_api;
607 poll_api = avahi_glib_poll_new(NULL);
608 loop = g_main_loop_new(NULL, FALSE);
610 if (daemon_signal_init(SIGINT, SIGQUIT, SIGHUP, SIGTERM, SIGUSR1, 0) < 0) {
611 avahi_log_error("Could not register signal handlers (%s).", strerror(errno));
615 if (!(io = g_io_channel_unix_new(daemon_signal_fd()))) {
616 avahi_log_error( "Failed to create signal io channel.");
620 g_io_channel_set_close_on_unref(io, FALSE);
621 watch_id = g_io_add_watch(io, G_IO_IN, signal_callback, loop);
623 if (simple_protocol_setup(NULL) < 0)
628 if (dbus_protocol_setup(loop) < 0)
633 static_service_load();
635 if (!(avahi_server = avahi_server_new(avahi_glib_poll_get(poll_api), &c->server_config, server_callback, c, &error))) {
636 avahi_log_error("Failed to create server: %s", avahi_strerror(error));
642 daemon_retval_send(0);
646 g_main_loop_run(loop);
650 static_service_remove_from_server();
651 static_service_free_all();
652 remove_dns_server_entry_groups();
654 simple_protocol_shutdown();
658 dbus_protocol_shutdown();
662 avahi_server_free(avahi_server);
664 daemon_signal_done();
666 if (watch_id != (guint) -1)
667 g_source_remove(watch_id);
670 g_io_channel_unref(io);
673 avahi_glib_poll_free(poll_api);
676 g_main_loop_unref(loop);
678 if (r != 0 && c->daemonize)
679 daemon_retval_send(1);
684 static gint drop_root(void) {
689 if (!(pw = getpwnam(AVAHI_USER))) {
690 avahi_log_error( "Failed to find user '"AVAHI_USER"'.");
694 if (!(gr = getgrnam(AVAHI_GROUP))) {
695 avahi_log_error( "Failed to find group '"AVAHI_GROUP"'.");
699 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);
701 if (initgroups(AVAHI_USER, gr->gr_gid) != 0) {
702 avahi_log_error("Failed to change group list: %s", strerror(errno));
706 #if defined(HAVE_SETRESGID)
707 r = setresgid(gr->gr_gid, gr->gr_gid, gr->gr_gid);
708 #elif defined(HAVE_SETREGID)
709 r = setregid(gr->gr_gid, gr->gr_gid);
711 if ((r = setgid(gr->gr_gid)) >= 0)
712 r = setegid(gr->gr_gid);
716 avahi_log_error("Failed to change GID: %s", strerror(errno));
720 #if defined(HAVE_SETRESUID)
721 r = setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid);
722 #elif defined(HAVE_SETREUID)
723 r = setreuid(pw->pw_uid, pw->pw_uid);
725 if ((r = setuid(pw->pw_uid)) >= 0)
726 r = seteuid(pw->pw_uid);
730 avahi_log_error("Failed to change UID: %s", strerror(errno));
734 g_setenv("USER", pw->pw_name, 1);
735 g_setenv("LOGNAME", pw->pw_name, 1);
736 g_setenv("HOME", pw->pw_dir, 1);
738 avahi_log_info("Successfully dropped root privileges.");
743 static const char* pid_file_proc(void) {
744 return AVAHI_DAEMON_RUNTIME_DIR"/pid";
747 static gint make_runtime_dir(void) {
750 gboolean reset_umask = FALSE;
755 if (!(pw = getpwnam(AVAHI_USER))) {
756 avahi_log_error( "Failed to find user '"AVAHI_USER"'.");
760 if (!(gr = getgrnam(AVAHI_GROUP))) {
761 avahi_log_error( "Failed to find group '"AVAHI_GROUP"'.");
768 if (mkdir(AVAHI_DAEMON_RUNTIME_DIR, 0755) < 0 && errno != EEXIST) {
769 avahi_log_error("mkdir(\""AVAHI_DAEMON_RUNTIME_DIR"\"): %s", strerror(errno));
773 chown(AVAHI_DAEMON_RUNTIME_DIR, pw->pw_uid, gr->gr_gid);
775 if (stat(AVAHI_DAEMON_RUNTIME_DIR, &st) < 0) {
776 avahi_log_error("stat(): %s\n", strerror(errno));
780 if (!S_ISDIR(st.st_mode) || st.st_uid != pw->pw_uid || st.st_gid != gr->gr_gid) {
781 avahi_log_error("Failed to create runtime directory "AVAHI_DAEMON_RUNTIME_DIR".");
793 static void set_one_rlimit(int resource, rlim_t limit, const gchar *name) {
795 rl.rlim_cur = rl.rlim_max = limit;
797 if (setrlimit(resource, &rl) < 0)
798 avahi_log_warn("setrlimit(%s, {%u, %u}) failed: %s", name, (unsigned) limit, (unsigned) limit, strerror(errno));
801 static void enforce_rlimits(void) {
803 if (config.rlimit_as_set)
804 set_one_rlimit(RLIMIT_AS, config.rlimit_as, "RLIMIT_AS");
805 if (config.rlimit_core_set)
806 set_one_rlimit(RLIMIT_CORE, config.rlimit_core, "RLIMIT_CORE");
807 if (config.rlimit_data_set)
808 set_one_rlimit(RLIMIT_DATA, config.rlimit_data, "RLIMIT_DATA");
809 if (config.rlimit_fsize_set)
810 set_one_rlimit(RLIMIT_FSIZE, config.rlimit_fsize, "RLIMIT_FSIZE");
811 if (config.rlimit_nofile_set)
812 set_one_rlimit(RLIMIT_NOFILE, config.rlimit_nofile, "RLIMIT_NOFILE");
813 if (config.rlimit_stack_set)
814 set_one_rlimit(RLIMIT_STACK, config.rlimit_stack, "RLIMIT_STACK");
816 if (config.rlimit_nproc_set)
817 set_one_rlimit(RLIMIT_NPROC, config.rlimit_nproc, "RLIMIT_NPROC");
820 #ifdef RLIMIT_MEMLOCK
821 /* We don't need locked memory */
822 set_one_rlimit(RLIMIT_MEMLOCK, 0, "RLIMIT_MEMLOCK");
826 #define RANDOM_DEVICE "/dev/urandom"
828 static void init_rand_seed(void) {
832 /* Try to initialize seed from /dev/urandom, to make it a little
833 * less predictable, and to make sure that multiple machines
834 * booted at the same time choose different random seeds. */
835 if ((fd = open(RANDOM_DEVICE, O_RDONLY)) >= 0) {
836 read(fd, &seed, sizeof(seed));
840 /* If the initialization failed by some reason, we add the time to the seed*/
841 seed |= (unsigned) time(NULL);
846 int main(int argc, char *argv[]) {
849 gboolean wrote_pid_file = FALSE;
851 avahi_set_log_function(log_function);
852 avahi_set_allocator(avahi_glib_allocator());
856 avahi_server_config_init(&config.server_config);
857 config.command = DAEMON_RUN;
858 config.daemonize = FALSE;
859 config.config_file = NULL;
860 config.enable_dbus = TRUE;
861 config.drop_root = TRUE;
862 config.publish_dns_servers = NULL;
863 config.publish_resolv_conf = FALSE;
864 config.use_syslog = FALSE;
865 config.no_rlimits = FALSE;
866 config.debug = FALSE;
868 config.rlimit_as_set = FALSE;
869 config.rlimit_core_set = FALSE;
870 config.rlimit_data_set = FALSE;
871 config.rlimit_fsize_set = FALSE;
872 config.rlimit_nofile_set = FALSE;
873 config.rlimit_stack_set = FALSE;
875 config.rlimit_nproc_set = FALSE;
878 if ((argv0 = strrchr(argv[0], '/')))
883 daemon_pid_file_ident = (const char *) argv0;
884 daemon_log_ident = (char*) argv0;
885 daemon_pid_file_proc = pid_file_proc;
887 if (parse_command_line(&config, argc, argv) < 0)
890 if (config.command == DAEMON_HELP) {
893 } else if (config.command == DAEMON_VERSION) {
894 printf("%s "PACKAGE_VERSION"\n", argv0);
896 } else if (config.command == DAEMON_KILL) {
897 if (daemon_pid_file_kill_wait(SIGTERM, 5) < 0) {
898 avahi_log_warn("Failed to kill daemon: %s", strerror(errno));
904 } else if (config.command == DAEMON_RELOAD) {
905 if (daemon_pid_file_kill(SIGHUP) < 0) {
906 avahi_log_warn("Failed to kill daemon: %s", strerror(errno));
912 } else if (config.command == DAEMON_CHECK)
913 r = (daemon_pid_file_is_running() >= 0) ? 0 : 1;
914 else if (config.command == DAEMON_RUN) {
917 if (getuid() != 0 && config.drop_root) {
918 avahi_log_error("This program is intended to be run as root.");
922 if ((pid = daemon_pid_file_is_running()) >= 0) {
923 avahi_log_error("Daemon already running on PID %u", pid);
927 if (load_config_file(&config) < 0)
930 if (config.daemonize) {
931 daemon_retval_init();
933 if ((pid = daemon_fork()) < 0)
939 if ((ret = daemon_retval_wait(20)) < 0) {
940 avahi_log_error("Could not recieve return value from daemon process.");
951 if (config.use_syslog || config.daemonize)
952 daemon_log_use = DAEMON_LOG_SYSLOG;
954 if (make_runtime_dir() < 0)
957 if (config.drop_root) {
962 if (daemon_pid_file_create() < 0) {
963 avahi_log_error("Failed to create PID file: %s", strerror(errno));
965 if (config.daemonize)
966 daemon_retval_send(1);
969 wrote_pid_file = TRUE;
971 if (!config.no_rlimits)
976 avahi_log_info("%s "PACKAGE_VERSION" starting up.", argv0);
978 if (run_server(&config) == 0)
984 if (config.daemonize)
985 daemon_retval_done();
987 avahi_server_config_free(&config.server_config);
988 g_free(config.config_file);
989 g_strfreev(config.publish_dns_servers);
990 g_strfreev(resolv_conf);
993 daemon_pid_file_remove();