main: Rename AllowedTetheringTechnologies to TetheringTechnologies
[platform/upstream/connman.git] / src / main.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2012  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <errno.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <unistd.h>
30 #include <string.h>
31 #include <signal.h>
32 #include <sys/signalfd.h>
33 #include <getopt.h>
34 #include <sys/stat.h>
35 #include <net/if.h>
36 #include <netdb.h>
37
38 #include <gdbus.h>
39
40 #include "connman.h"
41
42 #define DEFAULT_INPUT_REQUEST_TIMEOUT 120 * 1000
43 #define DEFAULT_BROWSER_LAUNCH_TIMEOUT 300 * 1000
44
45 #define MAINFILE "main.conf"
46 #define CONFIGMAINFILE CONFIGDIR "/" MAINFILE
47
48 static char *default_auto_connect[] = {
49         "wifi",
50         "ethernet",
51         "cellular",
52         NULL
53 };
54
55 static char *default_blacklist[] = {
56         "vmnet",
57         "vboxnet",
58         "virbr",
59         NULL
60 };
61
62 static struct {
63         connman_bool_t bg_scan;
64         char **pref_timeservers;
65         unsigned int *auto_connect;
66         unsigned int *preferred_techs;
67         char **fallback_nameservers;
68         unsigned int timeout_inputreq;
69         unsigned int timeout_browserlaunch;
70         char **blacklisted_interfaces;
71         connman_bool_t allow_hostname_updates;
72         connman_bool_t single_tech;
73         char **tethering_technologies;
74         connman_bool_t persistent_tethering_mode;
75 } connman_settings  = {
76         .bg_scan = TRUE,
77         .pref_timeservers = NULL,
78         .auto_connect = NULL,
79         .preferred_techs = NULL,
80         .fallback_nameservers = NULL,
81         .timeout_inputreq = DEFAULT_INPUT_REQUEST_TIMEOUT,
82         .timeout_browserlaunch = DEFAULT_BROWSER_LAUNCH_TIMEOUT,
83         .blacklisted_interfaces = NULL,
84         .allow_hostname_updates = TRUE,
85         .single_tech = FALSE,
86         .tethering_technologies = NULL,
87         .persistent_tethering_mode = FALSE,
88 };
89
90 #define CONF_BG_SCAN                    "BackgroundScanning"
91 #define CONF_PREF_TIMESERVERS           "FallbackTimeservers"
92 #define CONF_AUTO_CONNECT               "DefaultAutoConnectTechnologies"
93 #define CONF_PREFERRED_TECHS            "PreferredTechnologies"
94 #define CONF_FALLBACK_NAMESERVERS       "FallbackNameservers"
95 #define CONF_TIMEOUT_INPUTREQ           "InputRequestTimeout"
96 #define CONF_TIMEOUT_BROWSERLAUNCH      "BrowserLaunchTimeout"
97 #define CONF_BLACKLISTED_INTERFACES     "NetworkInterfaceBlacklist"
98 #define CONF_ALLOW_HOSTNAME_UPDATES     "AllowHostnameUpdates"
99 #define CONF_SINGLE_TECH                "SingleConnectedTechnology"
100 #define CONF_TETHERING_TECHNOLOGIES      "TetheringTechnologies"
101 #define CONF_PERSISTENT_TETHERING_MODE  "PersistentTetheringMode"
102
103 static const char *supported_options[] = {
104         CONF_BG_SCAN,
105         CONF_PREF_TIMESERVERS,
106         CONF_AUTO_CONNECT,
107         CONF_PREFERRED_TECHS,
108         CONF_FALLBACK_NAMESERVERS,
109         CONF_TIMEOUT_INPUTREQ,
110         CONF_TIMEOUT_BROWSERLAUNCH,
111         CONF_BLACKLISTED_INTERFACES,
112         CONF_ALLOW_HOSTNAME_UPDATES,
113         CONF_SINGLE_TECH,
114         CONF_TETHERING_TECHNOLOGIES,
115         CONF_PERSISTENT_TETHERING_MODE,
116         NULL
117 };
118
119 static GKeyFile *load_config(const char *file)
120 {
121         GError *err = NULL;
122         GKeyFile *keyfile;
123
124         keyfile = g_key_file_new();
125
126         g_key_file_set_list_separator(keyfile, ',');
127
128         if (!g_key_file_load_from_file(keyfile, file, 0, &err)) {
129                 if (err->code != G_FILE_ERROR_NOENT) {
130                         connman_error("Parsing %s failed: %s", file,
131                                                                 err->message);
132                 }
133
134                 g_error_free(err);
135                 g_key_file_free(keyfile);
136                 return NULL;
137         }
138
139         return keyfile;
140 }
141
142 static uint *parse_service_types(char **str_list, gsize len)
143 {
144         unsigned int *type_list;
145         int i, j;
146         enum connman_service_type type;
147
148         type_list = g_try_new0(unsigned int, len + 1);
149         if (type_list == NULL)
150                 return NULL;
151
152         i = 0;
153         j = 0;
154         while (str_list[i] != NULL)
155         {
156                 type = __connman_service_string2type(str_list[i]);
157
158                 if (type != CONNMAN_SERVICE_TYPE_UNKNOWN) {
159                         type_list[j] = type;
160                         j += 1;
161                 }
162                 i += 1;
163         }
164
165         return type_list;
166 }
167
168 static char **parse_fallback_nameservers(char **nameservers, gsize len)
169 {
170         char **servers;
171         int i, j;
172
173         servers = g_try_new0(char *, len + 1);
174         if (servers == NULL)
175                 return NULL;
176
177         i = 0;
178         j = 0;
179         while (nameservers[i] != NULL) {
180                 if (connman_inet_check_ipaddress(nameservers[i]) > 0) {
181                         servers[j] = g_strdup(nameservers[i]);
182                         j += 1;
183                 }
184                 i += 1;
185         }
186
187         return servers;
188 }
189
190 static void check_config(GKeyFile *config)
191 {
192         char **keys;
193         int j;
194
195         if (config == NULL)
196                 return;
197
198         keys = g_key_file_get_groups(config, NULL);
199
200         for (j = 0; keys != NULL && keys[j] != NULL; j++) {
201                 if (g_strcmp0(keys[j], "General") != 0)
202                         connman_warn("Unknown group %s in %s",
203                                                 keys[j], MAINFILE);
204         }
205
206         g_strfreev(keys);
207
208         keys = g_key_file_get_keys(config, "General", NULL, NULL);
209
210         for (j = 0; keys != NULL && keys[j] != NULL; j++) {
211                 connman_bool_t found;
212                 int i;
213
214                 found = FALSE;
215                 for (i = 0; supported_options[i] != NULL; i++) {
216                         if (g_strcmp0(keys[j], supported_options[i]) == 0) {
217                                 found = TRUE;
218                                 break;
219                         }
220                 }
221                 if (found == FALSE && supported_options[i] == NULL)
222                         connman_warn("Unknown option %s in %s",
223                                                 keys[j], MAINFILE);
224         }
225
226         g_strfreev(keys);
227 }
228
229 static void parse_config(GKeyFile *config)
230 {
231         GError *error = NULL;
232         gboolean boolean;
233         char **timeservers;
234         char **interfaces;
235         char **str_list;
236         char **tethering;
237         gsize len;
238         int timeout;
239
240         if (config == NULL) {
241                 connman_settings.auto_connect =
242                         parse_service_types(default_auto_connect, 3);
243                 connman_settings.blacklisted_interfaces =
244                         g_strdupv(default_blacklist);
245                 return;
246         }
247
248         DBG("parsing %s", MAINFILE);
249
250         boolean = g_key_file_get_boolean(config, "General",
251                                                 CONF_BG_SCAN, &error);
252         if (error == NULL)
253                 connman_settings.bg_scan = boolean;
254
255         g_clear_error(&error);
256
257         timeservers = g_key_file_get_string_list(config, "General",
258                                         CONF_PREF_TIMESERVERS, NULL, &error);
259         if (error == NULL)
260                 connman_settings.pref_timeservers = timeservers;
261
262         g_clear_error(&error);
263
264         str_list = g_key_file_get_string_list(config, "General",
265                         CONF_AUTO_CONNECT, &len, &error);
266
267         if (error == NULL)
268                 connman_settings.auto_connect =
269                         parse_service_types(str_list, len);
270         else
271                 connman_settings.auto_connect =
272                         parse_service_types(default_auto_connect, 3);
273
274         g_strfreev(str_list);
275
276         g_clear_error(&error);
277
278         str_list = g_key_file_get_string_list(config, "General",
279                         CONF_PREFERRED_TECHS, &len, &error);
280
281         if (error == NULL)
282                 connman_settings.preferred_techs =
283                         parse_service_types(str_list, len);
284
285         g_strfreev(str_list);
286
287         g_clear_error(&error);
288
289         str_list = g_key_file_get_string_list(config, "General",
290                         CONF_FALLBACK_NAMESERVERS, &len, &error);
291
292         if (error == NULL)
293                 connman_settings.fallback_nameservers =
294                         parse_fallback_nameservers(str_list, len);
295
296         g_strfreev(str_list);
297
298         g_clear_error(&error);
299
300         timeout = g_key_file_get_integer(config, "General",
301                         CONF_TIMEOUT_INPUTREQ, &error);
302         if (error == NULL && timeout >= 0)
303                 connman_settings.timeout_inputreq = timeout * 1000;
304
305         g_clear_error(&error);
306
307         timeout = g_key_file_get_integer(config, "General",
308                         CONF_TIMEOUT_BROWSERLAUNCH, &error);
309         if (error == NULL && timeout >= 0)
310                 connman_settings.timeout_browserlaunch = timeout * 1000;
311
312         g_clear_error(&error);
313
314         interfaces = g_key_file_get_string_list(config, "General",
315                         CONF_BLACKLISTED_INTERFACES, &len, &error);
316
317         if (error == NULL)
318                 connman_settings.blacklisted_interfaces = interfaces;
319         else
320                 connman_settings.blacklisted_interfaces =
321                         g_strdupv(default_blacklist);
322
323         g_clear_error(&error);
324
325         boolean = g_key_file_get_boolean(config, "General",
326                                         CONF_ALLOW_HOSTNAME_UPDATES,
327                                         &error);
328         if (error == NULL)
329                 connman_settings.allow_hostname_updates = boolean;
330
331         g_clear_error(&error);
332
333         boolean = g_key_file_get_boolean(config, "General",
334                         CONF_SINGLE_TECH, &error);
335         if (error == NULL)
336                 connman_settings.single_tech = boolean;
337
338         g_clear_error(&error);
339
340         tethering = g_key_file_get_string_list(config, "General",
341                         CONF_TETHERING_TECHNOLOGIES, &len, &error);
342
343         if (error == NULL)
344                 connman_settings.tethering_technologies = tethering;
345
346         g_clear_error(&error);
347
348         boolean = g_key_file_get_boolean(config, "General",
349                                         CONF_PERSISTENT_TETHERING_MODE,
350                                         &error);
351         if (error == NULL)
352                 connman_settings.persistent_tethering_mode = boolean;
353
354         g_clear_error(&error);
355 }
356
357 static int config_init(const char *file)
358 {
359         GKeyFile *config;
360
361         config = load_config(file);
362         check_config(config);
363         parse_config(config);
364         if (config != NULL)
365                 g_key_file_free(config);
366
367         return 0;
368 }
369
370 static GMainLoop *main_loop = NULL;
371
372 static unsigned int __terminated = 0;
373
374 static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
375                                                         gpointer user_data)
376 {
377         struct signalfd_siginfo si;
378         ssize_t result;
379         int fd;
380
381         if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
382                 return FALSE;
383
384         fd = g_io_channel_unix_get_fd(channel);
385
386         result = read(fd, &si, sizeof(si));
387         if (result != sizeof(si))
388                 return FALSE;
389
390         switch (si.ssi_signo) {
391         case SIGINT:
392         case SIGTERM:
393                 if (__terminated == 0) {
394                         connman_info("Terminating");
395                         g_main_loop_quit(main_loop);
396                 }
397
398                 __terminated = 1;
399                 break;
400         }
401
402         return TRUE;
403 }
404
405 static guint setup_signalfd(void)
406 {
407         GIOChannel *channel;
408         guint source;
409         sigset_t mask;
410         int fd;
411
412         sigemptyset(&mask);
413         sigaddset(&mask, SIGINT);
414         sigaddset(&mask, SIGTERM);
415
416         if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) {
417                 perror("Failed to set signal mask");
418                 return 0;
419         }
420
421         fd = signalfd(-1, &mask, 0);
422         if (fd < 0) {
423                 perror("Failed to create signal descriptor");
424                 return 0;
425         }
426
427         channel = g_io_channel_unix_new(fd);
428
429         g_io_channel_set_close_on_unref(channel, TRUE);
430         g_io_channel_set_encoding(channel, NULL, NULL);
431         g_io_channel_set_buffered(channel, FALSE);
432
433         source = g_io_add_watch(channel,
434                                 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
435                                 signal_handler, NULL);
436
437         g_io_channel_unref(channel);
438
439         return source;
440 }
441
442 static void disconnect_callback(DBusConnection *conn, void *user_data)
443 {
444         connman_error("D-Bus disconnect");
445
446         g_main_loop_quit(main_loop);
447 }
448
449 static gchar *option_config = NULL;
450 static gchar *option_debug = NULL;
451 static gchar *option_device = NULL;
452 static gchar *option_plugin = NULL;
453 static gchar *option_nodevice = NULL;
454 static gchar *option_noplugin = NULL;
455 static gchar *option_wifi = NULL;
456 static gboolean option_detach = TRUE;
457 static gboolean option_dnsproxy = TRUE;
458 static gboolean option_backtrace = TRUE;
459 static gboolean option_version = FALSE;
460
461 static gboolean parse_debug(const char *key, const char *value,
462                                         gpointer user_data, GError **error)
463 {
464         if (value)
465                 option_debug = g_strdup(value);
466         else
467                 option_debug = g_strdup("*");
468
469         return TRUE;
470 }
471
472 static GOptionEntry options[] = {
473         { "config", 'c', 0, G_OPTION_ARG_STRING, &option_config,
474                                 "Load the specified configuration file "
475                                 "instead of " CONFIGMAINFILE, "FILE" },
476         { "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG,
477                                 G_OPTION_ARG_CALLBACK, parse_debug,
478                                 "Specify debug options to enable", "DEBUG" },
479         { "device", 'i', 0, G_OPTION_ARG_STRING, &option_device,
480                         "Specify networking device or interface", "DEV" },
481         { "nodevice", 'I', 0, G_OPTION_ARG_STRING, &option_nodevice,
482                         "Specify networking interface to ignore", "DEV" },
483         { "plugin", 'p', 0, G_OPTION_ARG_STRING, &option_plugin,
484                                 "Specify plugins to load", "NAME,..." },
485         { "noplugin", 'P', 0, G_OPTION_ARG_STRING, &option_noplugin,
486                                 "Specify plugins not to load", "NAME,..." },
487         { "wifi", 'W', 0, G_OPTION_ARG_STRING, &option_wifi,
488                                 "Specify driver for WiFi/Supplicant", "NAME" },
489         { "nodaemon", 'n', G_OPTION_FLAG_REVERSE,
490                                 G_OPTION_ARG_NONE, &option_detach,
491                                 "Don't fork daemon to background" },
492         { "nodnsproxy", 'r', G_OPTION_FLAG_REVERSE,
493                                 G_OPTION_ARG_NONE, &option_dnsproxy,
494                                 "Don't enable DNS Proxy" },
495         { "nobacktrace", 0, G_OPTION_FLAG_REVERSE,
496                                 G_OPTION_ARG_NONE, &option_backtrace,
497                                 "Don't print out backtrace information" },
498         { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
499                                 "Show version information and exit" },
500         { NULL },
501 };
502
503 const char *connman_option_get_string(const char *key)
504 {
505         if (g_strcmp0(key, "wifi") == 0) {
506                 if (option_wifi == NULL)
507                         return "nl80211,wext";
508                 else
509                         return option_wifi;
510         }
511
512         return NULL;
513 }
514
515 connman_bool_t connman_setting_get_bool(const char *key)
516 {
517         if (g_str_equal(key, CONF_BG_SCAN) == TRUE)
518                 return connman_settings.bg_scan;
519
520         if (g_str_equal(key, CONF_ALLOW_HOSTNAME_UPDATES) == TRUE)
521                 return connman_settings.allow_hostname_updates;
522
523         if (g_str_equal(key, CONF_SINGLE_TECH) == TRUE)
524                 return connman_settings.single_tech;
525
526         if (g_str_equal(key, CONF_PERSISTENT_TETHERING_MODE) == TRUE)
527                 return connman_settings.persistent_tethering_mode;
528
529         return FALSE;
530 }
531
532 char **connman_setting_get_string_list(const char *key)
533 {
534         if (g_str_equal(key, CONF_PREF_TIMESERVERS) == TRUE)
535                 return connman_settings.pref_timeservers;
536
537         if (g_str_equal(key, CONF_FALLBACK_NAMESERVERS) == TRUE)
538                 return connman_settings.fallback_nameservers;
539
540         if (g_str_equal(key, CONF_BLACKLISTED_INTERFACES) == TRUE)
541                 return connman_settings.blacklisted_interfaces;
542
543         if (g_str_equal(key, CONF_TETHERING_TECHNOLOGIES) == TRUE)
544                 return connman_settings.tethering_technologies;
545
546         return NULL;
547 }
548
549 unsigned int *connman_setting_get_uint_list(const char *key)
550 {
551         if (g_str_equal(key, CONF_AUTO_CONNECT) == TRUE)
552                 return connman_settings.auto_connect;
553
554         if (g_str_equal(key, CONF_PREFERRED_TECHS) == TRUE)
555                 return connman_settings.preferred_techs;
556
557         return NULL;
558 }
559
560 unsigned int connman_timeout_input_request(void) {
561         return connman_settings.timeout_inputreq;
562 }
563
564 unsigned int connman_timeout_browser_launch(void) {
565         return connman_settings.timeout_browserlaunch;
566 }
567
568 int main(int argc, char *argv[])
569 {
570         GOptionContext *context;
571         GError *error = NULL;
572         DBusConnection *conn;
573         DBusError err;
574         guint signal;
575
576 #ifdef NEED_THREADS
577         if (g_thread_supported() == FALSE)
578                 g_thread_init(NULL);
579 #endif
580
581         context = g_option_context_new(NULL);
582         g_option_context_add_main_entries(context, options, NULL);
583
584         if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) {
585                 if (error != NULL) {
586                         g_printerr("%s\n", error->message);
587                         g_error_free(error);
588                 } else
589                         g_printerr("An unknown error occurred\n");
590                 exit(1);
591         }
592
593         g_option_context_free(context);
594
595         if (option_version == TRUE) {
596                 printf("%s\n", VERSION);
597                 exit(0);
598         }
599
600         if (option_detach == TRUE) {
601                 if (daemon(0, 0)) {
602                         perror("Can't start daemon");
603                         exit(1);
604                 }
605         }
606
607         if (mkdir(STATEDIR, S_IRUSR | S_IWUSR | S_IXUSR |
608                                 S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) {
609                 if (errno != EEXIST)
610                         perror("Failed to create state directory");
611         }
612
613         if (mkdir(STORAGEDIR, S_IRUSR | S_IWUSR | S_IXUSR |
614                                 S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) {
615                 if (errno != EEXIST)
616                         perror("Failed to create storage directory");
617         }
618
619         umask(0077);
620
621         main_loop = g_main_loop_new(NULL, FALSE);
622
623 #ifdef NEED_THREADS
624         if (dbus_threads_init_default() == FALSE) {
625                 fprintf(stderr, "Can't init usage of threads\n");
626                 exit(1);
627         }
628 #endif
629
630         signal = setup_signalfd();
631
632         dbus_error_init(&err);
633
634         conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, CONNMAN_SERVICE, &err);
635         if (conn == NULL) {
636                 if (dbus_error_is_set(&err) == TRUE) {
637                         fprintf(stderr, "%s\n", err.message);
638                         dbus_error_free(&err);
639                 } else
640                         fprintf(stderr, "Can't register with system bus\n");
641                 exit(1);
642         }
643
644         g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL);
645
646         __connman_log_init(argv[0], option_debug, option_detach,
647                         option_backtrace, "Connection Manager", VERSION);
648
649         __connman_dbus_init(conn);
650
651         if (option_config == NULL)
652                 config_init(CONFIGMAINFILE);
653         else
654                 config_init(option_config);
655
656         __connman_inotify_init();
657         __connman_technology_init();
658         __connman_notifier_init();
659         __connman_agent_init();
660         __connman_service_init();
661         __connman_provider_init();
662         __connman_network_init();
663         __connman_device_init(option_device, option_nodevice);
664
665         __connman_ippool_init();
666         __connman_iptables_init();
667         __connman_firewall_init();
668         __connman_nat_init();
669         __connman_tethering_init();
670         __connman_counter_init();
671         __connman_manager_init();
672         __connman_config_init();
673         __connman_stats_init();
674         __connman_clock_init();
675
676         __connman_resolver_init(option_dnsproxy);
677         __connman_ipconfig_init();
678         __connman_rtnl_init();
679         __connman_task_init();
680         __connman_proxy_init();
681         __connman_detect_init();
682         __connman_session_init();
683         __connman_timeserver_init();
684         __connman_connection_init();
685
686         __connman_plugin_init(option_plugin, option_noplugin);
687
688         __connman_rtnl_start();
689         __connman_dhcp_init();
690         __connman_dhcpv6_init();
691         __connman_wpad_init();
692         __connman_wispr_init();
693         __connman_rfkill_init();
694
695         g_free(option_config);
696         g_free(option_device);
697         g_free(option_plugin);
698         g_free(option_nodevice);
699         g_free(option_noplugin);
700
701         g_main_loop_run(main_loop);
702
703         g_source_remove(signal);
704
705         __connman_rfkill_cleanup();
706         __connman_wispr_cleanup();
707         __connman_wpad_cleanup();
708         __connman_dhcpv6_cleanup();
709         __connman_dhcp_cleanup();
710         __connman_session_cleanup();
711         __connman_plugin_cleanup();
712         __connman_provider_cleanup();
713         __connman_connection_cleanup();
714         __connman_timeserver_cleanup();
715         __connman_detect_cleanup();
716         __connman_proxy_cleanup();
717         __connman_task_cleanup();
718         __connman_rtnl_cleanup();
719         __connman_resolver_cleanup();
720
721         __connman_clock_cleanup();
722         __connman_stats_cleanup();
723         __connman_config_cleanup();
724         __connman_manager_cleanup();
725         __connman_counter_cleanup();
726         __connman_tethering_cleanup();
727         __connman_nat_cleanup();
728         __connman_firewall_cleanup();
729         __connman_iptables_cleanup();
730         __connman_ippool_cleanup();
731         __connman_device_cleanup();
732         __connman_network_cleanup();
733         __connman_service_cleanup();
734         __connman_agent_cleanup();
735         __connman_ipconfig_cleanup();
736         __connman_notifier_cleanup();
737         __connman_technology_cleanup();
738         __connman_inotify_cleanup();
739
740         __connman_dbus_cleanup();
741
742         __connman_log_cleanup(option_backtrace);
743
744         dbus_connection_unref(conn);
745
746         g_main_loop_unref(main_loop);
747
748         if (connman_settings.pref_timeservers != NULL)
749                 g_strfreev(connman_settings.pref_timeservers);
750
751         g_free(connman_settings.auto_connect);
752         g_free(connman_settings.preferred_techs);
753         g_strfreev(connman_settings.fallback_nameservers);
754         g_strfreev(connman_settings.blacklisted_interfaces);
755         g_strfreev(connman_settings.tethering_technologies);
756
757         g_free(option_debug);
758
759         return 0;
760 }