diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2022-03-07 14:54:51 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2022-03-07 15:27:21 +0100 |
commit | 904913493db5ac8c2ae36f5ac6d9da28868cc8a6 (patch) | |
tree | b66e4aebe5a644e40b04a5ba8a7870d153290252 | |
parent | 12f03636d035572d7370b73756a38c76aa48b378 (diff) |
cli: don't ignore errors from setting property aliaseslr/property-alias-err
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: 40032f461415 ('cli: fix resetting values via property alias')
-rw-r--r-- | src/nmcli/connections.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c index 559dc7dbc0..025f96a179 100644 --- a/src/nmcli/connections.c +++ b/src/nmcli/connections.c @@ -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; |