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