summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-05-23 12:03:18 +0200
committerThomas Haller <thaller@redhat.com>2018-05-28 14:58:24 +0200
commitd1a94a85b10bc22c39df30677285ff56b614d24b (patch)
tree4e9a6980662f86bb3fe9a1d1674fa2d5ebd85264
parentdbcb1d6d97c609d53dac4a86dc45d0e2595d8857 (diff)
downloadNetworkManager-d1a94a85b10bc22c39df30677285ff56b614d24b.tar.gz
device: hash a per-host key for ipv4.dhcp-client-id=stable
Otherwise, the generated client-id depends purely on the profile's stable-id. It means, the same profile (that is, either the same UUID or same stable-id) on different hosts will result in identical client-ids. That is clearly not desired. Hash a per-host secret-key as well. Note, that we don't hash the interface name. So, activating the profile on different interfaces, will still yield the same client-id. But also note, that commonly a profile is restricted to one device, via "connection.interface-name". Note that this is a change in behavior. However, "ipv4.dhcp-client-id=stable" was only added recently and not yet released. Fixes: 62a78639797244ef49f439ba2d8bd3332d31585b
-rw-r--r--clients/common/settings-docs.h.in2
-rw-r--r--libnm-core/nm-setting-ip4-config.c2
-rw-r--r--src/devices/nm-device.c7
3 files changed, 8 insertions, 3 deletions
diff --git a/clients/common/settings-docs.h.in b/clients/common/settings-docs.h.in
index 1b94905b4d..2896158157 100644
--- a/clients/common/settings-docs.h.in
+++ b/clients/common/settings-docs.h.in
@@ -211,7 +211,7 @@
#define DESCRIBE_DOC_NM_SETTING_IP_TUNNEL_TTL N_("The TTL to assign to tunneled packets. 0 is a special value meaning that packets inherit the TTL value.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_ADDRESSES N_("Array of IP addresses.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DAD_TIMEOUT N_("Timeout in milliseconds used to check for the presence of duplicate IP addresses on the network. If an address conflict is detected, the activation will fail. A zero value means that no duplicate address detection is performed, -1 means the default value (either configuration ipvx.dad-timeout override or zero). A value greater than zero is a timeout in milliseconds. The property is currently implemented only for IPv4.")
-#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID N_("A string sent to the DHCP server to identify the local machine which the DHCP server may use to customize the DHCP lease and options. When the property is a hex string ('aa:bb:cc') it is interpreted as a binary client ID, in which case the first byte is assumed to be the 'type' field as per RFC 2132 section 9.14 and the remaining bytes may be an hardware address (e.g. '01:xx:xx:xx:xx:xx:xx' where 1 is the Ethernet ARP type and the rest is a MAC address). If the property is not a hex string it is considered as a non-hardware-address client ID and the 'type' field is set to 0. The special values \"mac\" and \"perm-mac\" are supported, which use the current or permanent MAC address of the device to generate a client identifier with type ethernet type (01). Currently, these options only work for ethernet type of links. The special value \"stable\" is supported to generate a type 0 client identifier based on the stable-id (see connection.stable-id). If unset, a globally configured default is used. If still unset, the client-id from the last lease is reused.")
+#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID N_("A string sent to the DHCP server to identify the local machine which the DHCP server may use to customize the DHCP lease and options. When the property is a hex string ('aa:bb:cc') it is interpreted as a binary client ID, in which case the first byte is assumed to be the 'type' field as per RFC 2132 section 9.14 and the remaining bytes may be an hardware address (e.g. '01:xx:xx:xx:xx:xx:xx' where 1 is the Ethernet ARP type and the rest is a MAC address). If the property is not a hex string it is considered as a non-hardware-address client ID and the 'type' field is set to 0. The special values \"mac\" and \"perm-mac\" are supported, which use the current or permanent MAC address of the device to generate a client identifier with type ethernet type (01). Currently, these options only work for ethernet type of links. The special value \"stable\" is supported to generate a type 0 client identifier based on the stable-id (see connection.stable-id) and a per-host key. If unset, a globally configured default is used. If still unset, the client-id from the last lease is reused.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_FQDN N_("If the \"dhcp-send-hostname\" property is TRUE, then the specified FQDN will be sent to the DHCP server when acquiring a lease. This property and \"dhcp-hostname\" are mutually exclusive and cannot be set at the same time.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME N_("If the \"dhcp-send-hostname\" property is TRUE, then the specified name will be sent to the DHCP server when acquiring a lease. This property and \"dhcp-fqdn\" are mutually exclusive and cannot be set at the same time.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME N_("If TRUE, a hostname is sent to the DHCP server when acquiring a lease. Some DHCP servers use this hostname to update DNS databases, essentially providing a static hostname for the computer. If the \"dhcp-hostname\" property is NULL and this property is TRUE, the current persistent hostname of the computer is sent.")
diff --git a/libnm-core/nm-setting-ip4-config.c b/libnm-core/nm-setting-ip4-config.c
index 6214656e0b..0c668d8c02 100644
--- a/libnm-core/nm-setting-ip4-config.c
+++ b/libnm-core/nm-setting-ip4-config.c
@@ -725,7 +725,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *ip4_class)
* type of links.
*
* The special value "stable" is supported to generate a type 0 client identifier based
- * on the stable-id (see connection.stable-id).
+ * on the stable-id (see connection.stable-id) and a per-host key.
*
* If unset, a globally configured default is used. If still unset, the
* client-id from the last lease is reused.
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 3980758631..d26f23d0a0 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -7072,6 +7072,8 @@ dhcp4_get_client_id (NMDevice *self, NMConnection *connection)
guint8 buf[20];
gsize buf_size;
guint32 salted_header;
+ const guint8 *secret_key;
+ gsize secret_key_len;
stable_id = _get_stable_id (self, connection, &stable_type);
if (!stable_id)
@@ -7079,10 +7081,13 @@ dhcp4_get_client_id (NMDevice *self, NMConnection *connection)
salted_header = htonl (2011610591 + stable_type);
+ nm_utils_secret_key_get (&secret_key, &secret_key_len);
+
sum = g_checksum_new (G_CHECKSUM_SHA1);
g_checksum_update (sum, (const guchar *) &salted_header, sizeof (salted_header));
- g_checksum_update (sum, (const guchar *) stable_id, strlen (stable_id));
+ g_checksum_update (sum, (const guchar *) stable_id, strlen (stable_id) + 1);
+ g_checksum_update (sum, (const guchar *) secret_key, secret_key_len);
buf_size = sizeof (buf);
g_checksum_get_digest (sum, buf, &buf_size);