1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-28 03:25:27 +03:00

network: also check that Hostname= is a valid DNS domain name

This commit is contained in:
Yu Watanabe 2018-08-02 16:28:23 +09:00
parent 685499007f
commit 6528693a94

View File

@ -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(