Lubomir Rintel 2019-07-03 09:27:43 +02:00
commit ce89e8b9b0
3 changed files with 36 additions and 15 deletions

View file

@ -766,10 +766,11 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
}
if (priv->device_mac_address && !nm_utils_hwaddr_valid (priv->device_mac_address, ETH_ALEN)) {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("is not a valid MAC address"));
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("'%s' is not a valid MAC address"),
priv->device_mac_address);
g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS);
return FALSE;
}
@ -831,10 +832,11 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
if ( priv->cloned_mac_address
&& !NM_CLONED_MAC_IS_SPECIAL (priv->cloned_mac_address)
&& !nm_utils_hwaddr_valid (priv->cloned_mac_address, ETH_ALEN)) {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("is not a valid MAC address"));
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("'%s' is not a valid MAC address"),
priv->cloned_mac_address);
g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_CLONED_MAC_ADDRESS);
return FALSE;
}
@ -873,10 +875,11 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
}
if (priv->wol_password && !nm_utils_hwaddr_valid (priv->wol_password, ETH_ALEN)) {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("is not a valid MAC address"));
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("'%s' is not a valid MAC address"),
priv->wol_password);
g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD);
return FALSE;
}

View file

@ -745,6 +745,16 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, char **argv)
NMConnection *connection;
NMSettingWired *s_wired;
if ( !nm_utils_hwaddr_valid (bootif, ETH_ALEN)
&& g_str_has_prefix (bootif, "01-")
&& nm_utils_hwaddr_valid (&bootif[3], ETH_ALEN)) {
/*
* BOOTIF MAC address can be prefixed with a hardware type identifier.
* "01" stays for "wired", no other are known.
*/
bootif += 3;
}
connection = get_conn (connections, NULL, NM_SETTING_WIRED_SETTING_NAME);
s_wired = nm_connection_get_setting_wired (connection);

View file

@ -286,8 +286,12 @@ static void
test_multiple (void)
{
gs_unref_hashtable GHashTable *connections = NULL;
gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=192.0.2.2:::::eth0", "ip=[2001:db8::2]:::::eth0", NULL });
gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=192.0.2.2:::::eth0",
"ip=[2001:db8::2]:::::eth0",
"BOOTIF=00:53:AB:cd:02:03",
NULL });
NMConnection *connection;
NMSettingWired *s_wired;
NMSettingIPConfig *s_ip4;
NMSettingIPConfig *s_ip6;
NMIPAddress *ip_addr;
@ -301,6 +305,10 @@ test_multiple (void)
nmtst_assert_connection_verifies_without_normalization (connection);
g_assert_cmpstr (nm_connection_get_id (connection), ==, "eth0");
s_wired = nm_connection_get_setting_wired (connection);
g_assert (s_wired);
g_assert_cmpstr (nm_setting_wired_get_mac_address (s_wired), ==, "00:53:AB:CD:02:03");
s_ip4 = nm_connection_get_setting_ip4_config (connection);
g_assert (s_ip4);
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL);
@ -326,7 +334,7 @@ test_some_more (void)
gs_unref_hashtable GHashTable *connections = NULL;
gs_strfreev char **argv = g_strdupv ((char *[]){ "bootdev=eth1", "hail", "nameserver=[2001:DB8:3::53]",
"satan", "nameserver=192.0.2.53", "worship",
"BOOTIF=00-53-AB-cd-02-03", "doom", "rd.peerdns=0",
"BOOTIF=01-00-53-AB-cd-02-03", "doom", "rd.peerdns=0",
"rd.route=[2001:DB8:3::/48]:[2001:DB8:2::1]:ens10",
NULL });
NMConnection *connection;
@ -407,7 +415,7 @@ static void
test_no_bootif (void)
{
gs_unref_hashtable GHashTable *connections = NULL;
gs_strfreev char **argv = g_strdupv ((char *[]){ "BOOTIF=00-53-AB-cd-02-03", "rd.bootif=0", NULL });
gs_strfreev char **argv = g_strdupv ((char *[]){ "BOOTIF=01-00-53-AB-cd-02-03", "rd.bootif=0", NULL });
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
g_assert (connections);