X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fnetwork%2Fnetworkd-link.c;h=3324276bcc5b9c6ea2c1ae001f2d9a6b32563b3b;hb=4cc7a82c9490a3c5ae03b1d6d168ce40ba499e23;hp=a523a3e9b2d7f47f16785e9ef8b3a46d7d671fd0;hpb=856f962c7a2e13b33f5b1c691efb2780f2c7afc3;p=elogind.git diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index a523a3e9b..3324276bc 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -21,6 +21,7 @@ #include #include +#include #include "networkd.h" #include "libudev-private.h" @@ -1927,6 +1928,18 @@ static int link_enter_enslave(Link *link) { return 0; } +/* make sure the hostname is not "localhost" */ +static bool is_localhost(const char *hostname) { + assert(hostname); + + return streq(hostname, "localhost") || + streq(hostname, "localhost.") || + endswith(hostname, ".localhost") || + endswith(hostname, ".localhost.") || + endswith(hostname, ".localdomain") || + endswith(hostname, ".localdomain."); +} + static int link_configure(Link *link) { int r; @@ -1992,6 +2005,7 @@ static int link_configure(Link *link) { if (r < 0) return r; } + if (link->network->dhcp_routes) { r = sd_dhcp_client_set_request_option(link->dhcp_client, DHCP_OPTION_STATIC_ROUTE); if (r < 0) @@ -2000,6 +2014,18 @@ static int link_configure(Link *link) { if (r < 0) return r; } + + if (link->network->dhcp_sendhost) { + _cleanup_free_ char *hostname = gethostname_malloc(); + if (!hostname) + return -ENOMEM; + + if (!is_localhost(hostname)) { + r = sd_dhcp_client_set_hostname(link->dhcp_client, hostname); + if (r < 0) + return r; + } + } } if (link->network->dhcp_server) {