summaryrefslogtreecommitdiff
path: root/clients/cli
Commit message (Collapse)AuthorAgeFilesLines
* clients: add ovs-dpdk interface supportlr/ovs-dpdkLubomir Rintel2019-06-141-1/+2
|
* cli: fix crash on autocompletionBeniamino Galvani2019-06-111-2/+3
| | | | | | | | | | | | | | | | | | @connections is NULL when doing autocompletion. Fixes the following: $ nmcli --complete-args con monitor "" help id uuid path filename ... Segmentation fault (core dumped) Fixes: 4b3297271e6f ('cli: rework connection handling for multiple results') https://bugzilla.redhat.com/show_bug.cgi?id=1716948 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/177
* cli: enforce int type in for loopsFrancesco Giudici2019-05-291-15/+15
|
* cli: don't force interface name on add_and_activateLubomir Rintel2019-05-281-1/+0
| | | | | | | | | The daemon is already responsible for pinning the connection to a particular device. In fact, it may choose to use a different means than an interface name, such as a MAC address or a gsm.device-id. Remove it from the client. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/140
* cli: allow completing filenamesBeniamino Galvani2019-05-061-7/+16
| | | | | Allow the completion function to indicate that the word should be completed as a filename by the shell.
* cli: remove bluetooth completion codeBeniamino Galvani2019-05-061-8/+2
| | | | | | | The 'bt-type' property alias accepts values provided by gen_func_bt_type(); instead the 'bluetooth.type' property can only be set to [dun, panu, nap] and therefore it doesn't need special handling.
* cli: drop GValue transform functions for strdict and implement it in ↵Thomas Haller2019-04-251-36/+0
| | | | | | | | | | | | | _get_fcn_gobject_impl() The only remaining GValue transform function was from GHashTable (of (str,str) type) to string. Drop that too, and implement the conversion in _get_fcn_gobject_impl(). Note that there are few GObject properties of type GHashTable and most of them implement their own logic. This only applies to "802-3-ethernet.s390-options". Also, always sort the keys. Otherwise, the output is not stable.
* cli: drop GValue transformation of GBytes to string and implement bytes ↵Thomas Haller2019-04-251-32/+0
| | | | | | | | | | | | | | | getter via _get_fcn_gobject_impl() The g_value_register_transform_func() for handling GBytes was not actually used. All properties of type G_TYPE_BYTES have their explit handler how to convert bytes to string. That is good, because the implementation there was very bad (it did not honor pretty/parsable get-type). Also, merge _get_fcn_gobject_bytes() into _get_fcn_gobject_impl(). We already have a generic handler that handles properties solely based on the GObject type: _get_fcn_gobject_impl(). Just let it also handle bytes. It's better to have fewer handlers, if they don't need special context.
* cli: drop GValue transform function for G_TYPE_STRV to G_TYPE_STRINGThomas Haller2019-04-251-16/+0
| | | | | | It's ugly to modify the global behavior of glib to convert between types. Instead, _get_fcn_gobject_impl() is perfectly capable to implement converting a strv array to string.
* cli: don't wait for connection change on update failureBeniamino Galvani2019-04-241-2/+4
| | | | | | | | | | | | When saving a connection, we wait the connection-changed signal before proceeding to ensure that the remote connection is up to date. However, no signal is emitted if the update fails and so we shouldn't wait for it. Fixes: a370faeb59a9 ('cli: wait for changed signal after updating a connection'): https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/124 https://bugzilla.redhat.com/show_bug.cgi?id=1702203
* build/meson: rename "nm_core_dep" to "libnm_core_dep"Thomas Haller2019-04-181-1/+1
| | | | | The library is called "libnm_core". So the dependency should be called "libnm_core_dep", like in all other cases.
* shared: build helper "libnm-libnm-core-{intern|aux}.la" library for libnm-coreThomas Haller2019-04-182-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "libnm-core" implements common functionality for "NetworkManager" and "libnm". Note that clients like "nmcli" cannot access the internal API provided by "libnm-core". So, if nmcli wants to do something that is also done by "libnm-core", , "libnm", or "NetworkManager", the code would have to be duplicated. Instead, such code can be in "libnm-libnm-core-{intern|aux}.la". Note that: 0) "libnm-libnm-core-intern.la" is used by libnm-core itsself. On the other hand, "libnm-libnm-core-aux.la" is not used by libnm-core, but provides utilities on top of it. 1) they both extend "libnm-core" with utlities that are not public API of libnm itself. Maybe part of the code should one day become public API of libnm. On the other hand, this is code for which we may not want to commit to a stable interface or which we don't want to provide as part of the API. 2) "libnm-libnm-core-intern.la" is statically linked by "libnm-core" and thus directly available to "libnm" and "NetworkManager". On the other hand, "libnm-libnm-core-aux.la" may be used by "libnm" and "NetworkManager". Both libraries may be statically linked by libnm clients (like nmcli). 3) it must only use glib, libnm-glib-aux.la, and the public API of libnm-core. This is important: it must not use "libnm-core/nm-core-internal.h" nor "libnm-core/nm-utils-private.h" so the static library is usable by nmcli which couldn't access these. Note that "shared/nm-meta-setting.c" is an entirely different case, because it behaves differently depending on whether linking against "libnm-core" or the client programs. As such, this file must be compiled twice.
* cli: fix crash in split_required_fields_for_con_show()Thomas Haller2019-04-161-2/+6
| | | | | | | | | Depending on the architecture (calling convention), function arguments are evaluated in one order or the other. https://bugzilla.redhat.com/show_bug.cgi?id=1700409 Fixes: 34e60bf2282e ('cli: cleanup split_required_fields_for_con_show()')
* cli: tab complete only full D-Bus paths if there is no prefixth/cli-select-connectionThomas Haller2019-04-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | When tab completing connections by path name without any already typed parts, only suggest full D-Bus paths. The numbers are duplicate and not preferred. Before: $ nmcli connection show path <TAB> Display all 118 possibilities? (y or n) 1 46 /org/freedesktop/NetworkManager/Settings/29 10 47 /org/freedesktop/NetworkManager/Settings/3 11 48 /org/freedesktop/NetworkManager/Settings/30 12 49 /org/freedesktop/NetworkManager/Settings/31 13 5 /org/freedesktop/NetworkManager/Settings/32 Afterwards: $ nmcli connection show path <TAB> /org/freedesktop/NetworkManager/Settings/1 /org/freedesktop/NetworkManager/Settings/28 /org/freedesktop/NetworkManager/Settings/46 ... and $ nmcli connection modify path 4<TAB> 4 40 41 42 43 44 45 46 47 48 49
* cli: prefer matching connections by "uuid" instead of "id"Thomas Haller2019-04-151-27/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Scripts should refer to connections by UUID. That means, whenever a UUID matches, that is really what the user wants. The specifier "uuid" must have precedence over "id" (and all others). That means, we must search all connections. For example: $ UUIDS=($(nmcli -g TYPE,UUID connection show | sed -n 's/802-11-wireless://p')) $ nmcli -f connection.id,connection.uuid connection show "${UUIDS[@]}" in this case we must preferrably match by UUID, regardless of whether a "connection.id" exists. Note that if you have: $ nmcli connection show | grep fdf7b2d2-2858-3938-9b14-7f1b514a9a00 b fdf7b2d2-2858-3938-9b14-7f1b514a9a00 ethernet -- fdf7b2d2-2858-3938-9b14-7f1b514a9a00 ab9f3891-3420-335e-89da-f14c1b94c540 ethernet -- then certain commands will still select all matching connections: $ nmcli -f connection.id,connection.uuid --mode multiline connection show fdf7b2d2-2858-3938-9b14-7f1b514a9a00 connection.id: fdf7b2d2-2858-3938-9b14-7f1b514a9a00 connection.uuid: ab9f3891-3420-335e-89da-f14c1b94c540 connection.id: b connection.uuid: fdf7b2d2-2858-3938-9b14-7f1b514a9a00 This only makes a difference for commands that must pick only one profile: $ nmcli connection modify fdf7b2d2-2858-3938-9b14-7f1b514a9a00 con-name new-name
* cli: drop unnecessary NULL sentinel from nmc_complete_strings()Thomas Haller2019-04-156-30/+30
| | | | | | Since commit 62b939de4e22 ('cli: add nmc_complete_strv() which takes a string array for completion that may contain NULL'), the sentinel is no longer needed.
* cli: fix typo in nmcli usage outputThomas Haller2019-04-121-1/+1
| | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/157
* cli: cleanup split_required_fields_for_con_show()Thomas Haller2019-04-101-49/+43
| | | | | - return early and use cleanup attribute for freeing memory - use nm_utils_strsplit_set_with_empty() instead of g_strsplit_set().
* shared: add flags argument to nm_utils_strsplit_set()Thomas Haller2019-04-103-4/+5
| | | | | | It will be useful to extend nm_utils_strsplit_set() with various flavors and subtly different behaviors. Add a flags argument to support these.
* cli: fix missing newline for printing error message about "Connection ↵Thomas Haller2019-04-051-1/+1
| | | | | | | deletion failed" $ nmcli connection delete Wired\ connection\ 1 Error: Connection deletion failed: Insufficient privilegesError: not all connections deleted.
* clients: only ask secrets for settings that require themBeniamino Galvani2019-04-021-0/+6
| | | | | | | | | | | | When nmcli needs secrets for a connection it asks them for every known setting. nmtui is a bit smarter and asks them only for settings that actually exist in the connection. Make a step further and let clients ask secrets only for setting that exist *and* have any secret property. This decreases the number of D-Bus calls when editing or showing a connection with secrets. https://bugzilla.redhat.com/show_bug.cgi?id=1506536 https://github.com/NetworkManager/NetworkManager/pull/327
* cli: fix a crash on "nmcli d wifi hotspot"Lubomir Rintel2019-04-021-0/+1
| | | | | | | | | | Call the correct _finish() function for nm_client_add_and_activate_connection_async(). add_and_activate_cb() somewhat confusingly alternates between two different ones depending on whether info->create is set. Fixes: 35932375272a ('cli: reuse connections in nmcli dev wifi con') https://github.com/NetworkManager/NetworkManager/pull/326
* cli: fix accepting %NULL value for '+' modifierThomas Haller2019-03-271-1/+6
| | | | | | | | | I find it questionable, how nmcli likes to coerce the empty input to NULL to indicate resetting the value. If nmcli would like to set a default, it should use a different way of signalling that. Anyway, the assertion was too strict. $ nmcli connection modify "$PROFILE" +ipv4.addresses ''
* cli: freeze/thaw property changed signals in nmc_setting_set_property()Thomas Haller2019-03-251-7/+11
| | | | | | | | | | | | | Setting one property might affect multiple properties. For example, setting a team property might also emit property changed signal for "team.config". Or, one property might be modified multiple times. For example list properties may first clear the property, then append multiple elements. Or a list property might remove multiple elements. Combine these signals via g_object_freeze_notify() and g_object_thaw_notify().
* cli/trivial: add FIXME comment about how wrong ↵Thomas Haller2019-03-252-0/+23
| | | | editor_init_existing_connection() is
* cli: merge set_fcn() and remove_fcn()Thomas Haller2019-03-251-10/+5
| | | | | | | | | | | | | | | | | | | | | set_fcn() and remove_fcn() are strongly related. They should accept arguments in the same format, hence the parsing of the arguments should be done at one place. In fact, previously the parsing was separate, leading to ugly inconsistencies: $ nmcli connection modify "$PROFILE" +vpn.data x=y $ nmcli connection modify "$PROFILE" -vpn.data x=y Error: failed to remove a value from vpn.data: invalid option 'x=y'. or $ nmcli connection modify "$PROFILE" +ipv4.addresses 192.168.1.5/24,192.168.2.5/24 $ nmcli connection modify "$PROFILE" -ipv4.addresses 192.168.1.5/24,192.168.2.5/24 Error: failed to remove a value from ipv4.addresses: invalid prefix '24,192.168.2.5/24'; <1-32> allowed. Let set_fcn() handle set-default, set-all, add, and subtract.
* cli: allow resetting all values via set_fcn() property handlerThomas Haller2019-03-251-45/+7
| | | | | | | | Previously, set_fcn() could only append values. Now, pass on the modifier so that it may append, set all, or reset the default. These operations are strongly related and should be handled by the same set_fcn() function.
* cli: reset default value of properties via set_fcn()Thomas Haller2019-03-251-41/+40
| | | | | | | The property implementation must itself decide how to reset a value. We must not rely on properties being plain GObject properties. Let set_fcn() accept %NULL value to indicate resetting the default.
* cli: merge remove-property, reset-property and set-propertyThomas Haller2019-03-253-197/+115
| | | | | | | | | | | | | | | | | | | | | | It's fundamentally wrong to have separate "remove_fcn" and "set_fcn" implementations. Set, reset, add, and remove are all similar, and should be implemented in a similar manner. Merge the implementations all in set-property, which now can: - reset the value (value == NULL && modifier == '\0') - set a value (value != NULL && modifier == '\0') - add a value (value != NULL && modifier == '+') - remove a value (value != NULL && modifier == '-') The real problem is that remove_fcn() behaves fundamentally different from set_fcn(). You can do "+setting.property value1,value2" but you cannot remove them the same way. That is because most remove_fcn() implementations don't expect a list of values. But it's also because of the unnatural split between set_fcn() and remove_fcn(). The next commit will merge set_fcn(), remove_fcn() and reset property. This commit just merges them all in nmc_setting_set_property().
* cli: don't use nmc_property_get_gvalue() in ipv4_method_changed_cb()Thomas Haller2019-03-251-14/+14
| | | | | | | | | | | | ipv4_method_changed_cb() and ipv6_method_changed_cb() are horrible hacks, as they use a static variable to cache the previous value. Anyway, don't fix that now. We are going to drop nmc_property_get_gvalue()/nmc_property_set_gvalue() because that works only with GObject based properties -- and having this API around wrongly suggests it works in general. Use the native types directly.
* cli: drop nmc_property_set_default_value()Thomas Haller2019-03-253-19/+13
| | | | | | It's wrong to pretend that all properties are GObject based. Drop nmc_property_set_default_value() and use nmc_setting_reset_property() instead.
* cli: implement nmc_setting_reset_property() based on nmc_setting_set_property()Thomas Haller2019-03-253-65/+41
| | | | | | | | | | "reset" is just a special case of "set". We can keep nmc_setting_reset_property() as a convenience function, but it must be implemented based on nmc_setting_set_property(). Also, reset only used nmc_property_set_default_value(), which only works with GObject based properties. It's wrong to assume that all properties are GObject based. By implementing it based via nmc_setting_set_property() we can fix this (later).
* cli: don't interpret value as index too early for ↵Thomas Haller2019-03-253-33/+9
| | | | | | | | | | | nmc_setting_remove_property_option() Not all implementations support having the value being an index. For example, the implementations that are done via DEFINE_REMOVER_OPTION() macro. The meaning of the "value" string must not be determined by nmc_setting_remove_property_option(). It's up to the implementation to decide whether to allow an index and how to interpret it.
* cli/wireguard: add import functionality for WireGuardThomas Haller2019-03-071-14/+24
| | | | | | | | | | | | | Support importing ".conf" files as `wg-quick up` supports it. `wg-quick` parses several options under "[Interface]" and passes the remainder to `wg setconf`. The PreUp/PreDown/PostUp/PostDown options are of course not supported. "Table" for the moment behaves different. (cherry picked from commit a3a8583c315da45ace75f36c40bea9fa55b59ae3)
* cli: fix completion for `nmcli connection import`Thomas Haller2019-03-071-2/+5
| | | | | | | | | | If we already specified "type" or "file", don't offer it for completion again. $ nmcli connection import type openvpn <TAB> file type (cherry picked from commit fea0f4a5eaa069b9019151ca9a43b6ee25a7f837)
* cli: add nmc_complete_strv() which takes a string array for completion that ↵Thomas Haller2019-03-072-10/+28
| | | | | | | | | may contain NULL This will allow for a convenient calling pattern when some elements should be printed optionally. (cherry picked from commit 62b939de4e2288d0a9d305706db4cf47c34122d5)
* libnm,cli: add NMSettingWireGuardThomas Haller2019-02-221-0/+1
| | | | | | | | | | | | | | For now only add the core settings, no peers' data. To support peers and the allowed-ips of the peers is more complicated and will be done later. It's more complicated because these are nested lists (allowed-ips) inside a list (peers). That is quite unusual and to conveniently support that in D-Bus API, in keyfile format, in libnm, and nmcli, is a effort. Also, it's further complicated by the fact that each peer has a secret (the preshared-key). Thus we probably need secret flags for each peer, which is a novelty as well (until now we require a fixed set of secrets per profile that is well known).
* Add polkit action for Wi-Fi scansJonathan Kang2019-02-211-0/+2
| | | | | | | | | | | | | | | | | | Previously, Wi-Fi scans uses polkit action "org.freedesktop.NetworkManager.network-control". This is introduced in commit 5e3e19d0. But in a system with restrict polkit rules, for example "org.freedesktop.NetworkManager.network-control" was set as auth_admin. When you open the network panel of GNOME Control Center, a polkit dialog will keep showing up asking for admin password, as GNOME Control Center scans the Wi-Fi list every 15 seconds. Fix that by adding a new polkit action "org.freedesktop.NetworkManager.wifi.scan" so that distributions can add specific rule to allow Wi-Fi scans. [thaller@redhat.com: fix macro in "shared/nm-common-macros.h"] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/68
* clients/secret-agent: allow suppressing prompting the entry-id when ↵Thomas Haller2019-02-142-6/+16
| | | | | | | | requesting secrets When asking for the preshared-key for WireGuard peers, the secret request will be very verbose with redundant information. Allow suppressing the entry id from the prompt.
* all: replace strerror() calls with nm_strerror_native()Thomas Haller2019-02-121-6/+6
|
* all: cache errno in local variable before using itThomas Haller2019-02-121-12/+20
|
* all: drop unnecessary includes of <errno.h> and <string.h>Thomas Haller2019-02-128-11/+0
| | | | | "nm-macros-interal.h" already includes <errno.h> and <string.h>. No need to include it everywhere else too.
* all: minor coding style fixes (space before parentheses)Thomas Haller2019-02-111-1/+1
|
* cli: avoid "-Wduplicate-decl-specifier" warning in nmcli's resolve_color_alias()Thomas Haller2019-02-081-1/+1
| | | | | | | | [1/2] Compiling C object 'clients/cli/2641089@@nmcli@exe/nmcli.c.o'. ../clients/cli/nmcli.c: In function ‘resolve_color_alias’: ../clients/cli/nmcli.c:507:4: warning: duplicate ‘const’ declaration specifier [-Wduplicate-decl-specifier] } const aliases[] = { ^~~~~
* Revert "cli: verify connections before sending them over to daemon"Thomas Haller2019-02-061-23/+0
| | | | | | | | | | | | | | | | | | Just calling nm_connection_verify() is not correct. We need nm_connection_normalize() because otherwise we miss out on places where we have common normalization steps implemented to fix a connection. This is also what server-side is done. Revert the patch, as it breaks CI tests. I wonder also whether this is the right place. There are already several places in "clients/cli/connections.c" that call verify() and normalize(). These places should be unified so that there is one place where we complete the connection. And it probably should be done as a separate step before the add_new_connection()/update_connection() calls. This reverts commit ca58bcca0c3cfc6ae44f4a6c7c227590405e6d7c.
* cli: verify connections before sending them over to daemonlr/saeLubomir Rintel2019-02-051-0/+23
| | | | | This way we generate the error messages on the client side and therefore can localize them.
* clients/cli: if the AP supports SAE, claim WPA3 supportLubomir Rintel2019-02-051-1/+5
| | | | | RSN with SAE is what's called WPA3-Personal. Also, if there's neither PSK nor 802.1x, it's not WPA2.
* clients/cli: don't translate abbreviationsLubomir Rintel2019-02-051-8/+4
|
* client/cli: send a PSK when using SAELubomir Rintel2019-02-051-2/+4
|
* client/cli: add support for SAE key management flagLubomir Rintel2019-02-051-1/+3
|