mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-04 04:47:59 +02:00
ifcfg-rh: treat MODE=Auto as infrastructure mode
This commit is contained in:
parent
9c371949bf
commit
96a61a9909
4 changed files with 91 additions and 2 deletions
|
|
@ -1936,11 +1936,11 @@ make_wireless_setting (shvarFile *ifcfg,
|
|||
|
||||
if (!strcmp (lcase, "ad-hoc")) {
|
||||
mode = "adhoc";
|
||||
} else if (!strcmp (lcase, "managed")) {
|
||||
} else if (!strcmp (lcase, "managed") || !strcmp (lcase, "auto")) {
|
||||
mode = "infrastructure";
|
||||
} else {
|
||||
g_set_error (error, ifcfg_plugin_error_quark (), 0,
|
||||
"Invalid mode '%s' (not 'Ad-Hoc' or 'Managed')",
|
||||
"Invalid mode '%s' (not 'Ad-Hoc', 'Managed', or 'Auto')",
|
||||
lcase);
|
||||
g_free (lcase);
|
||||
goto error;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ EXTRA_DIST = \
|
|||
keys-test-wired-8021x-peap-mschapv2 \
|
||||
ifcfg-test-onboot-no \
|
||||
ifcfg-test-wifi-open \
|
||||
ifcfg-test-wifi-open-auto \
|
||||
ifcfg-test-wifi-open-ssid-quoted \
|
||||
ifcfg-test-wifi-open-ssid-long-quoted \
|
||||
ifcfg-test-wifi-open-ssid-hex \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
TYPE=Wireless
|
||||
DEVICE=eth2
|
||||
HWADDR=00:16:41:11:22:33
|
||||
NM_CONTROLLED=yes
|
||||
BOOTPROTO=dhcp
|
||||
ESSID=blahblah
|
||||
CHANNEL=1
|
||||
MODE=Auto
|
||||
RATE=auto
|
||||
ONBOOT=yes
|
||||
USERCTL=yes
|
||||
PEERDNS=yes
|
||||
IPV6INIT=no
|
||||
|
|
@ -1584,6 +1584,80 @@ test_read_wifi_open (void)
|
|||
g_object_unref (connection);
|
||||
}
|
||||
|
||||
#define TEST_IFCFG_WIFI_OPEN_AUTO TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-auto"
|
||||
|
||||
static void
|
||||
test_read_wifi_open_auto (void)
|
||||
{
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWireless *s_wireless;
|
||||
char *unmanaged = NULL;
|
||||
char *keyfile = NULL;
|
||||
gboolean ignore_error = FALSE;
|
||||
GError *error = NULL;
|
||||
const char *tmp;
|
||||
const char *expected_id = "System blahblah (test-wifi-open-auto)";
|
||||
const char *expected_mode = "infrastructure";
|
||||
|
||||
connection = connection_from_file (TEST_IFCFG_WIFI_OPEN_AUTO,
|
||||
NULL,
|
||||
TYPE_WIRELESS,
|
||||
NULL,
|
||||
&unmanaged,
|
||||
&keyfile,
|
||||
&error,
|
||||
&ignore_error);
|
||||
ASSERT (connection != NULL,
|
||||
"wifi-open-auto-read", "failed to read %s: %s", TEST_IFCFG_WIFI_OPEN_AUTO, error->message);
|
||||
|
||||
ASSERT (nm_connection_verify (connection, &error),
|
||||
"wifi-open-auto-verify", "failed to verify %s: %s", TEST_IFCFG_WIFI_OPEN_AUTO, error->message);
|
||||
|
||||
/* ===== CONNECTION SETTING ===== */
|
||||
|
||||
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
|
||||
ASSERT (s_con != NULL,
|
||||
"wifi-open-auto-verify-connection", "failed to verify %s: missing %s setting",
|
||||
TEST_IFCFG_WIFI_OPEN_AUTO,
|
||||
NM_SETTING_CONNECTION_SETTING_NAME);
|
||||
|
||||
/* ID */
|
||||
tmp = nm_setting_connection_get_id (s_con);
|
||||
ASSERT (tmp != NULL,
|
||||
"wifi-open-auto-verify-connection", "failed to verify %s: missing %s / %s key",
|
||||
TEST_IFCFG_WIFI_OPEN_AUTO,
|
||||
NM_SETTING_CONNECTION_SETTING_NAME,
|
||||
NM_SETTING_CONNECTION_ID);
|
||||
ASSERT (strcmp (tmp, expected_id) == 0,
|
||||
"wifi-open-auto-verify-connection", "failed to verify %s: unexpected %s / %s key value",
|
||||
TEST_IFCFG_WIFI_OPEN_AUTO,
|
||||
NM_SETTING_CONNECTION_SETTING_NAME,
|
||||
NM_SETTING_CONNECTION_ID);
|
||||
|
||||
/* ===== WIRELESS SETTING ===== */
|
||||
|
||||
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
|
||||
ASSERT (s_wireless != NULL,
|
||||
"wifi-open-auto-verify-wireless", "failed to verify %s: missing %s setting",
|
||||
TEST_IFCFG_WIFI_OPEN_AUTO,
|
||||
NM_SETTING_WIRELESS_SETTING_NAME);
|
||||
|
||||
tmp = nm_setting_wireless_get_mode (s_wireless);
|
||||
ASSERT (tmp != NULL,
|
||||
"wifi-open-auto-verify-wireless", "failed to verify %s: missing %s / %s key",
|
||||
TEST_IFCFG_WIFI_OPEN_AUTO,
|
||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
NM_SETTING_WIRELESS_MODE);
|
||||
ASSERT (strcmp (tmp, expected_mode) == 0,
|
||||
"wifi-open-auto-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
|
||||
TEST_IFCFG_WIFI_OPEN_AUTO,
|
||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
NM_SETTING_WIRELESS_MODE);
|
||||
|
||||
g_object_unref (connection);
|
||||
}
|
||||
|
||||
#define TEST_IFCFG_WIFI_OPEN_SSID_HEX TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-hex"
|
||||
|
||||
static void
|
||||
|
|
@ -5974,6 +6048,7 @@ int main (int argc, char **argv)
|
|||
test_read_onboot_no ();
|
||||
test_read_wired_8021x_peap_mschapv2 ();
|
||||
test_read_wifi_open ();
|
||||
test_read_wifi_open_auto ();
|
||||
test_read_wifi_open_ssid_hex ();
|
||||
test_read_wifi_open_ssid_bad (TEST_IFCFG_WIFI_OPEN_SSID_BAD_HEX, "wifi-open-ssid-bad-hex-read");
|
||||
test_read_wifi_open_ssid_bad (TEST_IFCFG_WIFI_OPEN_SSID_LONG_HEX, "wifi-open-ssid-long-hex-read");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue