mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 18:20:29 +01:00
merge: branch 'jv/accept-localhost-persistent'
policy: accept localhost hostnames if statically configured https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2114
This commit is contained in:
commit
63b81d893e
4 changed files with 18 additions and 6 deletions
|
|
@ -271,8 +271,7 @@ no-auto-default=*
|
|||
Set the management mode of the hostname. This parameter will
|
||||
affect only the transient hostname. If a valid static hostname is set,
|
||||
NetworkManager will skip the update of the hostname despite the value of
|
||||
this option. An hostname empty or equal to 'localhost', 'localhost6',
|
||||
'localhost.localdomain' or 'localhost6.localdomain' is considered invalid.
|
||||
this option. A hostname empty or equal to '(none)' is considered invalid.
|
||||
</para>
|
||||
<para><literal>default</literal>: NetworkManager will update the
|
||||
hostname with the one provided via DHCP or reverse DNS lookup of the
|
||||
|
|
|
|||
|
|
@ -960,7 +960,7 @@ update_system_hostname(NMPolicy *self, const char *msg, gboolean reset_retry_int
|
|||
|
||||
/* Try a persistent hostname first */
|
||||
configured_hostname = nm_hostname_manager_get_static_hostname(priv->hostname_manager);
|
||||
if (configured_hostname && nm_utils_is_specific_hostname(configured_hostname)) {
|
||||
if (configured_hostname && nm_utils_is_not_empty_hostname(configured_hostname)) {
|
||||
_set_hostname(self, configured_hostname, "from system configuration", FALSE);
|
||||
priv->dhcp_hostname = FALSE;
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -6004,8 +6004,8 @@ nm_utils_is_localhost(const char *name)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_is_specific_hostname(const char *name)
|
||||
static gboolean
|
||||
_nm_utils_check_hostname(const char *name, bool allow_localhost)
|
||||
{
|
||||
if (nm_str_is_empty(name))
|
||||
return FALSE;
|
||||
|
|
@ -6016,7 +6016,7 @@ nm_utils_is_specific_hostname(const char *name)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (nm_utils_is_localhost(name))
|
||||
if (!allow_localhost && nm_utils_is_localhost(name))
|
||||
return FALSE;
|
||||
|
||||
/* FIXME: properly validate the hostname, like systemd's hostname_is_valid() */
|
||||
|
|
@ -6024,6 +6024,18 @@ nm_utils_is_specific_hostname(const char *name)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_is_specific_hostname(const char *name)
|
||||
{
|
||||
return _nm_utils_check_hostname(name, FALSE);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_is_not_empty_hostname(const char *name)
|
||||
{
|
||||
return _nm_utils_check_hostname(name, TRUE);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -3419,6 +3419,7 @@ char *_nm_utils_format_variant_attributes(GHashTable *a
|
|||
gboolean nm_utils_is_localhost(const char *name);
|
||||
|
||||
gboolean nm_utils_is_specific_hostname(const char *name);
|
||||
gboolean nm_utils_is_not_empty_hostname(const char *name);
|
||||
|
||||
struct passwd;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue