NetworkManager/libnm-core
Thomas Haller 9eddf9fb09 settings: track profiles on disk that are shadowed by in-memory connections
Via Update2() D-Bus API there are three ways how a profile can be stored
(or migrated) to in-memory:

  - NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY
  - NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACHED
  - NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_ONLY

With the recent rework of settings I dropped NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY
and it had the same meaning as NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACHED.

However, the way NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACHED was implemented is
problematic. The problem is that it leaves the profile on disk but creates an
in-memory representation which shadows the persistent storage. Later,
when storing the profile to disk again, a new filename is chosen.
This allows via D-Bus API to toggle between NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACHED
and NM_SETTINGS_UPDATE2_FLAG_TO_DISK, and thereby pilling up profiles on disk.
Also, there is no D-Bus API to do anything sensible with these leaked, shadowed
profiles on disk.

Note that if we have a read-only profile in /usr/lib or in ifupdown
plugin, then the problem is not made any worse. That is, because via D-Bus
API such profiles can be made in-memory, and afterwards stored to /etc.
Thereby too the profile gets duplicate on disk, but this game only
works once. Afterwards, you cannot repeat it to create additional
profiles on disk. It means, you can only leak profiles once, and only
if they already exist in read-only storage to begin with.

This problem with NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACHED already existed
before the settings-delegate-storage rework, and is unrelated to whether in-memory
profiles now happen to be persisted to /run.

Note that NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_ONLY is simple and does not suffer
from this problem. When you move a profile to in-memory-only, it gets deleted from
persistent storage and no duplication happens.

The problem is that NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACHED used to
forget about the profile that it shadows, and that is wrong.

So, first re-add proper support for NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY. This
works by remembering the "shadowed-storage" path for in-memory profiles.
When later saving such a profile to disk again, the shadowed-storage
will be re-used. Likewise, when deleting such a profile, the shadowed
storage will be deleted.

Note that we keep NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACHED and it
also remembers the shadowed storage (but without "owning" it). That means,
when such a profile gets saved to disk again, the orginal storage is
reused too. As such, during future updates it behaves just like
NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY. The difference is when deleting
such a profile. In this case, the profile is left on storage and a
tombstone gets written. So, how is this better than before and why even
keep this complicated flag?
First, we keep this flag because we really want the ansible role to be
able to do in-memory changes only. That implies being able to delete a
profile from NetworkManager's view, but not from persistent storage. Without
this flag there is no way to do that. You can only modify an on-disk profile
by shadowing it, but you could not delete it form NetworkManager's view
while keeping it on disk.

The new form of NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACHED is safe and avoids
the duplication problem because also for tombstones it remembers the original
"shadowed-storage". That is, when the profile gets recreated later via
D-Bus API AddConnection, then the re-created profile will still reference
and reuse the shadowed storage that it had before deletion.
2019-07-25 23:27:49 +02:00
..
tests libnm/crypto: accept TPM2-wrapped PEM keys 2019-07-10 17:31:48 +02:00
meson.build libnm-core: add ovs-dpdk setting 2019-06-14 12:10:20 +02:00
nm-connection-private.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-connection.c libnm: accept %NULL argument in nmtst_connection_assert_unchanging() 2019-07-16 12:35:36 +02:00
nm-connection.h libnm: add NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED serialization flag 2019-06-17 12:12:02 +02:00
nm-core-enum-types.c.template libnm-core: add ovs-dpdk setting 2019-06-14 12:10:20 +02:00
nm-core-enum-types.h.template build: use template files for enum types' sources generation 2017-12-18 11:25:06 +01:00
nm-core-internal.h libnm,core: add support for "suppress_prefixlength" rule attribute 2019-07-16 10:03:17 +02:00
nm-core-types-internal.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-core-types.h libnm-core: add ovs-dpdk setting 2019-06-14 12:10:20 +02:00
nm-crypto-gnutls.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-crypto-impl.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-crypto-nss.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-crypto.c libnm/crypto: accept TPM2-wrapped PEM keys 2019-07-10 17:31:48 +02:00
nm-crypto.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-dbus-interface.h settings: track profiles on disk that are shadowed by in-memory connections 2019-07-25 23:27:49 +02:00
nm-dbus-utils.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-errors.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-errors.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-json.c libnm-core: don't use RTLD_DEEPBIND when building with asan 2018-02-15 15:34:03 +01:00
nm-json.h shared: move most of "shared/nm-utils" to "shared/nm-glib-aux" 2019-04-18 18:59:09 +02:00
nm-keyfile-internal.h settings: support storing "shadowed-storage" to [.nmmeta] section for keyfiles in /run 2019-07-25 22:02:00 +02:00
nm-keyfile-utils.c libnm: add nm_key_file_get_boolean() helper 2019-07-16 12:35:36 +02:00
nm-keyfile-utils.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-keyfile.c settings: rework tracking settings connections and settings plugins 2019-07-16 19:09:08 +02:00
nm-property-compare.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-property-compare.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-6lowpan.c libnm-core: reorder code in settings 2019-01-15 09:55:24 +01:00
nm-setting-6lowpan.h libnm-core: add NMSetting{6Lowpan,Wpan}Class to a public header 2018-06-29 22:34:23 +02:00
nm-setting-8021x.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-8021x.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-adsl.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-adsl.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bluetooth.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bluetooth.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bond.c libnm,core: support more "arp_validate" bond options 2019-07-18 12:17:35 +02:00
nm-setting-bond.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bridge-port.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bridge-port.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bridge.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bridge.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-cdma.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-cdma.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-connection.c libnm,cli,ifcfg-rh: add connection:wait-device-timeout property 2019-07-10 12:43:06 +02:00
nm-setting-connection.h libnm,cli,ifcfg-rh: add connection:wait-device-timeout property 2019-07-10 12:43:06 +02:00
nm-setting-dcb.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-dcb.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-dummy.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-dummy.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-ethtool.c libnm: belatedly expose nm_ethtool_optname_is_feature() in libnm 2019-06-11 14:58:14 +02:00
nm-setting-ethtool.h libnm: belatedly expose nm_ethtool_optname_is_feature() in libnm 2019-06-11 14:58:14 +02:00
nm-setting-generic.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-generic.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-gsm.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-gsm.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-infiniband.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-infiniband.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-ip-config.c all: codespell fixes 2019-07-24 11:30:19 +02:00
nm-setting-ip-config.h libnm,core: add support for "suppress_prefixlength" rule attribute 2019-07-16 10:03:17 +02:00
nm-setting-ip-tunnel.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-ip-tunnel.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-ip4-config.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-ip4-config.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-ip6-config.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-ip6-config.h ipv6: add 'disabled' method 2019-06-11 16:22:04 +02:00
nm-setting-macsec.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-macsec.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-macvlan.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-macvlan.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-match.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-match.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-olpc-mesh.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-olpc-mesh.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-ovs-bridge.c core: add ovs-bridge.datapath-type property 2019-07-25 12:32:20 +02:00
nm-setting-ovs-bridge.h core: add ovs-bridge.datapath-type property 2019-07-25 12:32:20 +02:00
nm-setting-ovs-dpdk.c libnm-core: add ovs-dpdk setting 2019-06-14 12:10:20 +02:00
nm-setting-ovs-dpdk.h libnm-core: add ovs-dpdk setting 2019-06-14 12:10:20 +02:00
nm-setting-ovs-interface.c core/ovs-interface: add support for dpdk type 2019-06-14 12:10:20 +02:00
nm-setting-ovs-interface.h libnm-core: add ovs-interface setting 2017-10-30 17:40:08 +01:00
nm-setting-ovs-patch.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-ovs-patch.h libnm-core: add ovs-patch setting 2017-10-30 17:40:08 +01:00
nm-setting-ovs-port.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-ovs-port.h libnm-core: add ovs-port setting 2017-10-30 17:40:08 +01:00
nm-setting-ppp.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-ppp.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-pppoe.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-pppoe.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-private.h libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-proxy.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-proxy.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-serial.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-serial.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-sriov.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-sriov.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-tc-config.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-tc-config.h libnm: don't return deep-copied strv array from nm_tc_qdisc_get_attribute_names() 2019-04-20 08:09:52 +02:00
nm-setting-team-port.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-team-port.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-team.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-team.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-tun.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-tun.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-user.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-user.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-vlan.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-vlan.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-vpn.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-vpn.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-vxlan.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-vxlan.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wifi-p2p.c shared: build helper "libnm-libnm-core-{intern|aux}.la" library for libnm-core 2019-04-18 18:59:09 +02:00
nm-setting-wifi-p2p.h core/setting-wifi-p2p: Add WFD IEs property to P2P settings 2019-02-21 10:10:20 +01:00
nm-setting-wimax.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wimax.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wired.c core/wired: include the invalide MAC address in error messages 2019-07-02 16:06:03 +02:00
nm-setting-wired.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wireguard.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-wireguard.h libnm: change nm_wireguard_peer_set_endpoint() API to allow validation 2019-03-07 17:54:25 +01:00
nm-setting-wireless-security.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wireless-security.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wireless.c libnm: implement serialization options (inject timestamp/seen-bssids) for nm_connection_to_dbus_full() 2019-06-28 16:48:17 +02:00
nm-setting-wireless.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wpan.c libnm-core: reorder code in settings 2019-01-15 09:55:24 +01:00
nm-setting-wpan.h core/setting-wpan: add page and channel properties 2018-10-07 15:46:02 +02:00
nm-setting.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-simple-connection.c libnm: workaround assertion failure for nmtst_connection_assert_unchanging() when disposing connection 2019-06-26 09:53:54 +02:00
nm-simple-connection.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-team-utils.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-team-utils.h libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-utils-private.h libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-utils.c libnm: accept %NULL for @name argument of nm_utils_is_valid_iface_name() 2019-07-25 10:46:18 +02:00
nm-utils.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-version.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-vpn-dbus-interface.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-vpn-editor-plugin.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-vpn-editor-plugin.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-vpn-plugin-info.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-vpn-plugin-info.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00