Merge pull request #9775 from yuwata/follow-up-9766
This commit is contained in:
commit
cad8d67194
|
@ -1194,25 +1194,28 @@
|
|||
<varlistentry>
|
||||
<term><varname>SendHostname=</varname></term>
|
||||
<listitem>
|
||||
<para>When true (the default), the machine's hostname will
|
||||
be sent to the DHCP server.</para>
|
||||
<para>When true (the default), the machine's hostname will be sent to the DHCP server.
|
||||
Note that the machine's hostname must consist only of 7-bit ASCII lower-case characters and
|
||||
no spaces or dots, and be formatted as a valid DNS domain name. Otherwise, the hostname is not
|
||||
sent even if this is set to true.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>UseHostname=</varname></term>
|
||||
<listitem>
|
||||
<para>When true (the default), the hostname received from
|
||||
the DHCP server will be set as the transient hostname of the system
|
||||
the DHCP server will be set as the transient hostname of the system.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>Hostname=</varname></term>
|
||||
<listitem>
|
||||
<para>Use this value for the hostname which is sent to the
|
||||
DHCP server, instead of machine's hostname.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<term><varname>Hostname=</varname></term>
|
||||
<listitem>
|
||||
<para>Use this value for the hostname which is sent to the DHCP server, instead of machine's hostname.
|
||||
Note that the specified hostname must consist only of 7-bit ASCII lower-case characters and
|
||||
no spaces or dots, and be formatted as a valid DNS domain name.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>UseDomains=</varname></term>
|
||||
<listitem>
|
||||
|
|
|
@ -599,7 +599,14 @@ static int dhcp4_set_hostname(Link *link) {
|
|||
hn = hostname;
|
||||
}
|
||||
|
||||
return sd_dhcp_client_set_hostname(link->dhcp_client, hn);
|
||||
r = sd_dhcp_client_set_hostname(link->dhcp_client, hn);
|
||||
if (r == -EINVAL && hostname)
|
||||
/* Ignore error when the machine's hostname is not suitable to send in DHCP packet. */
|
||||
log_link_warning_errno(link, r, "DHCP4 CLIENT: Failed to set hostname from kernel hostname, ignoring: %m");
|
||||
else if (r < 0)
|
||||
return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set hostname: %m");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool promote_secondaries_enabled(const char *ifname) {
|
||||
|
@ -737,7 +744,7 @@ int dhcp4_configure(Link *link) {
|
|||
|
||||
r = dhcp4_set_hostname(link);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set hostname: %m");
|
||||
return r;
|
||||
|
||||
if (link->network->dhcp_vendor_class_identifier) {
|
||||
r = sd_dhcp_client_set_vendor_class_identifier(link->dhcp_client,
|
||||
|
|
|
@ -453,7 +453,14 @@ static int dhcp6_set_hostname(sd_dhcp6_client *client, Link *link) {
|
|||
hn = hostname;
|
||||
}
|
||||
|
||||
return sd_dhcp6_client_set_fqdn(client, hn);
|
||||
r = sd_dhcp6_client_set_fqdn(client, hn);
|
||||
if (r == -EINVAL && hostname)
|
||||
/* Ignore error when the machine's hostname is not suitable to send in DHCP packet. */
|
||||
log_link_warning_errno(link, r, "DHCP6 CLIENT: Failed to set hostname from kernel hostname, ignoring: %m");
|
||||
else if (r < 0)
|
||||
return log_link_error_errno(link, r, "DHCP6 CLIENT: Failed to set hostname: %m");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dhcp6_configure(Link *link) {
|
||||
|
@ -497,7 +504,7 @@ int dhcp6_configure(Link *link) {
|
|||
|
||||
r = dhcp6_set_hostname(client, link);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "DHCP6 CLIENT: Failed to set hostname: %m");
|
||||
return r;
|
||||
|
||||
r = sd_dhcp6_client_set_ifindex(client, link->ifindex);
|
||||
if (r < 0)
|
||||
|
|
|
@ -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(
|
||||
|
@ -1005,7 +1013,8 @@ int config_parse_timezone(
|
|||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
char **datap = data, *tz = NULL;
|
||||
_cleanup_free_ char *tz = NULL;
|
||||
char **datap = data;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
|
@ -1018,14 +1027,10 @@ int config_parse_timezone(
|
|||
|
||||
if (!timezone_is_valid(tz, LOG_ERR)) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Timezone is not valid, ignoring assignment: %s", rvalue);
|
||||
free(tz);
|
||||
return 0;
|
||||
}
|
||||
|
||||
free(*datap);
|
||||
*datap = tz;
|
||||
|
||||
return 0;
|
||||
return free_and_replace(*datap, tz);
|
||||
}
|
||||
|
||||
int config_parse_dhcp_server_dns(
|
||||
|
|
|
@ -218,7 +218,10 @@ static int dns_trust_anchor_load_positive(DnsTrustAnchor *d, const char *path, u
|
|||
if (r < 0)
|
||||
return log_warning_errno(r, "Unable to parse domain in line %s:%u: %m", path, line);
|
||||
|
||||
if (!dns_name_is_valid(domain)) {
|
||||
r = dns_name_is_valid(domain);
|
||||
if (r < 0)
|
||||
return log_warning_errno(r, "Failed to chack validity of domain name '%s', at line %s:%u, ignoring line: %m", domain, path, line);
|
||||
if (r == 0) {
|
||||
log_warning("Domain name %s is invalid, at line %s:%u, ignoring line.", domain, path, line);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -385,7 +388,10 @@ static int dns_trust_anchor_load_negative(DnsTrustAnchor *d, const char *path, u
|
|||
if (r < 0)
|
||||
return log_warning_errno(r, "Unable to parse line %s:%u: %m", path, line);
|
||||
|
||||
if (!dns_name_is_valid(domain)) {
|
||||
r = dns_name_is_valid(domain);
|
||||
if (r < 0)
|
||||
return log_warning_errno(r, "Failed to chack validity of domain name '%s', at line %s:%u, ignoring line: %m", domain, path, line);
|
||||
if (r == 0) {
|
||||
log_warning("Domain name %s is invalid, at line %s:%u, ignoring line.", domain, path, line);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue