diff options
| author | Michael Biebl <biebl@debian.org> | 2016-05-11 17:08:25 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2016-05-11 17:08:25 +0200 |
| commit | 73e152af6e3fb4f5848bfb8394484026ff119003 (patch) | |
| tree | d5a8b37778d3a95c51511451b38b6a329b94cb41 /src/dhcp-manager | |
| parent | 78c3b8801ecf4975e5da1af3b10ae20dd2d876de (diff) | |
Imported Upstream version 1.2.2 upstream/1.2.2
Diffstat (limited to 'src/dhcp-manager')
| -rw-r--r-- | src/dhcp-manager/nm-dhcp-client.c | 58 | ||||
| -rw-r--r-- | src/dhcp-manager/nm-dhcp-systemd.c | 9 |
2 files changed, 17 insertions, 50 deletions
diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c index b8161ab5..9f4cdf3e 100644 --- a/src/dhcp-manager/nm-dhcp-client.c +++ b/src/dhcp-manager/nm-dhcp-client.c @@ -436,37 +436,10 @@ nm_dhcp_client_start_ip4 (NMDhcpClient *self, return NM_DHCP_CLIENT_GET_CLASS (self)->ip4_start (self, dhcp_anycast_addr, last_ip4_address); } -/* uuid_parse does not work for machine-id, so we use our own converter */ -static gboolean -machine_id_parse (const char *in, uuid_t uu) -{ - const char *cp; - int i; - char buf[3]; - - g_return_val_if_fail (in != NULL, FALSE); - g_return_val_if_fail (strlen (in) == 32, FALSE); - - for (i = 0; i < 32; i++) { - if (!g_ascii_isxdigit (in[i])) - return FALSE; - } - - buf[2] = 0; - cp = in; - for (i = 0; i < 16; i++) { - buf[0] = *cp++; - buf[1] = *cp++; - uu[i] = ((unsigned char) strtoul (buf, NULL, 16)) & 0xFF; - } - return TRUE; -} - static GByteArray * generate_duid_from_machine_id (void) { GByteArray *duid; - char *contents = NULL; GChecksum *sum; guint8 buffer[32]; /* SHA256 digest size */ gsize sumlen = sizeof (buffer); @@ -474,27 +447,16 @@ generate_duid_from_machine_id (void) uuid_t uuid; GRand *generator; guint i; - gboolean success = FALSE; - - /* Get the machine ID from /etc/machine-id; it's always in /etc no matter - * where our configured SYSCONFDIR is. Alternatively, it might be in - * LOCALSTATEDIR /lib/dbus/machine-id. - */ - if ( g_file_get_contents ("/etc/machine-id", &contents, NULL, NULL) - || g_file_get_contents (LOCALSTATEDIR "/lib/dbus/machine-id", &contents, NULL, NULL)) { - contents = g_strstrip (contents); - success = machine_id_parse (contents, uuid); - if (success) { - /* Hash the machine ID so it's not leaked to the network */ - sum = g_checksum_new (G_CHECKSUM_SHA256); - g_checksum_update (sum, (const guchar *) &uuid, sizeof (uuid)); - g_checksum_get_digest (sum, buffer, &sumlen); - g_checksum_free (sum); - } - g_free (contents); - } - - if (!success) { + gs_free char *machine_id_s = NULL; + + machine_id_s = nm_utils_machine_id_read (); + if (nm_utils_machine_id_parse (machine_id_s, uuid)) { + /* Hash the machine ID so it's not leaked to the network */ + sum = g_checksum_new (G_CHECKSUM_SHA256); + g_checksum_update (sum, (const guchar *) &uuid, sizeof (uuid)); + g_checksum_get_digest (sum, buffer, &sumlen); + g_checksum_free (sum); + } else { nm_log_warn (LOGD_DHCP6, "dhcp6: failed to read " SYSCONFDIR "/machine-id " "or " LOCALSTATEDIR "/lib/dbus/machine-id to generate " "DHCPv6 DUID; creating non-persistent random DUID."); diff --git a/src/dhcp-manager/nm-dhcp-systemd.c b/src/dhcp-manager/nm-dhcp-systemd.c index 5d49c27e..82cb3350 100644 --- a/src/dhcp-manager/nm-dhcp-systemd.c +++ b/src/dhcp-manager/nm-dhcp-systemd.c @@ -279,8 +279,9 @@ lease_to_ip4_config (const char *iface, /* Domain Name */ r = sd_dhcp_lease_get_domainname (lease, &str); if (r == 0) { - /* Multiple domains sometimes stuffed into the option */ - char **domains = g_strsplit (str, " ", 0); + /* Multiple domains sometimes stuffed into option 15 "Domain Name". + * As systemd escapes such characters, split them at \\032. */ + char **domains = g_strsplit (str, "\\032", 0); char **s; for (s = domains; *s; s++) { @@ -857,6 +858,7 @@ dhcp6_event_cb (sd_dhcp6_client *client, int event, gpointer user_data) nm_dhcp_client_set_state (NM_DHCP_CLIENT (user_data), NM_DHCP_STATE_FAIL, NULL, NULL); break; case SD_DHCP6_CLIENT_EVENT_IP_ACQUIRE: + case SD_DHCP6_CLIENT_EVENT_INFORMATION_REQUEST: bound6_handle (self); break; default: @@ -893,6 +895,9 @@ ip6_start (NMDhcpClient *client, return FALSE; } + if (info_only) + sd_dhcp6_client_set_information_request (priv->client6, 1); + /* NM stores the entire DUID which includes the uint16 "type", while systemd * wants the type passed separately from the following data. */ |