mirror of
https://github.com/systemd/systemd.git
synced 2025-02-04 21:47:31 +03:00
network: also check that Hostname= is a valid DNS domain name
This commit is contained in:
parent
685499007f
commit
6528693a94
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user