diff options
| author | Michael Biebl <biebl@debian.org> | 2017-05-11 14:55:55 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2017-05-11 14:55:55 +0200 |
| commit | c333f062ddcba9b35330647bf6cbd0a07f2d786e (patch) | |
| tree | 257c3a0c74c09f4ad2328eab5b932806405f0c1c /src/dnsmasq | |
| parent | a222e56e103f949b148a6942e385ccca2c26d9f3 (diff) | |
New upstream version 1.8.0 upstream/1.8.0
Diffstat (limited to 'src/dnsmasq')
| -rw-r--r-- | src/dnsmasq/nm-dnsmasq-manager.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/dnsmasq/nm-dnsmasq-manager.c b/src/dnsmasq/nm-dnsmasq-manager.c index 9b24e69e..f76c983d 100644 --- a/src/dnsmasq/nm-dnsmasq-manager.c +++ b/src/dnsmasq/nm-dnsmasq-manager.c @@ -152,13 +152,15 @@ create_dm_cmd_line (const char *iface, GError **error) { NMCmdLine *cmd; - GString *s; + nm_auto_free_gstring GString *s = NULL; char first[INET_ADDRSTRLEN]; char last[INET_ADDRSTRLEN]; char localaddr[INET_ADDRSTRLEN]; + char tmpaddr[INET_ADDRSTRLEN]; char *error_desc = NULL; const char *dm_binary; const NMPlatformIP4Address *listen_address; + guint i, n; listen_address = nm_ip4_config_get_address (ip4_config, 0); g_return_val_if_fail (listen_address, NULL); @@ -167,6 +169,8 @@ create_dm_cmd_line (const char *iface, if (!dm_binary) return NULL; + s = g_string_sized_new (100); + /* Create dnsmasq command line */ cmd = nm_cmd_line_new (); nm_cmd_line_add_string (cmd, dm_binary); @@ -196,11 +200,11 @@ create_dm_cmd_line (const char *iface, */ nm_cmd_line_add_string (cmd, "--strict-order"); - s = g_string_new ("--listen-address="); nm_utils_inet4_ntop (listen_address->address, localaddr); + g_string_append (s, "--listen-address="); g_string_append (s, localaddr); nm_cmd_line_add_string (cmd, s->str); - g_string_free (s, TRUE); + g_string_truncate (s, 0); if (!nm_dnsmasq_utils_get_range (listen_address, first, last, &error_desc)) { g_set_error_literal (error, @@ -213,24 +217,41 @@ create_dm_cmd_line (const char *iface, return NULL; } - s = g_string_new ("--dhcp-range="); - g_string_append_printf (s, "%s,%s,60m", first, last); + g_string_append_printf (s, "--dhcp-range=%s,%s,60m", first, last); nm_cmd_line_add_string (cmd, s->str); - g_string_free (s, TRUE); + g_string_truncate (s, 0); if (!nm_ip4_config_get_never_default (ip4_config)) { - s = g_string_new ("--dhcp-option=option:router,"); + g_string_append (s, "--dhcp-option=option:router,"); g_string_append (s, localaddr); nm_cmd_line_add_string (cmd, s->str); - g_string_free (s, TRUE); + g_string_truncate (s, 0); + } + + if ((n = nm_ip4_config_get_num_nameservers (ip4_config))) { + g_string_append (s, "--dhcp-option=option:dns-server"); + for (i = 0; i < n; i++) { + g_string_append_c (s, ','); + g_string_append (s, nm_utils_inet4_ntop (nm_ip4_config_get_nameserver (ip4_config, i), tmpaddr)); + } + g_string_truncate (s, 0); + } + + if ((n = nm_ip4_config_get_num_searches (ip4_config))) { + g_string_append (s, "--dhcp-option=option:domain-search"); + for (i = 0; i < n; i++) { + g_string_append_c (s, ','); + g_string_append (s, nm_ip4_config_get_search (ip4_config, i)); + } + g_string_truncate (s, 0); } nm_cmd_line_add_string (cmd, "--dhcp-lease-max=50"); - s = g_string_new ("--pid-file="); + g_string_append (s, "--pid-file="); g_string_append (s, pidfile); nm_cmd_line_add_string (cmd, s->str); - g_string_free (s, TRUE); + g_string_truncate (s, 0); /* dnsmasq exits if the conf dir is not present */ if (g_file_test (CONFDIR, G_FILE_TEST_IS_DIR)) |