| From d4b37f7a7b4d7ee2f8c23d63093ac32810bf0621 Mon Sep 17 00:00:00 2001 |
| From: Daniel Wang <wonderfly@google.com> |
| Date: Mon, 6 Mar 2017 15:35:13 -0800 |
| Subject: [PATCH 1/1] libsystemd-networkd: use single-label hostname. |
| |
| --- |
| src/libsystemd-network/sd-dhcp-lease.c | 15 +++++++++++++++ |
| 1 file changed, 15 insertions(+) |
| |
| diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c |
| index 8387b185c..2d60d4223 100644 |
| --- a/src/libsystemd-network/sd-dhcp-lease.c |
| +++ b/src/libsystemd-network/sd-dhcp-lease.c |
| @@ -141,12 +141,27 @@ int sd_dhcp_lease_get_domainname(sd_dhcp_lease *lease, const char **domainname) |
| } |
| |
| int sd_dhcp_lease_get_hostname(sd_dhcp_lease *lease, const char **hostname) { |
| + char *firstdot = NULL; |
| + |
| assert_return(lease, -EINVAL); |
| assert_return(hostname, -EINVAL); |
| |
| if (!lease->hostname) |
| return -ENODATA; |
| |
| + // Lakitu-specific behavior: always use single-label hostname |
| + // or unqualified domain-name instead of FQDN. |
| + // Lakitu configures systemd-networkd to set the hostname via |
| + // DHCP. RFC 1497 says the DHCP server may send a |
| + // fully-qualified domain name as the hostname. The FQDN can |
| + // be 255 bytes long, but the hostname on Linux is typically |
| + // limited to 64 bytes. To avoid dropping the FQDN as |
| + // "invalid" for its length, we mutate |hostname| such that it |
| + // contains only the single-label hostname. |
| + if ((firstdot = strchr(lease->hostname, '.')) != NULL) { |
| + *firstdot = 0; |
| + } |
| + |
| *hostname = lease->hostname; |
| return 0; |
| } |
| -- |
| 2.12.0.rc1.440.g5b76565f74-goog |
| |