diff options
| author | Michael Biebl <biebl@debian.org> | 2018-10-20 01:31:18 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-10-20 01:31:18 +0200 |
| commit | b4885f208ba690090952c0ae0452dd5bc2ba0601 (patch) | |
| tree | 5c8af02da4543f7132b9bad45711a3a65e620d0d /src/dhcp | |
| parent | 142485af41b7cf7b0060cc682a56d3ff38cabbb6 (diff) | |
| parent | 6518e361171f64bcaaa4bf868139362ed95cc2e0 (diff) | |
Update upstream source from tag 'upstream/1.14.2'
Update to upstream version '1.14.2' with Debian dir c118292f450ace1133a5dba2777cbeb54977dbe8
Diffstat (limited to 'src/dhcp')
| -rw-r--r-- | src/dhcp/nm-dhcp-dhclient-utils.c | 1 | ||||
| -rw-r--r-- | src/dhcp/nm-dhcp-dhclient.c | 19 | ||||
| -rw-r--r-- | src/dhcp/nm-dhcp-helper.c | 2 | ||||
| -rw-r--r-- | src/dhcp/nm-dhcp-manager.c | 2 | ||||
| -rw-r--r-- | src/dhcp/nm-dhcp-systemd.c | 39 | ||||
| -rw-r--r-- | src/dhcp/tests/test-dhcp-dhclient.c | 22 |
6 files changed, 77 insertions, 8 deletions
diff --git a/src/dhcp/nm-dhcp-dhclient-utils.c b/src/dhcp/nm-dhcp-dhclient-utils.c index d8f8dd98..a2c3bfb6 100644 --- a/src/dhcp/nm-dhcp-dhclient-utils.c +++ b/src/dhcp/nm-dhcp-dhclient-utils.c @@ -444,6 +444,7 @@ nm_dhcp_dhclient_create_config (const char *interface, add_request (reqs, "static-routes"); add_request (reqs, "wpad"); add_request (reqs, "ntp-servers"); + add_request (reqs, "root-path"); } else { add_hostname6 (new_contents, hostname); add_request (reqs, "dhcp6.name-servers"); diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c index 46d2339b..4a936178 100644 --- a/src/dhcp/nm-dhcp-dhclient.c +++ b/src/dhcp/nm-dhcp-dhclient.c @@ -41,6 +41,7 @@ #include "nm-utils/nm-dedup-multi.h" #include "nm-utils.h" +#include "nm-config.h" #include "nm-dhcp-dhclient-utils.h" #include "nm-dhcp-manager.h" #include "NetworkManagerUtils.h" @@ -120,8 +121,20 @@ get_dhclient_leasefile (int addr_family, const char *uuid, char **out_preferred_path) { + char *rundir_path; char *path; + /* First, see if the lease file is in /run */ + rundir_path = g_strdup_printf (NMRUNDIR "/dhclient%s-%s-%s.lease", + _addr_family_to_path_part (addr_family), + uuid, + iface); + + if (g_file_test (rundir_path, G_FILE_TEST_EXISTS)) { + NM_SET_OUT (out_preferred_path, g_strdup (rundir_path)); + return rundir_path; + } + /* /var/lib/NetworkManager is the preferred leasefile path */ path = g_strdup_printf (NMSTATEDIR "/dhclient%s-%s-%s.lease", _addr_family_to_path_part (addr_family), @@ -133,6 +146,12 @@ get_dhclient_leasefile (int addr_family, return path; } + if (nm_config_get_configure_and_quit (nm_config_get ()) == NM_CONFIG_CONFIGURE_AND_QUIT_INITRD) { + g_free (path); + path = rundir_path; + } else { + g_free (rundir_path); + } NM_SET_OUT (out_preferred_path, g_steal_pointer (&path)); /* If the leasefile we're looking for doesn't exist yet in the new location diff --git a/src/dhcp/nm-dhcp-helper.c b/src/dhcp/nm-dhcp-helper.c index 2b48d7a5..7f1d2a7b 100644 --- a/src/dhcp/nm-dhcp-helper.c +++ b/src/dhcp/nm-dhcp-helper.c @@ -118,7 +118,7 @@ kill_pid (void) if (pid_str) pid = strtol (pid_str, NULL, 10); if (pid) { - _LOGI ("a fatal error occured, kill dhclient instance with pid %d\n", pid); + _LOGI ("a fatal error occurred, kill dhclient instance with pid %d", pid); kill (pid, SIGTERM); } } diff --git a/src/dhcp/nm-dhcp-manager.c b/src/dhcp/nm-dhcp-manager.c index 6c71af9d..5ae16d72 100644 --- a/src/dhcp/nm-dhcp-manager.c +++ b/src/dhcp/nm-dhcp-manager.c @@ -413,7 +413,7 @@ nm_dhcp_manager_init (NMDhcpManager *self) NM_CONFIG_KEYFILE_KEY_MAIN_DHCP, NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY); client = client_free; - if (nm_config_get_configure_and_quit (config)) { + if (nm_config_get_configure_and_quit (config) == NM_CONFIG_CONFIGURE_AND_QUIT_ENABLED) { client_factory = &_nm_dhcp_client_factory_internal; if (client && !nm_streq (client, client_factory->name)) nm_log_info (LOGD_DHCP, "dhcp-init: Using internal DHCP client since configure-and-quit is set."); diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c index b51c6e7b..5b7b5fbe 100644 --- a/src/dhcp/nm-dhcp-systemd.c +++ b/src/dhcp/nm-dhcp-systemd.c @@ -32,6 +32,7 @@ #include "nm-utils/unaligned.h" #include "nm-utils.h" +#include "nm-config.h" #include "nm-dhcp-utils.h" #include "NetworkManagerUtils.h" #include "platform/nm-platform.h" @@ -121,6 +122,7 @@ static const ReqOption dhcp4_requests[] = { { SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE, REQPREFIX "rfc3442_classless_static_routes", TRUE }, { SD_DHCP_OPTION_PRIVATE_CLASSLESS_STATIC_ROUTE, REQPREFIX "ms_classless_static_routes", TRUE }, { SD_DHCP_OPTION_PRIVATE_PROXY_AUTODISCOVERY, REQPREFIX "wpad", TRUE }, + { SD_DHCP_OPTION_ROOT_PATH, REQPREFIX "root_path", TRUE }, /* Internal values */ { SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME, REQPREFIX "expiry", FALSE }, @@ -432,6 +434,13 @@ lease_to_ip4_config (NMDedupMultiIndex *multi_idx, add_option (options, dhcp4_requests, SD_DHCP_OPTION_NTP_SERVER, str->str); } + /* Root path */ + r = sd_dhcp_lease_get_root_path (lease, &s); + if (r >= 0) { + LOG_LEASE (LOGD_DHCP4, "root path '%s'", s); + add_option (options, dhcp4_requests, SD_DHCP_OPTION_ROOT_PATH, s); + } + r = sd_dhcp_lease_get_vendor_specific (lease, &data, &data_len); if (r >= 0) metered = !!memmem (data, data_len, "ANDROID_METERED", NM_STRLEN ("ANDROID_METERED")); @@ -445,10 +454,30 @@ lease_to_ip4_config (NMDedupMultiIndex *multi_idx, static char * get_leasefile_path (int addr_family, const char *iface, const char *uuid) { - return g_strdup_printf (NMSTATEDIR "/internal%s-%s-%s.lease", - addr_family == AF_INET6 ? "6" : "", - uuid, - iface); + char *rundir_path; + char *statedir_path; + + rundir_path = g_strdup_printf (NMRUNDIR "/internal%s-%s-%s.lease", + addr_family == AF_INET6 ? "6" : "", + uuid, + iface); + + if (g_file_test (rundir_path, G_FILE_TEST_EXISTS)) + return rundir_path; + + statedir_path = g_strdup_printf (NMSTATEDIR "/internal%s-%s-%s.lease", + addr_family == AF_INET6 ? "6" : "", + uuid, + iface); + + if ( g_file_test (statedir_path, G_FILE_TEST_EXISTS) + || nm_config_get_configure_and_quit (nm_config_get ()) != NM_CONFIG_CONFIGURE_AND_QUIT_INITRD) { + g_free (rundir_path); + return statedir_path; + } else { + g_free (statedir_path); + return rundir_path; + } } /*****************************************************************************/ @@ -897,7 +926,7 @@ ip6_start (NMDhcpClient *client, } if (needed_prefixes > 0) { - _LOGW ("dhcp-client6: prefix delegation not yet supported, won't supply %d prefixes\n", + _LOGW ("dhcp-client6: prefix delegation not yet supported, won't supply %d prefixes", needed_prefixes); } diff --git a/src/dhcp/tests/test-dhcp-dhclient.c b/src/dhcp/tests/test-dhcp-dhclient.c index 14a1c786..edac4257 100644 --- a/src/dhcp/tests/test-dhcp-dhclient.c +++ b/src/dhcp/tests/test-dhcp-dhclient.c @@ -104,6 +104,7 @@ static const char *orig_missing_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -132,6 +133,7 @@ static const char *override_client_id_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -161,6 +163,7 @@ static const char *quote_client_id_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -190,6 +193,7 @@ static const char *quote_client_id_expected_2 = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -219,6 +223,7 @@ static const char *hex_zero_client_id_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -248,6 +253,7 @@ static const char *ascii_client_id_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -277,6 +283,7 @@ static const char *hex_single_client_id_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -310,6 +317,7 @@ static const char *existing_hex_client_id_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -347,6 +355,7 @@ static const char *existing_escaped_client_id_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -385,6 +394,7 @@ static const char *existing_ascii_client_id_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -419,7 +429,8 @@ static const char *fqdn_expected = \ "also request ms-classless-static-routes;\n" "also request static-routes;\n" "also request wpad;\n" - "also request ntp-servers;\n\n"; + "also request ntp-servers;\n" + "also request root-path;\n\n"; static void test_fqdn (void) @@ -455,6 +466,7 @@ static const char *fqdn_options_override_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n" "# FQDN options from /path/to/dhclient.conf\n" "send fqdn.encoded off;\n" @@ -492,6 +504,7 @@ static const char *override_hostname_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -580,6 +593,7 @@ static const char *existing_alsoreq_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -618,6 +632,7 @@ static const char *existing_req_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -657,6 +672,7 @@ static const char *existing_multiline_alsoreq_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -890,6 +906,7 @@ static const char *interface1_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -935,6 +952,7 @@ static const char *interface2_expected = \ "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; static void @@ -1030,6 +1048,7 @@ test_structured (void) "also request static-routes;\n" "also request wpad;\n" "also request ntp-servers;\n" + "also request root-path;\n" "\n"; new_client_id = g_bytes_new (bytes, sizeof (bytes) - 1); @@ -1085,6 +1104,7 @@ test_config_req_intf (void) "also request ms-classless-static-routes;\n" "also request static-routes;\n" "also request wpad;\n" + "also request root-path;\n" "\n"; test_config (orig, expected, |