NetworkManager/src
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
..
devices settings: track profiles on disk that are shadowed by in-memory connections 2019-07-25 23:27:49 +02:00
dhcp dhcp: nettools: check if addr is in the lease when bound 2019-07-25 11:42:12 +02:00
dns all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
dnsmasq all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
initrd initrd/tests: add some more variations of possible BOOTIF= variables 2019-07-03 09:16:52 +02:00
ndisc all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
platform all: codespell fixes 2019-07-24 11:30:19 +02:00
ppp core/pppd-plugin: wait to recover port settings before notifying death 2019-06-14 13:29:45 +02:00
settings settings: track profiles on disk that are shadowed by in-memory connections 2019-07-25 23:27:49 +02:00
supplicant supplicant: allow fast transition for WPA-PSK and WPA-EAP 2019-07-25 12:31:19 +02:00
systemd dhcp: access internal systemd structure to retrieve dhcp private options 2019-07-05 14:12:21 +02:00
tests src/tests: show exit status in test failure of test_nm_utils_kill_child() 2019-06-13 11:27:32 +02:00
vpn all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
main-utils.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
main-utils.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
main.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
meson.build settings: rework tracking settings connections and settings plugins 2019-07-16 19:09:08 +02:00
NetworkManagerUtils.c libnm,core: add support for "suppress_prefixlength" rule attribute 2019-07-16 10:03:17 +02:00
NetworkManagerUtils.h core: add flag to nm_shutdown_wait_obj_register_full() for freeing allcated message string 2019-06-26 12:26:11 +02:00
nm-act-request.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-act-request.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-active-connection.c settings: rework tracking settings connections and settings plugins 2019-07-16 19:09:08 +02:00
nm-active-connection.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-audit-manager.c settings: add audit-logging for connection load and reload 2019-07-16 12:35:36 +02:00
nm-audit-manager.h settings: add audit-logging for connection load and reload 2019-07-16 12:35:36 +02:00
nm-auth-manager.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-auth-manager.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-auth-subject.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-auth-subject.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-auth-utils.c auth-chain: track auth-chains in embedded CList 2019-06-13 16:10:53 +02:00
nm-auth-utils.h auth-chain: track auth-chains in embedded CList 2019-06-13 16:10:53 +02:00
nm-checkpoint-manager.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-checkpoint-manager.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-checkpoint.c settings/trivial: rename NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK to NM_SETTINGS_CONNECTION_PERSIST_MODE_TO_DISK 2019-07-25 22:02:00 +02:00
nm-checkpoint.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-config-data.c config: simplify no-auto-default list handling and sort entries 2019-07-25 10:52:47 +02:00
nm-config-data.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-config.c config: simplify no-auto-default list handling and sort entries 2019-07-25 10:52:47 +02:00
nm-config.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-connectivity.c connectivity: make platform argument to nm_connectivity_check_start() optional 2019-06-18 15:49:09 +02:00
nm-connectivity.h device: don't start connectivity check on unconfigured devices 2019-06-18 15:49:09 +02:00
nm-core-utils.c core: add and use NM_MATCH_SPEC_*_TAG defines instead of plain strings 2019-07-25 10:48:40 +02:00
nm-core-utils.h core: add and use NM_MATCH_SPEC_*_TAG defines instead of plain strings 2019-07-25 10:48:40 +02:00
nm-dbus-manager.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-dbus-manager.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-dbus-object.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-dbus-object.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-dbus-utils.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-dbus-utils.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-dcb.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-dcb.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-dhcp4-config.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-dhcp4-config.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-dhcp6-config.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-dhcp6-config.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-dispatcher.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-dispatcher.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-firewall-manager.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-firewall-manager.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-hostname-manager.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-hostname-manager.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-iface-helper.c dhcp: pass broadcast address to clients 2019-07-05 11:06:01 +02:00
nm-ip4-config.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-ip4-config.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-ip6-config.c core: fix mangling static IPv6 routes in nm_ip6_config_merge_setting() 2019-07-09 14:33:57 +02:00
nm-ip6-config.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-keep-alive.c core: add and use nm_keep_alive_destroy() 2019-06-27 13:25:40 +02:00
nm-keep-alive.h core: add and use nm_keep_alive_destroy() 2019-06-27 13:25:40 +02:00
nm-logging.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-logging.h core: avoid plain pointer values in logging output 2019-06-25 13:26:37 +02:00
nm-manager.c settings/trivial: rename NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK to NM_SETTINGS_CONNECTION_PERSIST_MODE_TO_DISK 2019-07-25 22:02:00 +02:00
nm-manager.h libnm,core: Add ConnectivityCheckUri property and accessors 2019-07-22 21:03:09 +02:00
nm-netns.c policy-routing: take ownership of externally configured rules 2019-07-16 10:16:07 +02:00
nm-netns.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-pacrunner-manager.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-pacrunner-manager.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-policy.c settings: rework tracking settings connections and settings plugins 2019-07-16 19:09:08 +02:00
nm-policy.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-proxy-config.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-proxy-config.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-rfkill-manager.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-rfkill-manager.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-session-monitor.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-session-monitor.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-sleep-monitor.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-sleep-monitor.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-test-utils-core.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-types.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
org.freedesktop.NetworkManager.conf wifi-p2p: rename Wi-Fi P2P 2019-02-01 17:02:57 +01:00