mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-09 12:00:36 +01:00
ifcfg-rh: fix dhcp-client-id
This commit is contained in:
parent
13c5e660de
commit
c6fe990ba4
2 changed files with 101 additions and 2 deletions
|
|
@ -428,7 +428,7 @@ make_ip4_setting (shvarFile *ifcfg, const char *network_file, GError **error)
|
|||
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME, value, NULL);
|
||||
g_free (value);
|
||||
|
||||
value = svGetValue (ifcfg, "DHCP_CLIENT_IDENTIFIER", FALSE);
|
||||
value = svGetValue (ifcfg, "DHCP_CLIENT_ID", FALSE);
|
||||
if (value && strlen (value))
|
||||
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, value, NULL);
|
||||
g_free (value);
|
||||
|
|
|
|||
|
|
@ -3327,7 +3327,7 @@ test_write_wired_static (void)
|
|||
/* IP4 setting */
|
||||
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
||||
ASSERT (s_ip4 != NULL,
|
||||
"connection-write", "failed to allocate new %s setting",
|
||||
"wired-static-write", "failed to allocate new %s setting",
|
||||
NM_SETTING_IP4_CONFIG_SETTING_NAME);
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
|
||||
|
||||
|
|
@ -3395,6 +3395,104 @@ test_write_wired_static (void)
|
|||
g_object_unref (reread);
|
||||
}
|
||||
|
||||
static void
|
||||
test_write_wired_dhcp (void)
|
||||
{
|
||||
NMConnection *connection;
|
||||
NMConnection *reread;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingIP4Config *s_ip4;
|
||||
char *uuid;
|
||||
gboolean success;
|
||||
GError *error = NULL;
|
||||
char *testfile = NULL;
|
||||
gboolean unmanaged = FALSE;
|
||||
char *keyfile = NULL;
|
||||
gboolean ignore_error = FALSE;
|
||||
|
||||
connection = nm_connection_new ();
|
||||
ASSERT (connection != NULL,
|
||||
"wired-dhcp-write", "failed to allocate new connection");
|
||||
|
||||
/* Connection setting */
|
||||
s_con = (NMSettingConnection *) nm_setting_connection_new ();
|
||||
ASSERT (s_con != NULL,
|
||||
"wired-dhcp-write", "failed to allocate new %s setting",
|
||||
NM_SETTING_CONNECTION_SETTING_NAME);
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_con));
|
||||
|
||||
uuid = nm_utils_uuid_generate ();
|
||||
g_object_set (s_con,
|
||||
NM_SETTING_CONNECTION_ID, "Auto Ethernet",
|
||||
NM_SETTING_CONNECTION_UUID, uuid,
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
|
||||
NULL);
|
||||
g_free (uuid);
|
||||
|
||||
/* Wired setting */
|
||||
s_wired = (NMSettingWired *) nm_setting_wired_new ();
|
||||
ASSERT (s_con != NULL,
|
||||
"wired-dhcp-write", "failed to allocate new %s setting",
|
||||
NM_SETTING_WIRED_SETTING_NAME);
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_wired));
|
||||
|
||||
/* IP4 setting */
|
||||
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
||||
ASSERT (s_ip4 != NULL,
|
||||
"wired-dhcp-write", "failed to allocate new %s setting",
|
||||
NM_SETTING_IP4_CONFIG_SETTING_NAME);
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
|
||||
|
||||
g_object_set (s_ip4,
|
||||
NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
|
||||
NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, "random-client-id-00:22:33",
|
||||
NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME, "awesome-hostname",
|
||||
NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, TRUE,
|
||||
NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, TRUE,
|
||||
NULL);
|
||||
|
||||
ASSERT (nm_connection_verify (connection, &error) == TRUE,
|
||||
"wired-dhcp-write", "failed to verify connection: %s",
|
||||
(error && error->message) ? error->message : "(unknown)");
|
||||
|
||||
/* Save the ifcfg */
|
||||
success = writer_new_connection (connection,
|
||||
TEST_DIR "/network-scripts/",
|
||||
&testfile,
|
||||
&error);
|
||||
ASSERT (success == TRUE,
|
||||
"wired-dhcp-write", "failed to write connection to disk: %s",
|
||||
(error && error->message) ? error->message : "(unknown)");
|
||||
|
||||
ASSERT (testfile != NULL,
|
||||
"wired-dhcp-write", "didn't get ifcfg file path back after writing connection");
|
||||
|
||||
/* re-read the connection for comparison */
|
||||
reread = connection_from_file (testfile,
|
||||
NULL,
|
||||
TYPE_ETHERNET,
|
||||
&unmanaged,
|
||||
&keyfile,
|
||||
&error,
|
||||
&ignore_error);
|
||||
unlink (testfile);
|
||||
|
||||
ASSERT (reread != NULL,
|
||||
"wired-dhcp-write-reread", "failed to read %s: %s", testfile, error->message);
|
||||
|
||||
ASSERT (nm_connection_verify (reread, &error),
|
||||
"wired-dhcp-write-reread-verify", "failed to verify %s: %s", testfile, error->message);
|
||||
|
||||
ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE,
|
||||
"wired-dhcp-write", "written and re-read connection weren't the same.");
|
||||
|
||||
g_free (testfile);
|
||||
g_object_unref (connection);
|
||||
g_object_unref (reread);
|
||||
}
|
||||
|
||||
#define TEST_IFCFG_WIFI_OPEN_SSID_BAD_HEX TEST_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-bad-hex"
|
||||
#define TEST_IFCFG_WIFI_OPEN_SSID_LONG_QUOTED TEST_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-long-quoted"
|
||||
#define TEST_IFCFG_WIFI_OPEN_SSID_LONG_HEX TEST_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-long-hex"
|
||||
|
|
@ -3437,6 +3535,7 @@ int main (int argc, char **argv)
|
|||
test_read_wifi_wep_eap_ttls_chap ();
|
||||
|
||||
test_write_wired_static ();
|
||||
test_write_wired_dhcp ();
|
||||
|
||||
basename = g_path_get_basename (argv[0]);
|
||||
fprintf (stdout, "%s: SUCCESS\n", basename);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue