libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
authorThomas Haller <thaller@redhat.com>
Fri, 18 Mar 2016 12:42:50 +0000 (13:42 +0100)
committerThomas Haller <thaller@redhat.com>
Sat, 26 Mar 2016 11:10:54 +0000 (12:10 +0100)
commit737c8cc532263149f0a6779f542ee54ee22fd6ce
treefa6461412e2e4e47b5ad37d20fb999e929010e1b
parent88655999df765373a4808089e26e441d2bfcae14
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()

In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).

In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.

Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.

Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.

For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.

This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
libnm-core/nm-connection.c
libnm-core/nm-core-internal.h
libnm-core/nm-setting-connection.c
libnm-core/nm-setting-ip-config.c
libnm-core/nm-setting-ip4-config.c
libnm-core/nm-setting-ip6-config.c
libnm-core/nm-setting-private.h
libnm-core/nm-setting-vlan.c
libnm-core/nm-setting.c
libnm-core/tests/test-general.c