summary refs log tree commit diff
path: root/src/nmcli
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2024-09-01 22:38:35 +0200
committerMichael Biebl <biebl@debian.org>2024-09-01 22:38:35 +0200
commitf9bfd1158b8d08d6a5ed3bb7cc1ba7a6455e5201 (patch)
tree10267dcf5b842b7c638a79bd6851549cd849b81d /src/nmcli
parent681dfc70ef98f6ed0c05bcb0fbff00e3fc0799ea (diff)
New upstream version 1.49.90 upstream/1.49.90
Diffstat (limited to 'src/nmcli')
-rw-r--r--src/nmcli/common.c2
-rw-r--r--src/nmcli/connections.c16
-rw-r--r--src/nmcli/devices.c43
-rw-r--r--src/nmcli/gen-metadata-nm-settings-nmcli.xml.in6
-rw-r--r--src/nmcli/nmcli.c24
5 files changed, 50 insertions, 41 deletions
diff --git a/src/nmcli/common.c b/src/nmcli/common.c
index 2f205e50..fbabdffc 100644
--- a/src/nmcli/common.c
+++ b/src/nmcli/common.c
@@ -824,7 +824,7 @@ static char    *rl_string;
 /**
  * nmc_cleanup_readline:
  *
- * Cleanup readline when nmcli is terminated with a signal.
+ * Cleanup readline when nmcli is terminated.
  * It makes sure the terminal is not garbled.
  */
 void
diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c
index 7e192388..002dd402 100644
--- a/src/nmcli/connections.c
+++ b/src/nmcli/connections.c
@@ -3799,6 +3799,7 @@ check_valid_name_toplevel(const char *val, const char **port_type, GError **erro
     gs_unref_ptrarray GPtrArray   *tmp_arr = NULL;
     const NMMetaSettingInfoEditor *setting_info;
     gs_free_error GError          *tmp_err = NULL;
+    GType                          gtype   = G_TYPE_INVALID;
     const char                    *str;
     int                            i;
 
@@ -3808,6 +3809,13 @@ check_valid_name_toplevel(const char *val, const char **port_type, GError **erro
     tmp_arr = g_ptr_array_sized_new(32);
     for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) {
         setting_info = &nm_meta_setting_infos_editor[i];
+
+        /* skip "non-base" settings (that means, not valid for a connection's "type") */
+        gtype = setting_info->general->get_setting_gtype();
+        if (nm_meta_setting_info_get_base_type_priority(setting_info->general, gtype)
+            == NM_SETTING_PRIORITY_INVALID)
+            continue;
+
         g_ptr_array_add(tmp_arr, (gpointer) setting_info->general->setting_name);
         if (setting_info->alias)
             g_ptr_array_add(tmp_arr, (gpointer) setting_info->alias);
@@ -6629,9 +6637,11 @@ get_setting_and_property(const char *prompt,
         valid_settings_port = nm_meta_setting_info_valid_parts_for_port_type(s_type, NULL);
 
         setting_name = check_valid_name(sett, valid_settings_main, valid_settings_port, NULL);
-        setting      = nm_meta_setting_info_editor_new_setting(
-            nm_meta_setting_info_editor_find_by_name(setting_name, FALSE),
-            NM_META_ACCESSOR_SETTING_INIT_TYPE_DEFAULT);
+        if (setting_name) {
+            setting = nm_meta_setting_info_editor_new_setting(
+                nm_meta_setting_info_editor_find_by_name(setting_name, FALSE),
+                NM_META_ACCESSOR_SETTING_INIT_TYPE_DEFAULT);
+        }
     } else
         setting = nm_g_object_ref(nmc_tab_completion.setting);
 
diff --git a/src/nmcli/devices.c b/src/nmcli/devices.c
index c55f0a39..f6163757 100644
--- a/src/nmcli/devices.c
+++ b/src/nmcli/devices.c
@@ -2221,6 +2221,13 @@ add_and_activate_cb(GObject *client, GAsyncResult *result, gpointer user_data)
         return;
     }
 
+    if (nmc->secret_agent) {
+        NMRemoteConnection *connection = nm_active_connection_get_connection(active);
+
+        nm_secret_agent_simple_enable(nmc->secret_agent,
+                                      nm_connection_get_path(NM_CONNECTION(connection)));
+    }
+
     if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
         progress_id = g_timeout_add(120, progress_cb, info->device);
 
@@ -3662,8 +3669,7 @@ do_device_wifi_connect(const NMCCommand *cmd, NmCli *nmc, int argc, const char *
     GByteArray        *bssid2_arr            = NULL;
     gs_free NMDevice **devices               = NULL;
     int                devices_idx;
-    char              *ssid_ask   = NULL;
-    char              *passwd_ask = NULL;
+    char              *ssid_ask = NULL;
     const GPtrArray   *avail_cons;
     gboolean           name_match = FALSE;
     int                i;
@@ -4021,29 +4027,15 @@ do_device_wifi_connect(const NMCCommand *cmd, NmCli *nmc, int argc, const char *
         || (ap_rsn_flags != NM_802_11_AP_SEC_NONE
             && !NM_FLAGS_ANY(ap_rsn_flags,
                              NM_802_11_AP_SEC_KEY_MGMT_OWE | NM_802_11_AP_SEC_KEY_MGMT_OWE_TM))) {
-        const char                *con_password = NULL;
-        NMSettingWirelessSecurity *s_wsec       = NULL;
-
-        if (connection) {
-            s_wsec = nm_connection_get_setting_wireless_security(connection);
-            if (s_wsec) {
-                if (ap_wpa_flags == NM_802_11_AP_SEC_NONE
-                    && ap_rsn_flags == NM_802_11_AP_SEC_NONE) {
-                    /* WEP */
-                    con_password = nm_setting_wireless_security_get_wep_key(s_wsec, 0);
-                } else if ((ap_wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)
-                           || (ap_rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)
-                           || (ap_rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_SAE)) {
-                    /* WPA PSK */
-                    con_password = nm_setting_wireless_security_get_psk(s_wsec);
-                }
-            }
-        }
-
-        /* Ask for missing password when one is expected and '--ask' is used */
-        if (!password && !con_password && nmc->ask) {
-            password = passwd_ask =
-                nmc_readline_echo(&nmc->nmc_config, nmc->nmc_config.show_secrets, _("Password: "));
+        NMSettingWirelessSecurity *s_wsec = NULL;
+
+        /* Create secret agent */
+        nmc->secret_agent = nm_secret_agent_simple_new("nmcli-connect");
+        if (nmc->secret_agent) {
+            g_signal_connect(nmc->secret_agent,
+                             NM_SECRET_AGENT_SIMPLE_REQUEST_SECRETS,
+                             G_CALLBACK(nmc_secrets_requested),
+                             nmc);
         }
 
         if (password) {
@@ -4091,7 +4083,6 @@ finish:
     if (bssid2_arr)
         g_byte_array_free(bssid2_arr, TRUE);
     g_free(ssid_ask);
-    nm_free_secret(passwd_ask);
 }
 
 static GBytes *
diff --git a/src/nmcli/gen-metadata-nm-settings-nmcli.xml.in b/src/nmcli/gen-metadata-nm-settings-nmcli.xml.in
index b35a96a4..7f5bc2c7 100644
--- a/src/nmcli/gen-metadata-nm-settings-nmcli.xml.in
+++ b/src/nmcli/gen-metadata-nm-settings-nmcli.xml.in
@@ -89,6 +89,10 @@
                   nmcli-description="Configures AP isolation, which prevents communication between wireless devices connected to this AP. This property can be set to a value different from &quot;default&quot; (-1) only when the interface is configured in AP mode. If set to &quot;true&quot; (1), devices are not able to communicate with each other. This increases security because it protects devices against attacks from other clients in the network. At the same time, it prevents devices to access resources on the same wireless networks as file shares, printers, etc. If set to &quot;false&quot; (0), devices can talk to each other. When set to &quot;default&quot; (-1), the global default is used; in case the global default is unspecified it is assumed to be &quot;false&quot; (0)."
                   format="ternary"
                   values="true/yes/on, false/no/off, default/unknown" />
+        <property name="channel-width"
+                  nmcli-description="Specifies width of the wireless channel in Access Point (AP) mode. When set to &quot;auto&quot; (0) (the default), the channel width is automatically determined. At the moment, this means that the safest (smallest) width is chosen. If the value is not &quot;auto&quot; (0), then the &apos;channel&apos; property must also be set. When using the 2.4GHz band, the width can be at most 40MHz. This property can be set to a value different from &quot;auto&quot; (0) only when the interface is configured in AP mode."
+                  format="choice (NMSettingWirelessChannelWidth)"
+                  values="auto (0), 20mhz (20), 40mhz (40), 80mhz (80)" />
     </setting>
     <setting name="802-11-wireless-security"
              alias="wifi-sec" >
@@ -1468,7 +1472,7 @@
                   values="0 - 2147483647"
                   special-values="default (0)" />
         <property name="addr-gen-mode"
-                  nmcli-description="Configure method for creating the IPv6 interface identifer of addresses with RFC4862 IPv6 Stateless Address Autoconfiguration and Link Local addresses. The permitted values are: &quot;eui64&quot; (0), &quot;stable-privacy&quot; (1), &quot;default&quot; (3) or &quot;default-or-eui64&quot; (2). If the property is set to &quot;eui64&quot;, the addresses will be generated using the interface token derived from hardware address. This makes the host part of the address to stay constant, making it possible to track the host&apos;s presence when it changes networks. The address changes when the interface hardware is replaced. If a duplicate address is detected, there is also no fallback to generate another address. When configured, the &quot;ipv6.token&quot; is used instead of the MAC address to generate addresses for stateless autoconfiguration. If the property is set to &quot;stable-privacy&quot;, the interface identifier is generated as specified by RFC7217. This works by hashing a host specific key (see NetworkManager(8) manual), the interface name, the connection&apos;s &quot;connection.stable-id&quot; property and the address prefix.  This improves privacy by making it harder to use the address to track the host&apos;s presence and the address is stable when the network interface hardware is replaced. The special values &quot;default&quot; and &quot;default-or-eui64&quot; will fallback to the global connection default as documented in the NetworkManager.conf(5) manual. If the global default is not specified, the fallback value is &quot;stable-privacy&quot; or &quot;eui64&quot;, respectively. If not specified, when creating a new profile the default is &quot;default&quot;. Note that this setting is distinct from the Privacy Extensions as configured by &quot;ip6-privacy&quot; property and it does not affect the temporary addresses configured with this option."
+                  nmcli-description="Configure method for creating the IPv6 interface identifier of addresses with RFC4862 IPv6 Stateless Address Autoconfiguration and Link Local addresses. The permitted values are: &quot;eui64&quot; (0), &quot;stable-privacy&quot; (1), &quot;default&quot; (3) or &quot;default-or-eui64&quot; (2). If the property is set to &quot;eui64&quot;, the addresses will be generated using the interface token derived from hardware address. This makes the host part of the address to stay constant, making it possible to track the host&apos;s presence when it changes networks. The address changes when the interface hardware is replaced. If a duplicate address is detected, there is also no fallback to generate another address. When configured, the &quot;ipv6.token&quot; is used instead of the MAC address to generate addresses for stateless autoconfiguration. If the property is set to &quot;stable-privacy&quot;, the interface identifier is generated as specified by RFC7217. This works by hashing a host specific key (see NetworkManager(8) manual), the interface name, the connection&apos;s &quot;connection.stable-id&quot; property and the address prefix.  This improves privacy by making it harder to use the address to track the host&apos;s presence and the address is stable when the network interface hardware is replaced. The special values &quot;default&quot; and &quot;default-or-eui64&quot; will fallback to the global connection default as documented in the NetworkManager.conf(5) manual. If the global default is not specified, the fallback value is &quot;stable-privacy&quot; or &quot;eui64&quot;, respectively. If not specified, when creating a new profile the default is &quot;default&quot;. Note that this setting is distinct from the Privacy Extensions as configured by &quot;ip6-privacy&quot; property and it does not affect the temporary addresses configured with this option."
                   format="choice (NMSettingIP6ConfigAddrGenMode)"
                   values="eui64 (0), stable-privacy (1), default-or-eui64 (2), default (3)" />
         <property name="ra-timeout"
diff --git a/src/nmcli/nmcli.c b/src/nmcli/nmcli.c
index be177847..cfe4c5f4 100644
--- a/src/nmcli/nmcli.c
+++ b/src/nmcli/nmcli.c
@@ -163,17 +163,18 @@ complete_one(gpointer key, gpointer value, gpointer user_data)
         last = prefix;
 
     if ((!*last && !strchr(name, '.')) || matches(last, name)) {
-        if (option != prefix) {
+        if (!nm_streq0(option, prefix)) {
             /* value prefix was not a standalone argument,
              * it was part of --option=<value> argument.
              * Repeat the part leading to "=". */
-            nmc_print("%s=", option);
+            nmc_print("%s\n", option);
+        } else {
+            nmc_print("%.*s%s%s\n",
+                      (int) (last - prefix),
+                      prefix,
+                      name,
+                      nm_streq(last, name) ? "," : "");
         }
-        nmc_print("%.*s%s%s\n",
-                  (int) (last - prefix),
-                  prefix,
-                  name,
-                  strcmp(last, name) == 0 ? "," : "");
     }
 }
 
@@ -225,13 +226,14 @@ complete_option_with_value(const char *option, const char *prefix, ...)
     va_start(args, prefix);
     while ((candidate = va_arg(args, const char *))) {
         if (!*prefix || matches(prefix, candidate)) {
-            if (option != prefix) {
+            if (!nm_streq0(option, prefix)) {
                 /* value prefix was not a standalone argument,
                  * it was part of --option=<value> argument.
                  * Repeat the part leading to "=". */
-                nmc_print("%s=", option);
+                nmc_print("%s%s\n", option, candidate + strlen(prefix));
+            } else {
+                nmc_print("%s\n", candidate);
             }
-            nmc_print("%s\n", candidate);
         }
     }
     va_end(args);
@@ -1044,6 +1046,8 @@ main(int argc, char *argv[])
     if (process_command_line(&nm_cli, argc, argv))
         g_main_loop_run(loop);
 
+    nmc_cleanup_readline();
+
     if (nm_cli.complete) {
         /* Remove error statuses from command completion runs. */
         if (nm_cli.return_value < NMC_RESULT_COMPLETE_FILE)