diff options
-rw-r--r-- | clients/cli/connections.c | 47 | ||||
-rw-r--r-- | clients/cli/devices.c | 257 | ||||
-rw-r--r-- | clients/cli/nmcli.h | 5 | ||||
-rw-r--r-- | clients/tests/test-client.check-on-disk/test_003.expected | 36 | ||||
-rwxr-xr-x | clients/tests/test-client.py | 2 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | data/meson.build | 2 | ||||
-rw-r--r-- | dispatcher/meson.build | 1 | ||||
-rw-r--r-- | libnm-core/nm-setting-ip-config.c | 9 | ||||
-rw-r--r-- | libnm-core/nm-version.h | 14 | ||||
-rw-r--r-- | libnm-core/tests/test-setting.c | 4 | ||||
-rw-r--r-- | libnm/meson.build | 2 | ||||
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | shared/meson.build | 24 | ||||
-rw-r--r-- | shared/nm-utils/tests/meson.build | 22 | ||||
-rw-r--r-- | shared/nm-version-macros.h.in | 1 | ||||
-rw-r--r-- | src/devices/nm-device-bond.c | 10 | ||||
-rw-r--r-- | src/devices/nm-device-bridge.c | 10 | ||||
-rw-r--r-- | src/devices/team/nm-device-team.c | 10 | ||||
-rw-r--r-- | src/meson.build | 3 |
20 files changed, 260 insertions, 205 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index e365980eb0..b8905cc78a 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -2933,7 +2933,8 @@ do_connection_up (NmCli *nmc, int argc, char **argv) pwds = *argv; } else if (!nmc->complete) { - g_printerr (_("Unknown parameter: %s\n"), *argv); + g_string_printf (nmc->return_text, _("Error: invalid extra argument '%s'."), *argv); + return NMC_RESULT_ERROR_USER_INPUT; } next_arg (nmc, &argc, &argv, NULL); @@ -3135,7 +3136,7 @@ do_connection_down (NmCli *nmc, int argc, char **argv) } if (arg_num == 0) { g_string_printf (nmc->return_text, _("Error: No connection specified.")); - NMC_RETURN (nmc, NMC_RESULT_ERROR_USER_INPUT); + return NMC_RESULT_ERROR_USER_INPUT; } } @@ -3153,7 +3154,7 @@ do_connection_down (NmCli *nmc, int argc, char **argv) arg_ptr++; if (!arg_num) { g_string_printf (nmc->return_text, _("Error: %s argument is missing."), selector); - NMC_RETURN (nmc, NMC_RESULT_ERROR_USER_INPUT); + return NMC_RESULT_ERROR_USER_INPUT; } } @@ -3174,7 +3175,7 @@ do_connection_down (NmCli *nmc, int argc, char **argv) if (!found_active_cons) { g_string_printf (nmc->return_text, _("Error: no active connection provided.")); - NMC_RETURN (nmc, NMC_RESULT_ERROR_NOT_FOUND); + return NMC_RESULT_ERROR_NOT_FOUND; } nm_assert (found_active_cons->len > 0); @@ -8220,7 +8221,7 @@ do_connection_edit (NmCli *nmc, int argc, char **argv) else { if (!nmc_parse_args (exp_args, TRUE, &argc, &argv, &error)) { g_string_assign (nmc->return_text, error->message); - NMC_RETURN (nmc, error->code); + return error->code; } } @@ -8250,7 +8251,7 @@ do_connection_edit (NmCli *nmc, int argc, char **argv) } else { g_string_printf (nmc->return_text, _("Error: only one of 'id', 'filename', uuid, or 'path' can be provided.")); - NMC_RETURN (nmc, NMC_RESULT_ERROR_USER_INPUT); + return NMC_RESULT_ERROR_USER_INPUT; } } @@ -8264,7 +8265,7 @@ do_connection_edit (NmCli *nmc, int argc, char **argv) if (!found_con) { g_string_printf (nmc->return_text, _("Error: Unknown connection '%s'."), con); - NMC_RETURN (nmc, NMC_RESULT_ERROR_NOT_FOUND); + return NMC_RESULT_ERROR_NOT_FOUND; } /* Duplicate the connection and use that so that we need not @@ -8418,7 +8419,7 @@ do_connection_modify (NmCli *nmc, connection = get_connection (nmc, &argc, &argv, NULL, NULL, NULL, &error); if (!connection) { g_string_printf (nmc->return_text, _("Error: %s."), error->message); - NMC_RETURN (nmc, error->code); + return error->code; } rc = nm_client_get_connection_by_uuid (nmc->client, @@ -8426,12 +8427,12 @@ do_connection_modify (NmCli *nmc, if (!rc) { g_string_printf (nmc->return_text, _("Error: Unknown connection '%s'."), nm_connection_get_uuid (connection)); - NMC_RETURN (nmc, NMC_RESULT_ERROR_NOT_FOUND); + return NMC_RESULT_ERROR_NOT_FOUND; } if (!nmc_read_connection_properties (nmc, NM_CONNECTION (rc), &argc, &argv, &error)) { g_string_assign (nmc->return_text, error->message); - NMC_RETURN (nmc, error->code); + return error->code; } if (nmc->complete) @@ -8509,7 +8510,7 @@ do_connection_clone (NmCli *nmc, int argc, char **argv) connection = get_connection (nmc, argc_ptr, argv_ptr, NULL, NULL, NULL, &error); if (!connection) { g_string_printf (nmc->return_text, _("Error: %s."), error->message); - NMC_RETURN (nmc, error->code); + return error->code; } if (nmc->complete) @@ -8522,12 +8523,12 @@ do_connection_clone (NmCli *nmc, int argc, char **argv) _("New connection name: ")); } else { g_string_printf (nmc->return_text, _("Error: <new name> argument is missing.")); - NMC_RETURN (nmc, NMC_RESULT_ERROR_USER_INPUT); + return NMC_RESULT_ERROR_USER_INPUT; } if (next_arg (nmc->ask ? NULL : nmc, argc_ptr, argv_ptr, NULL) == 0) { g_string_printf (nmc->return_text, _("Error: unknown extra argument: '%s'."), *argv); - NMC_RETURN (nmc, NMC_RESULT_ERROR_USER_INPUT); + return NMC_RESULT_ERROR_USER_INPUT; } new_connection = nm_simple_connection_new_clone (connection); @@ -8858,7 +8859,7 @@ do_connection_import (NmCli *nmc, int argc, char **argv) filename = nm_strstrip (filename_ask); } else { g_string_printf (nmc->return_text, _("Error: No arguments provided.")); - NMC_RETURN (nmc, NMC_RESULT_ERROR_USER_INPUT); + return NMC_RESULT_ERROR_USER_INPUT; } } @@ -8874,7 +8875,7 @@ do_connection_import (NmCli *nmc, int argc, char **argv) argv++; if (!argc) { g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1)); - NMC_RETURN (nmc, NMC_RESULT_ERROR_USER_INPUT); + return NMC_RESULT_ERROR_USER_INPUT; } if ( argc == 1 @@ -8895,7 +8896,7 @@ do_connection_import (NmCli *nmc, int argc, char **argv) argv++; if (!argc) { g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1)); - NMC_RETURN (nmc, NMC_RESULT_ERROR_USER_INPUT); + return NMC_RESULT_ERROR_USER_INPUT; } if (argc == 1 && nmc->complete) nmc->return_value = NMC_RESULT_COMPLETE_FILE; @@ -8904,8 +8905,8 @@ do_connection_import (NmCli *nmc, int argc, char **argv) else g_printerr (_("Warning: 'file' already specified, ignoring extra one.\n")); } else { - g_string_printf (nmc->return_text, _("Unknown parameter: %s"), *argv); - NMC_RETURN (nmc, NMC_RESULT_ERROR_USER_INPUT); + g_string_printf (nmc->return_text, _("Error: invalid extra argument '%s'."), *argv); + return NMC_RESULT_ERROR_USER_INPUT; } next_arg (nmc, &argc, &argv, NULL); @@ -8916,11 +8917,11 @@ do_connection_import (NmCli *nmc, int argc, char **argv) if (!type) { g_string_printf (nmc->return_text, _("Error: 'type' argument is required.")); - NMC_RETURN (nmc, NMC_RESULT_ERROR_USER_INPUT); + return NMC_RESULT_ERROR_USER_INPUT; } if (!filename) { g_string_printf (nmc->return_text, _("Error: 'file' argument is required.")); - NMC_RETURN (nmc, NMC_RESULT_ERROR_USER_INPUT); + return NMC_RESULT_ERROR_USER_INPUT; } if (nm_streq (type, "wireguard")) @@ -8929,7 +8930,7 @@ do_connection_import (NmCli *nmc, int argc, char **argv) service_type = nm_vpn_plugin_info_list_find_service_type (nm_vpn_get_plugin_infos (), type); if (!service_type) { g_string_printf (nmc->return_text, _("Error: failed to find VPN plugin for %s."), type); - NMC_RETURN (nmc, NMC_RESULT_ERROR_UNKNOWN); + return NMC_RESULT_ERROR_UNKNOWN; } /* Import VPN configuration */ @@ -8937,7 +8938,7 @@ do_connection_import (NmCli *nmc, int argc, char **argv) if (!plugin) { g_string_printf (nmc->return_text, _("Error: failed to load VPN plugin: %s."), error->message); - NMC_RETURN (nmc, NMC_RESULT_ERROR_UNKNOWN); + return NMC_RESULT_ERROR_UNKNOWN; } connection = nm_vpn_editor_plugin_import (plugin, filename, &error); @@ -8946,7 +8947,7 @@ do_connection_import (NmCli *nmc, int argc, char **argv) if (!connection) { g_string_printf (nmc->return_text, _("Error: failed to import '%s': %s."), filename, error->message); - NMC_RETURN (nmc, NMC_RESULT_ERROR_UNKNOWN); + return NMC_RESULT_ERROR_UNKNOWN; } add_connection (nmc->client, diff --git a/clients/cli/devices.c b/clients/cli/devices.c index c00d3191a9..8354fcac75 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -1681,9 +1681,9 @@ do_devices_status (NmCli *nmc, int argc, char **argv) if (nmc->complete) return nmc->return_value; - while (argc > 0) { - g_printerr (_("Unknown parameter: %s\n"), *argv); - next_arg (nmc, &argc, &argv, NULL); + if (argc) { + g_string_printf (nmc->return_text, _("Error: invalid extra argument '%s'."), *argv); + return NMC_RESULT_ERROR_USER_INPUT; } if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0) @@ -1836,20 +1836,52 @@ connected_state_cb (NMDevice *device, NMActiveConnection *active) typedef struct { NmCli *nmc; NMDevice *device; - gboolean hotspot; - gboolean create; + char *specific_object; + bool hotspot:1; + bool create:1; } AddAndActivateInfo; +static AddAndActivateInfo * +add_and_activate_info_new (NmCli *nmc, + NMDevice *device, + gboolean hotspot, + gboolean create, + const char *specific_object) +{ + AddAndActivateInfo *info; + + info = g_slice_new (AddAndActivateInfo); + *info = (AddAndActivateInfo) { + .nmc = nmc, + .device = g_object_ref (device), + .hotspot = hotspot, + .create = create, + .specific_object = g_strdup (specific_object), + }; + return info; +} + +static void +add_and_activate_info_free (AddAndActivateInfo *info) +{ + g_object_unref (info->device); + g_free (info->specific_object); + nm_g_slice_free (info); +} + +NM_AUTO_DEFINE_FCN0 (AddAndActivateInfo *, _nm_auto_free_add_and_activate_info, add_and_activate_info_free) +#define nm_auto_free_add_and_activate_info nm_auto (_nm_auto_free_add_and_activate_info) + static void add_and_activate_cb (GObject *client, GAsyncResult *result, gpointer user_data) { - AddAndActivateInfo *info = (AddAndActivateInfo *) user_data; + nm_auto_free_add_and_activate_info AddAndActivateInfo *info = user_data; NmCli *nmc = info->nmc; NMDevice *device = info->device; - NMActiveConnection *active; - GError *error = NULL; + gs_unref_object NMActiveConnection *active = NULL; + gs_free_error GError *error = NULL; if (info->create) active = nm_client_add_and_activate_connection_finish (NM_CLIENT (client), result, &error); @@ -1857,37 +1889,36 @@ add_and_activate_cb (GObject *client, active = nm_client_activate_connection_finish (NM_CLIENT (client), result, &error); if (error) { - if (info->hotspot) + if (info->hotspot) { g_string_printf (nmc->return_text, _("Error: Failed to setup a Wi-Fi hotspot: %s"), error->message); - else if (info->create) + } else if (info->create) { g_string_printf (nmc->return_text, _("Error: Failed to add/activate new connection: %s"), error->message); - else + } else { g_string_printf (nmc->return_text, _("Error: Failed to activate connection: %s"), error->message); - g_error_free (error); + } nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION; quit (); - } else { - if (nmc->nowait_flag) { - g_object_unref (active); - quit (); - } else { - g_object_ref (device); - g_signal_connect (device, "notify::state", G_CALLBACK (device_state_cb), active); - g_signal_connect (active, "notify::state", G_CALLBACK (active_state_cb), device); + return; + } - connected_state_cb (device, active); + if (nmc->nowait_flag) { + quit (); + return; + } - g_timeout_add_seconds (nmc->timeout, timeout_cb, nmc); /* Exit if timeout expires */ + g_signal_connect (device, "notify::state", G_CALLBACK (device_state_cb), active); + g_signal_connect (active, "notify::state", G_CALLBACK (active_state_cb), device); - if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY) - progress_id = g_timeout_add (120, progress_cb, device); - } - } + connected_state_cb (g_object_ref (device), + g_steal_pointer (&active)); - g_free (info); + g_timeout_add_seconds (nmc->timeout, timeout_cb, nmc); /* Exit if timeout expires */ + + if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY) + progress_id = g_timeout_add (120, progress_cb, device); } static void @@ -1916,9 +1947,9 @@ create_connect_connection_for_device (AddAndActivateInfo *info) static void connect_device_cb (GObject *client, GAsyncResult *result, gpointer user_data) { - AddAndActivateInfo *info = (AddAndActivateInfo *) user_data; + nm_auto_free_add_and_activate_info AddAndActivateInfo *info = user_data; NmCli *nmc = info->nmc; - NMActiveConnection *active; + gs_unref_object NMActiveConnection *active = NULL; GError *error = NULL; const GPtrArray *devices; NMDevice *device; @@ -1929,7 +1960,7 @@ connect_device_cb (GObject *client, GAsyncResult *result, gpointer user_data) /* If no connection existed for the device, create one and activate it */ if (g_error_matches (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_CONNECTION)) { info->create = TRUE; - create_connect_connection_for_device (info); + create_connect_connection_for_device (g_steal_pointer (&info)); return; } @@ -1938,42 +1969,41 @@ connect_device_cb (GObject *client, GAsyncResult *result, gpointer user_data) g_error_free (error); nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION; quit (); - } else { - g_assert (active); - devices = nm_active_connection_get_devices (active); - if (devices->len == 0) { - g_string_printf (nmc->return_text, _("Error: Device activation failed: device was disconnected")); - nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION; - g_object_unref (active); - quit (); - g_free (info); - return; - } + return; + } - device = g_ptr_array_index (devices, 0); + nm_assert (NM_IS_ACTIVE_CONNECTION (active)); - if (nmc->nowait_flag) { - g_object_unref (active); - quit (); - } else { - if (nmc->secret_agent) { - NMRemoteConnection *connection = nm_active_connection_get_connection (active); + devices = nm_active_connection_get_devices (active); + if (devices->len == 0) { + g_string_printf (nmc->return_text, _("Error: Device activation failed: device was disconnected")); + nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION; + quit (); + return; + } - nm_secret_agent_simple_enable (nmc->secret_agent, - nm_connection_get_path (NM_CONNECTION (connection))); - } + device = g_ptr_array_index (devices, 0); - g_object_ref (device); - g_signal_connect (device, "notify::state", G_CALLBACK (device_state_cb), active); - g_signal_connect (active, "notify::state", G_CALLBACK (active_state_cb), device); + if (nmc->nowait_flag) { + quit (); + return; + } - connected_state_cb (device, active); + if (nmc->secret_agent) { + NMRemoteConnection *connection = nm_active_connection_get_connection (active); - /* Start timer not to loop forever if "notify::state" signal is not issued */ - g_timeout_add_seconds (nmc->timeout, timeout_cb, nmc); - } + nm_secret_agent_simple_enable (nmc->secret_agent, + nm_connection_get_path (NM_CONNECTION (connection))); } - g_free (info); + + g_signal_connect (device, "notify::state", G_CALLBACK (device_state_cb), active); + g_signal_connect (active, "notify::state", G_CALLBACK (active_state_cb), device); + + connected_state_cb (g_object_ref (device), + g_steal_pointer (&active)); + + /* Start timer not to loop forever if "notify::state" signal is not issued */ + g_timeout_add_seconds (nmc->timeout, timeout_cb, nmc); } static NMCResultCode @@ -2018,10 +2048,7 @@ do_device_connect (NmCli *nmc, int argc, char **argv) nmc); } - info = g_malloc0 (sizeof (AddAndActivateInfo)); - info->nmc = nmc; - info->device = device; - info->hotspot = FALSE; + info = add_and_activate_info_new (nmc, device, FALSE, FALSE, NULL); nm_client_activate_connection_async (nmc->client, NULL, /* let NM find a connection automatically */ @@ -3027,8 +3054,10 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv) if (nmc->complete) return nmc->return_value; - if (argc) - g_printerr (_("Unknown parameter: %s\n"), *argv); + if (argc) { + g_string_printf (nmc->return_text, _("Error: invalid extra argument '%s'."), *argv); + return NMC_RESULT_ERROR_USER_INPUT; + } if (rescan == NULL || strcmp (rescan, "auto") == 0) { rescan_cutoff = NM_MAX (nm_utils_get_timestamp_msec () - 30 * NM_UTILS_MSEC_PER_SECOND, 0); @@ -3116,14 +3145,43 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv) return nmc->return_value; } +static void +activate_update2_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) +{ + NMRemoteConnection *remote_con = NM_REMOTE_CONNECTION (source_object); + nm_auto_free_add_and_activate_info AddAndActivateInfo *info = user_data; + NmCli *nmc = info->nmc; + gs_unref_variant GVariant *ret = NULL; + GError *error = NULL; + + ret = nm_remote_connection_update2_finish (remote_con, res, &error); + + if (!ret) { + g_string_printf (nmc->return_text, _("Error: %s."), error->message); + nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; + g_error_free (error); + quit (); + return; + } + + nm_client_activate_connection_async (nmc->client, + NM_CONNECTION (remote_con), + info->device, + info->specific_object, + NULL, + add_and_activate_cb, + g_steal_pointer (&info)); +} + static NMCResultCode -do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv) +do_device_wifi_connect (NmCli *nmc, int argc, char **argv) { NMDevice *device = NULL; NMAccessPoint *ap = NULL; NM80211ApFlags ap_flags; NM80211ApSecurityFlags ap_wpa_flags; NM80211ApSecurityFlags ap_rsn_flags; + NMRemoteConnection *remote_con = NULL; NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; @@ -3144,7 +3202,6 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv) char *passwd_ask = NULL; const GPtrArray *avail_cons; gboolean name_match = FALSE; - gboolean existing_con = FALSE; int i; /* Set default timeout waiting for operation completion. */ @@ -3291,7 +3348,9 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv) goto finish; } } else if (!nmc->complete) { - g_printerr (_("Unknown parameter: %s\n"), *argv); + g_string_printf (nmc->return_text, _("Error: invalid extra argument '%s'."), *argv); + nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; + goto finish; } next_arg (nmc, &argc, &argv, NULL); @@ -3391,22 +3450,22 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv) /* ap has been checked against bssid1, bssid2 and the ssid * and now avail_con has been checked against ap. */ - connection = NM_CONNECTION (avail_con); - existing_con = TRUE; + remote_con = avail_con; + connection = NM_CONNECTION (remote_con); break; } } - if (name_match && !existing_con) { + if (name_match && !remote_con) { g_string_printf (nmc->return_text, _("Error: Connection '%s' exists but properties don't match."), con_name); nmc->return_value = NMC_RESULT_ERROR_NOT_FOUND; goto finish; } - if (!existing_con) { + if (!remote_con) { /* If there are some connection data from user, create a connection and * fill them into proper settings. */ - if (con_name || private || bssid2_arr || password || hidden) + if (con_name || private || bssid2_arr || hidden) connection = nm_simple_connection_new (); if (con_name || private) { @@ -3518,24 +3577,21 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv) nmc->nowait_flag = (nmc->timeout == 0); nmc->should_wait++; - info = g_malloc0 (sizeof (AddAndActivateInfo)); - info->nmc = nmc; - info->device = device; - info->hotspot = FALSE; - info->create = !existing_con; - if (existing_con) { - nm_client_activate_connection_async (nmc->client, - connection, - device, - nm_object_get_path (NM_OBJECT (ap)), - NULL, - add_and_activate_cb, - info); + info = add_and_activate_info_new (nmc, device, FALSE, !remote_con, nm_object_get_path (NM_OBJECT (ap))); + + if (remote_con) { + nm_remote_connection_update2 (remote_con, + nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL), + NM_SETTINGS_UPDATE2_FLAG_BLOCK_AUTOCONNECT, + NULL, + NULL, + activate_update2_cb, + info); } else { nm_client_add_and_activate_connection_async (nmc->client, connection, - device, - nm_object_get_path (NM_OBJECT (ap)), + info->device, + info->specific_object, NULL, add_and_activate_cb, info); @@ -3784,7 +3840,7 @@ do_device_wifi_hotspot (NmCli *nmc, int argc, char **argv) } else if (nmc_arg_is_option (*argv, "show-password")) { show_password = TRUE; } else { - g_string_printf (nmc->return_text, _("Error: Unknown parameter %s."), *argv); + g_string_printf (nmc->return_text, _("Error: invalid extra argument '%s'."), *argv); return NMC_RESULT_ERROR_USER_INPUT; } @@ -3888,11 +3944,7 @@ do_device_wifi_hotspot (NmCli *nmc, int argc, char **argv) nmc->nowait_flag = (nmc->timeout == 0); nmc->should_wait++; - info = g_malloc0 (sizeof (AddAndActivateInfo)); - info->nmc = nmc; - info->device = device; - info->hotspot = TRUE; - info->create = TRUE; + info = add_and_activate_info_new (nmc, device, TRUE, TRUE, NULL); nm_client_add_and_activate_connection_async (nmc->client, connection, @@ -3966,8 +4018,11 @@ do_device_wifi_rescan (NmCli *nmc, int argc, char **argv) goto finish; } g_ptr_array_add (ssids, *argv); - } else if (!nmc->complete) - g_printerr (_("Unknown parameter: %s\n"), *argv); + } else if (!nmc->complete) { + g_string_printf (nmc->return_text, _("Error: invalid extra argument '%s'."), *argv); + nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; + goto finish; + } next_arg (nmc, &argc, &argv, NULL); } @@ -4013,11 +4068,11 @@ finish: } static NMCCommand device_wifi_cmds[] = { - { "list", do_device_wifi_list, NULL, TRUE, TRUE }, - { "connect", do_device_wifi_connect_network, NULL, TRUE, TRUE }, - { "hotspot", do_device_wifi_hotspot, NULL, TRUE, TRUE }, - { "rescan", do_device_wifi_rescan, NULL, TRUE, TRUE }, - { NULL, do_device_wifi_list, NULL, TRUE, TRUE }, + { "list", do_device_wifi_list, NULL, TRUE, TRUE }, + { "connect", do_device_wifi_connect, NULL, TRUE, TRUE }, + { "hotspot", do_device_wifi_hotspot, NULL, TRUE, TRUE }, + { "rescan", do_device_wifi_rescan, NULL, TRUE, TRUE }, + { NULL, do_device_wifi_list, NULL, TRUE, TRUE }, }; static NMCResultCode diff --git a/clients/cli/nmcli.h b/clients/cli/nmcli.h index cd50333a99..1c4b4a2d89 100644 --- a/clients/cli/nmcli.h +++ b/clients/cli/nmcli.h @@ -149,11 +149,6 @@ typedef struct _NmCli { char *palette_buffer; /* Buffer with sequences for terminal-colors.d(5)-based coloring. */ } NmCli; -#define NMC_RETURN(nmc, rvalue) \ - G_STMT_START { \ - return ((nmc)->return_value = (rvalue)); \ - } G_STMT_END - extern NmCli nm_cli; /* Error quark for GError domain */ diff --git a/clients/tests/test-client.check-on-disk/test_003.expected b/clients/tests/test-client.check-on-disk/test_003.expected index 20980164e9..c8cb4903b5 100644 --- a/clients/tests/test-client.check-on-disk/test_003.expected +++ b/clients/tests/test-client.check-on-disk/test_003.expected @@ -892,9 +892,9 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 1459 +size: 1409 location: clients/tests/test-client.py:951:test_003()/31 -cmd: $NMCLI -f ALL dev s eth0 +cmd: $NMCLI -f ALL dev status lang: C returncode: 0 stdout: 1272 bytes @@ -907,14 +907,9 @@ wlan1 wifi unavailable unknown unknown /org/freedesk wlan1 wifi unavailable unknown unknown /org/freedesktop/NetworkManager/Devices/5 -- -- -- <<< -stderr: 24 bytes ->>> -Unknown parameter: eth0 - -<<< -size: 1474 +size: 1424 location: clients/tests/test-client.py:951:test_003()/32 -cmd: $NMCLI -f ALL dev s eth0 +cmd: $NMCLI -f ALL dev status lang: pl_PL.UTF-8 returncode: 0 stdout: 1277 bytes @@ -927,11 +922,6 @@ wlan1 wifi niedostępne nieznane nieznane /org/freedes wlan1 wifi niedostępne nieznane nieznane /org/freedesktop/NetworkManager/Devices/5 -- -- -- <<< -stderr: 24 bytes ->>> -Nieznany parametr: eth0 - -<<< size: 3494 location: clients/tests/test-client.py:954:test_003()/33 cmd: $NMCLI -f ALL dev show eth0 @@ -1782,9 +1772,9 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 1459 +size: 1409 location: clients/tests/test-client.py:951:test_003()/54 -cmd: $NMCLI -f ALL dev s eth0 +cmd: $NMCLI -f ALL dev status lang: C returncode: 0 stdout: 1272 bytes @@ -1797,14 +1787,9 @@ wlan1 wifi unavailable unknown unknown /org/freedesk wlan1 wifi unavailable unknown unknown /org/freedesktop/NetworkManager/Devices/5 -- -- -- <<< -stderr: 24 bytes ->>> -Unknown parameter: eth0 - -<<< -size: 1474 +size: 1424 location: clients/tests/test-client.py:951:test_003()/55 -cmd: $NMCLI -f ALL dev s eth0 +cmd: $NMCLI -f ALL dev status lang: pl_PL.UTF-8 returncode: 0 stdout: 1277 bytes @@ -1817,11 +1802,6 @@ wlan1 wifi niedostępne nieznane nieznane /org/freedes wlan1 wifi niedostępne nieznane nieznane /org/freedesktop/NetworkManager/Devices/5 -- -- -- <<< -stderr: 24 bytes ->>> -Nieznany parametr: eth0 - -<<< size: 3494 location: clients/tests/test-client.py:954:test_003()/56 cmd: $NMCLI -f ALL dev show eth0 diff --git a/clients/tests/test-client.py b/clients/tests/test-client.py index ff5a3604dd..307a1182f3 100755 --- a/clients/tests/test-client.py +++ b/clients/tests/test-client.py @@ -947,7 +947,7 @@ class TestNmcli(NmTestBase): self.call_nmcli_l(['con', 's', 'ethernet'], replace_stdout = replace_stdout) - self.call_nmcli_l(['-f', 'ALL', 'dev', 's', 'eth0'], + self.call_nmcli_l(['-f', 'ALL', 'dev', 'status'], replace_stdout = replace_stdout) self.call_nmcli_l(['-f', 'ALL', 'dev', 'show', 'eth0'], diff --git a/configure.ac b/configure.ac index 2d0e92522d..951f51b9a0 100644 --- a/configure.ac +++ b/configure.ac @@ -7,8 +7,8 @@ dnl - add corresponding NM_VERSION_x_y_z macros in dnl "shared/nm-version-macros.h.in" dnl - update number in meson.build m4_define([nm_major_version], [1]) -m4_define([nm_minor_version], [20]) -m4_define([nm_micro_version], [0]) +m4_define([nm_minor_version], [21]) +m4_define([nm_micro_version], [1]) m4_define([nm_version], [nm_major_version.nm_minor_version.nm_micro_version]) diff --git a/data/meson.build b/data/meson.build index f496bf0135..9025eae452 100644 --- a/data/meson.build +++ b/data/meson.build @@ -11,7 +11,6 @@ server = 'server.conf' configure_file( input: server + '.in', output: server, - install: true, install_dir: join_paths(nm_datadir, 'doc', nm_name, 'examples'), configuration: data_conf, ) @@ -32,7 +31,6 @@ if install_systemd_unit_dir configure_file( input: service + '.in', output: service, - install: true, install_dir: systemd_system_unit_dir, configuration: data_conf, ) diff --git a/dispatcher/meson.build b/dispatcher/meson.build index da9ac7f292..0706ab07a2 100644 --- a/dispatcher/meson.build +++ b/dispatcher/meson.build @@ -13,7 +13,6 @@ service = 'org.freedesktop.nm_dispatcher.service' configure_file( input: service + '.in', output: service, - install: true, install_dir: dbus_sys_dir, configuration: service_conf, ) diff --git a/libnm-core/nm-setting-ip-config.c b/libnm-core/nm-setting-ip-config.c index 458d93b30d..56b16d414a 100644 --- a/libnm-core/nm-setting-ip-config.c +++ b/libnm-core/nm-setting-ip-config.c @@ -3110,7 +3110,8 @@ nm_ip_routing_rule_from_string (const char *str, goto next_words_consumed; } if (NM_IN_STRSET (word0, "not")) { - /* we accept multiple "not" specifiers. */ + /* we accept multiple "not" specifiers. "not not" still means + * not. */ val_invert = TRUE; goto next_words_consumed; } @@ -3460,15 +3461,15 @@ nm_ip_routing_rule_to_string (const NMIPRoutingRule *self, str = g_string_sized_new (30); - if (self->invert) - g_string_append (str, "not"); - if (self->priority_has) { g_string_append_printf (nm_gstring_add_space_delimiter (str), "priority %u", (guint) self->priority); } + if (self->invert) + g_string_append (nm_gstring_add_space_delimiter (str), "not"); + _rr_string_append_inet_addr (str, TRUE, ( !self->to_has diff --git a/libnm-core/nm-version.h b/libnm-core/nm-version.h index ee6a1e7db7..bb5b5422f6 100644 --- a/libnm-core/nm-version.h +++ b/libnm-core/nm-version.h @@ -215,4 +215,18 @@ # define NM_AVAILABLE_IN_1_20 #endif +#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_22 +# define NM_DEPRECATED_IN_1_22 G_DEPRECATED +# define NM_DEPRECATED_IN_1_22_FOR(f) G_DEPRECATED_FOR(f) +#else +# define NM_DEPRECATED_IN_1_22 +# define NM_DEPRECATED_IN_1_22_FOR(f) +#endif + +#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_22 +# define NM_AVAILABLE_IN_1_22 G_UNAVAILABLE(1,22) +#else +# define NM_AVAILABLE_IN_1_22 +#endif + #endif /* NM_VERSION_H */ diff --git a/libnm-core/tests/test-setting.c b/libnm-core/tests/test-setting.c index aa9de5a03d..3438aea99d 100644 --- a/libnm-core/tests/test-setting.c +++ b/libnm-core/tests/test-setting.c @@ -3168,7 +3168,9 @@ test_routing_rule (gconstpointer test_data) _rr_from_str ("priority 5 from :: iif a\\\\303b table 25"); _rr_from_str ("priority 5 to 0.0.0.0 sport 10 table 6", "priority 5 to 0.0.0.0 sport 10-10 table 6"); - _rr_from_str ("not priority 5 to 0.0.0.0 dport 10-133 table 6", + _rr_from_str ("priority 5 not to 0.0.0.0 dport 10-133 table 6", + "not priority 5 to 0.0.0.0 dport 10-133 table 6", + "not priority 5 not to 0.0.0.0 dport 10-133 table 6", "priority 5 to 0.0.0.0 not dport 10-133 not table 6", "priority 5 to 0.0.0.0 not dport 10-\\ 133 not table 6"); _rr_from_str ("priority 5 to 0.0.0.0 ipproto 10 sport 10 table 6"); diff --git a/libnm/meson.build b/libnm/meson.build index 3aa182dd4e..2e65d3bebf 100644 --- a/libnm/meson.build +++ b/libnm/meson.build @@ -224,7 +224,7 @@ if enable_introspection extra_args: cflags, header: 'NetworkManager.h', install: true, - depends: libnm_dep, + dependencies: libnm_dep, ) generate_plugin_docs = join_paths(meson.current_source_dir(), 'generate-plugin-docs.pl') diff --git a/meson.build b/meson.build index efad8426b8..9fc9ad2684 100644 --- a/meson.build +++ b/meson.build @@ -4,7 +4,7 @@ project( # - add corresponding NM_VERSION_x_y_z macros in # "shared/nm-version-macros.h.in" # - update number in configure.ac - version: '1.20.0', + version: '1.21.1', license: 'GPL2+', default_options: [ 'buildtype=debugoptimized', diff --git a/shared/meson.build b/shared/meson.build index af903d3c8a..d542804eb4 100644 --- a/shared/meson.build +++ b/shared/meson.build @@ -330,24 +330,6 @@ libnm_systemd_shared_no_logging_dep = declare_dependency( ], ) -############################################################################### - -exe = executable( - 'nm-utils/tests/test-shared-general', - [ 'nm-utils/tests/test-shared-general.c' ], - c_args: [ - '-DNETWORKMANAGER_COMPILATION_TEST', - '-DNETWORKMANAGER_COMPILATION=(NM_NETWORKMANAGER_COMPILATION_GLIB|NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_PROG)', - ], - dependencies: [ - shared_nm_glib_aux_dep, - libnm_systemd_shared_no_logging_dep, - shared_c_siphash_dep, - ], -) - -test( - 'shared/nm-utils/tests/test-shared-general', - test_script, - args: test_args + [exe.full_path()] -) +if enable_tests + subdir('nm-utils/tests') +endif diff --git a/shared/nm-utils/tests/meson.build b/shared/nm-utils/tests/meson.build new file mode 100644 index 0000000000..e0560f296d --- /dev/null +++ b/shared/nm-utils/tests/meson.build @@ -0,0 +1,22 @@ +test_unit = 'test-shared-general' + +exe = executable( + test_unit, + test_unit + '.c', + c_args: [ + '-DNETWORKMANAGER_COMPILATION_TEST', + '-DNETWORKMANAGER_COMPILATION=(NM_NETWORKMANAGER_COMPILATION_GLIB|NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_PROG)', + ], + dependencies: [ + shared_nm_glib_aux_dep, + libnm_systemd_shared_no_logging_dep, + shared_c_siphash_dep, + ], +) + +test( + 'shared/nm-utils/' + test_unit, + test_script, + args: test_args + [exe.full_path()], + timeout: default_test_timeout, +) diff --git a/shared/nm-version-macros.h.in b/shared/nm-version-macros.h.in index a546b1009a..eed928242e 100644 --- a/shared/nm-version-macros.h.in +++ b/shared/nm-version-macros.h.in @@ -76,6 +76,7 @@ #define NM_VERSION_1_16 (NM_ENCODE_VERSION (1, 16, 0)) #define NM_VERSION_1_18 (NM_ENCODE_VERSION (1, 18, 0)) #define NM_VERSION_1_20 (NM_ENCODE_VERSION (1, 20, 0)) +#define NM_VERSION_1_22 (NM_ENCODE_VERSION (1, 22, 0)) /* For releases, NM_API_VERSION is equal to NM_VERSION. * diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 50494526a9..7626b04a00 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -416,10 +416,12 @@ release_slave (NMDevice *device, int ifindex_slave; int ifindex; - ifindex = nm_device_get_ifindex (device); - if ( ifindex <= 0 - || !nm_platform_link_get (nm_device_get_platform (device), ifindex)) - configure = FALSE; + if (configure) { + ifindex = nm_device_get_ifindex (device); + if ( ifindex <= 0 + || !nm_platform_link_get (nm_device_get_platform (device), ifindex)) + configure = FALSE; + } ifindex_slave = nm_device_get_ip_ifindex (slave); diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index 91d824b35b..8f3a4045ba 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -628,10 +628,12 @@ release_slave (NMDevice *device, int ifindex_slave; int ifindex; - ifindex = nm_device_get_ifindex (device); - if ( ifindex <= 0 - || !nm_platform_link_get (nm_device_get_platform (device), ifindex)) - configure = FALSE; + if (configure) { + ifindex = nm_device_get_ifindex (device); + if ( ifindex <= 0 + || !nm_platform_link_get (nm_device_get_platform (device), ifindex)) + configure = FALSE; + } ifindex_slave = nm_device_get_ip_ifindex (slave); diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 4661a84034..79ac8935bb 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -777,10 +777,12 @@ release_slave (NMDevice *device, int ifindex_slave; int ifindex; - ifindex = nm_device_get_ifindex (device); - if ( ifindex <= 0 - || !nm_platform_link_get (nm_device_get_platform (device), ifindex)) - configure = FALSE; + if (configure) { + ifindex = nm_device_get_ifindex (device); + if ( ifindex <= 0 + || !nm_platform_link_get (nm_device_get_platform (device), ifindex)) + configure = FALSE; + } ifindex_slave = nm_device_get_ip_ifindex (slave); diff --git a/src/meson.build b/src/meson.build index f3f5ee581a..a9e7601de6 100644 --- a/src/meson.build +++ b/src/meson.build @@ -293,10 +293,9 @@ network_manager_sym = executable( # this uses symbols from nm-full-symbols instead of libNetworkManager.a ver_script = custom_target( symbol_map_name, - input: meson.source_root(), output: symbol_map_name, depends: [ network_manager_sym, core_plugins ], - command: [create_exports_networkmanager, '--called-from-build', '@INPUT@'], + command: [create_exports_networkmanager, '--called-from-build', meson.source_root()], ) ldflags = ['-rdynamic', '-Wl,--version-script,@0@'.format(ver_script.full_path())] |