diff options
author | Tom Gundersen <teg@jklm.no> | 2015-07-20 17:58:45 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-07-20 17:58:45 +0200 |
commit | 31053e929ed2f13b22b76d0d2819d11189f696b6 (patch) | |
tree | b06219ca95a3720cae4e49aa6bd60eb1cf9f64ab /src/network/networkd-network.c | |
parent | 6913b32249eeaabf00184872de189e1a8889ab74 (diff) | |
parent | d88ba7f02ee8ada591edbd17de34764bd19d6e9b (diff) |
Merge pull request #549 from ssahani/dhcp
networkd: allow hostname override
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; +} |