Commit graph

9 commits

Author SHA1 Message Date
Vojtech Bubela
6f3b2dbf6f
cli: sort entries in src/nmcli/devices.c by alphabetical order
Sort entries in src/nmcli/devices.c (on line 5023 - 5036)
by alphabetical order. The Order is violated in cases where
the sort would affect previous behaviour.

Example: `nmcli d d` is still shortcut for `nmcli device disconnect`
instead of `nmcli device delete`.
2021-07-09 16:41:31 +02:00
Thomas Haller
69cb2b3f24
cli: fix list of commands in nmc_command_func_device() 2021-07-09 16:01:54 +02:00
Vojtech Bubela
5cd1b2669d
cli: add alias to nmcli device connect|disconnect
nmcli now accepts `nmcli device up|down` which works the same way as
`nmcli device connect|disconnect`

I also edited man pages of nmcli with new options.
2021-07-09 16:01:47 +02:00
Thomas Haller
ea60f273af
cli: minor cleanup of code in "devices.c"
- declare each variable on a separate line.

- use nm_auto_free_gstring instead of explicit free.
2021-05-27 10:42:10 +02:00
Thomas Haller
550434a026
cli: workaround coverity false positive in "devices.c"
Error: RESOURCE_LEAK (CWE-772): [#def268] [important]
    NetworkManager-1.31.5/src/nmcli/devices.c:1367: alloc_fn: Storage is returned from allocation function "g_string_free".
    NetworkManager-1.31.5/src/nmcli/devices.c:1367: leaked_storage: Ignoring storage allocated by "g_string_free(security_str, 0)" leaks it.
    # 1365|       g_ptr_array_add(info->output_data, arr);
    # 1366|
    # 1367|->     g_string_free(security_str, FALSE);
    # 1368|   }
    # 1369|

    Error: RESOURCE_LEAK (CWE-772): [#def269] [important]
    NetworkManager-1.31.5/src/nmcli/devices.c:1451: alloc_fn: Storage is returned from allocation function "g_string_free".
    NetworkManager-1.31.5/src/nmcli/devices.c:1451: leaked_storage: Ignoring storage allocated by "g_string_free(slaves_str, 0)" leaks it.
    # 1449|       print_data(&nmc->nmc_config, &nmc->pager_data, out_indices, NULL, 0, &out);
    # 1450|
    # 1451|->     g_string_free(slaves_str, FALSE);
    # 1452|
    # 1453|       return TRUE;

    Error: RESOURCE_LEAK (CWE-772): [#def270] [important]
    NetworkManager-1.31.5/src/nmcli/devices.c:1517: alloc_fn: Storage is returned from allocation function "g_string_free".
    NetworkManager-1.31.5/src/nmcli/devices.c:1517: leaked_storage: Ignoring storage allocated by "g_string_free(slaves_str, 0)" leaks it.
    # 1515|       print_data(&nmc->nmc_config, &nmc->pager_data, out_indices, NULL, 0, &out);
    # 1516|
    # 1517|->     g_string_free(slaves_str, FALSE);
    # 1518|
    # 1519|       return TRUE;
2021-05-27 10:34:41 +02:00
Thomas Haller
e5f37477c0
cli: fix leak in print_wifi_connection()
Found by Coverity:

  Error: RESOURCE_LEAK (CWE-772): [#def297] [important]
  NetworkManager-1.31.3/src/nmcli/devices.c:4610: alloc_fn: Storage is returned from allocation function "nm_utils_ssid_to_utf8".
  NetworkManager-1.31.3/src/nmcli/devices.c:4610: var_assign: Assigning: "ssid" = storage returned from "nm_utils_ssid_to_utf8(g_bytes_get_data(ssid_bytes, NULL), g_bytes_get_size(ssid_bytes))".
  NetworkManager-1.31.3/src/nmcli/devices.c:4612: noescape: Resource "ssid" is not freed or pointed-to in "g_print".
  NetworkManager-1.31.3/src/nmcli/devices.c:4642: noescape: Resource "ssid" is not freed or pointed-to in "string_append_mecard".
  NetworkManager-1.31.3/src/nmcli/devices.c:4654: leaked_storage: Variable "ssid" going out of scope leaks the storage it points to.
  # 4652|
  # 4653|       g_print("\n");
  # 4654|-> }
  # 4655|
  # 4656|   static gboolean

Fixes: 7061341a41 ('cli: add "nmcli d wifi show"')
2021-05-11 13:56:50 +02:00
Fernando Fernandez Mancera
27e37a4b17 interface-flags: expose NM_DEVICE_INTERFACE_FLAG_PROMISC
This patch is introducing NM_DEVICE_INTERFACE_FLAG_PROMISC in
interface_flags. The flag represents IFF_PROMISC kernel flag.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-04-22 18:57:30 +00:00
Thomas Haller
f34841e196
all: use nm_g_variant_new_ay() helper 2021-04-16 11:44:19 +02:00
Thomas Haller
61f99307c6
cli: move from "clients/cli/" to "src/nmcli/" 2021-03-15 17:10:54 +01:00
Renamed from clients/cli/devices.c (Browse further)