summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-08-02 16:28:23 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-08-06 10:46:05 +0900
commit6528693a94821e0e13a8e112fb481c4ab0c62688 (patch)
tree3f252bc7d80c7e49645d3301f65f3de1db795758 /src/network
parent685499007fc536f5e78ebb49cb67561e186f665e (diff)
downloadsystemd-6528693a94821e0e13a8e112fb481c4ab0c62688.tar.gz
systemd-6528693a94821e0e13a8e112fb481c4ab0c62688.tar.bz2
systemd-6528693a94821e0e13a8e112fb481c4ab0c62688.zip
network: also check that Hostname= is a valid DNS domain name
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-network.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 1f1cdced8f..eb13e9e93d 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -971,7 +971,8 @@ int config_parse_hostname(
void *data,
void *userdata) {
- char **hostname = data, *hn = NULL;
+ _cleanup_free_ char *hn = NULL;
+ char **hostname = data;
int r;
assert(filename);
@@ -984,13 +985,20 @@ int config_parse_hostname(
if (!hostname_is_valid(hn, false)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Hostname is not valid, ignoring assignment: %s", rvalue);
- free(hn);
return 0;
}
- free(*hostname);
- *hostname = hostname_cleanup(hn);
- return 0;
+ r = dns_name_is_valid(hn);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r, "Failed to check validity of hostname '%s', ignoring assignment: %m", rvalue);
+ return 0;
+ }
+ if (r == 0) {
+ log_syntax(unit, LOG_ERR, filename, line, 0, "Hostname is not a valid DNS domain name, ignoring assignment: %s", rvalue);
+ return 0;
+ }
+
+ return free_and_replace(*hostname, hn);
}
int config_parse_timezone(