mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 06:20:17 +01:00
cli: don't ignore errors from setting property aliases
Before, we would just ignore the errors when we passed an invalid value
to a property alias:
$ nmcli c add type ethernet mac Hello
Connection 'ethernet-1' (242eec76-7147-411a-a50b-336cf5bc8137) successfully added.
$ nmcli c show 242eec76-7147-411a-a50b-336cf5bc8137 |grep 802-3-ethernet.mac-address:
802-3-ethernet.mac-address: --
...or crash, because the GError would still be around:
$ nmcli c add type ethernet mac Hello ethernet.mac-address World
(process:734670): GLib-WARNING **: 14:52:51.436: GError set over the top of a previous GError or uninitialized memory.
This indicates a bug in someone's code. You must ensure an error is NULL before it's set.
The overwriting error message was: Error: failed to modify 802-3-ethernet.mac-address: 'World' is not a valid Ethernet MAC.
Error: failed to modify 802-3-ethernet.mac-address: 'Hello' is not a valid Ethernet MAC.
Now we catch it early enough:
$ nmcli c add type ethernet mac Hello
Error: failed to modify 802-3-ethernet.mac-address: 'Hello' is not a valid Ethernet MAC.
Fixes: 40032f4614 ('cli: fix resetting values via property alias')
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1134
This commit is contained in:
parent
6430a7d70c
commit
a7ef068186
1 changed files with 10 additions and 10 deletions
|
|
@ -4211,16 +4211,16 @@ set_option(NmCli *nmc,
|
|||
if (option && option->check_and_set) {
|
||||
return option->check_and_set(nmc, connection, option, value, error);
|
||||
} else if (value || allow_reset) {
|
||||
set_property(nmc->client,
|
||||
connection,
|
||||
setting_name,
|
||||
property_name,
|
||||
value,
|
||||
!value ? NM_META_ACCESSOR_MODIFIER_DEL
|
||||
: (inf_flags & NM_META_PROPERTY_INF_FLAG_MULTI
|
||||
? NM_META_ACCESSOR_MODIFIER_ADD
|
||||
: NM_META_ACCESSOR_MODIFIER_SET),
|
||||
error);
|
||||
return set_property(nmc->client,
|
||||
connection,
|
||||
setting_name,
|
||||
property_name,
|
||||
value,
|
||||
!value ? NM_META_ACCESSOR_MODIFIER_DEL
|
||||
: (inf_flags & NM_META_PROPERTY_INF_FLAG_MULTI
|
||||
? NM_META_ACCESSOR_MODIFIER_ADD
|
||||
: NM_META_ACCESSOR_MODIFIER_SET),
|
||||
error);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue