]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/libsystemd-network/sd-dhcp-client.c
dhcp: don't enforce hardware address length for sd_dhcp_client_set_client_id()
authorThomas Haller <thaller@redhat.com>
Wed, 19 Dec 2018 09:05:37 +0000 (10:05 +0100)
committerThomas Haller <thaller@redhat.com>
Thu, 20 Dec 2018 12:31:48 +0000 (13:31 +0100)
commitbfda0d0f09666e2476c9abd0280c4b9fa82b968c
treec59c64a053a7f85f06b770f893e1bf63dc3d155d
parentb9d80714583bf40e354ad0fc364ebfb35a0b3d76
dhcp: don't enforce hardware address length for sd_dhcp_client_set_client_id()

sd_dhcp_client_set_client_id() is the only API for setting a raw client-id.
All other setters are more restricted and only allow to set a type 255 DUID.

Also, dhcp4_set_client_identifier() is the only caller, which already
does:

                r = sd_dhcp_client_set_client_id(link->dhcp_client,
                                                 ARPHRD_ETHER,
                                                 (const uint8_t *) &link->mac,
                                                 sizeof(link->mac));

and hence ensures that the data length is indeed ETH_ALEN.

Drop additional input validation from sd_dhcp_client_set_client_id(). The client-id
is an opaque blob, and if a caller wishes to set type 1 (ethernet) or type 32
(infiniband) with unexpected address length, it should be allowed. The actual
client-id is not relevant to the DHCP client, and it's the responsibility of the
caller to generate a suitable client-id.

For example, in NetworkManager you can configure all the bytes of the
client-id, including such _invalid_ settings. I think it makes sense,
to allow the user to fully configure the identifier. Even if such configuration
would be rejected, it would be the responsibility of the higher layers (including
a sensible error message to the user) and not fail later during
sd_dhcp_client_set_client_id().

Still log a debug message if the length is unexpected.
src/libsystemd-network/sd-dhcp-client.c