diff options
author | Susant Sahani <susant@redhat.com> | 2015-07-10 15:42:27 +0530 |
---|---|---|
committer | Susant Sahani <susant@redhat.com> | 2015-07-10 15:42:27 +0530 |
commit | a7d0ef446e5f28b37688743de22052abc8136a94 (patch) | |
tree | e91453eb0cbfd96040092a3f8337cc2b16afff04 /src/network/networkd-network.c | |
parent | 9b361114f568e839784a3aeba5c1df5a95e86832 (diff) |
networkd: DHCP override hostname
This patch enhances the DHCP client to send the hostname
reference
http://lists.freedesktop.org/archives/systemd-devel/2014-July/021550.html
Tested with
Example conf:
[Match]
Name=eth1
[Network]
DHCP=v4
[DHCP]
SendHostname=true
Hostname=test
Diffstat (limited to 'src/network/networkd-network.c')
-rw-r--r-- | src/network/networkd-network.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index a8e9ef909c..55e735e6bf 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -207,6 +207,7 @@ void network_free(Network *network) { free(network->description); free(network->dhcp_vendor_class_identifier); + free(network->hostname); free(network->mac); @@ -809,3 +810,38 @@ int config_parse_ipv6_privacy_extensions( return 0; } + +int config_parse_hostname(const char *unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + char **hostname = data; + char *hn = NULL; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + + r = config_parse_string(unit, filename, line, section, section_line, + lvalue, ltype, rvalue, &hn, userdata); + if (r < 0) + return r; + + if (!hostname_is_valid(hn)) { + log_syntax(unit, LOG_ERR, filename, line, EINVAL, "hostname is not valid, ignoring assignment: %s", rvalue); + + free(hn); + return 0; + } + + *hostname = hn; + + return 0; +} |