network: add externally managed profiles
cover network: add externally managed profiles
Add [Settings].ExternallyManaged for network profiles whose contents are owned by another network manager.
This is intended for setups where an external manager writes iwd profile files so iwd can read the connection parameters, but the external manager remains the source of truth for the file contents and secret storage policy. In that case iwd should not rewrite the profile as a side effect of normal network operation.
When ExternallyManaged=true is set, iwd still reads the profile and can use it for connection setup, but skips profile writes during normal network operation. Explicit profile removal through KnownNetwork.Forget remains available.
This works for handcrafted profiles and for profiles mirrored by another manager such as NetworkManager.
Matthias Kurz (2):
network: add externally managed profiles
doc: document externally managed profiles
src/iwd.network.rst | 8 ++++ src/knownnetworks.c | 8 ++++ src/knownnetworks.h | 2 + src/network.c | 67 +++++++++++++++++++------- src/storage.c | 17 ++++++- unit/test-storage.c | 114 +++++++++++++++++++++++++++++++++++++++++++- 6 files changed, 196 insertions(+), 20 deletions(-)
PATCH 1/2 network: add externally managed profiles
Add [Settings].ExternallyManaged for network profiles whose contents are owned by another network manager. IWD still reads these profiles for connection setup, but avoids updating them as a side effect of network operation.
Skip connection timestamp/profile writes, security cache writes, automatic profile encryption rewrites, and KnownNetwork AutoConnect persistence for externally managed profiles. Explicit Forget remains available through the existing removal path.
Add storage tests covering the existing encryption rewrite path and the externally managed no-rewrite case.
--- src/knownnetworks.c | 8 ++++ src/knownnetworks.h | 2 + src/network.c | 67 +++++++++++++++++++------- src/storage.c | 17 ++++++- unit/test-storage.c | 114 +++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 188 insertions(+), 20 deletions(-)
src/knownnetworks.c +8 -0
@@ -82,6 +82,11 @@ void __network_config_parse(const struct l_settings *settings, config->always_random_addr = b; +if (!l_settings_get_bool (settings,NET_EXTERNALLY_MANAGED , &b)) + b = false; + + config->externally_managed = b; + value =l_settings_get_value (settings,NET_ADDRESS_OVERRIDE );if (value) { if (util_string_to_address(value, new_addr) &&
@@ -690,6 +695,9 @@ static struct l_dbus_message *known_network_property_set_autoconnect(if (network->config.is_autoconnectable == autoconnect)return l_dbus_message_new_method_return (message); +if (network->config.externally_managed) +return dbus_error_not_available (message); + settings = network->ops->open (network);if (!settings)return dbus_error_failed (message);
src/knownnetworks.h +2 -0
@@ -30,6 +30,7 @@#define NET_TRANSITION_DISABLE SETTINGS, "TransitionDisable"#define NET_TRANSITION_DISABLE_MODES SETTINGS, "DisabledTransitionModes"#define NET_USE_DEFAULT_ECC_GROUP SETTINGS, "UseDefaultEccGroup" +#define NET_EXTERNALLY_MANAGED SETTINGS, "ExternallyManaged"enum security ;struct scan_freq_set ;
@@ -82,6 +83,7 @@ struct network_config { bool have_transition_disable : 1;uint8_t transition_disable;enum known_network_ecc_group ecc_group; + bool externally_managed : 1; };struct network_info {
src/network.c +50 -17
93 lines not on this page · raw message
src/storage.c +16 -1
@@ -559,10 +559,22 @@ done:return 0 ; } +static bool storage_settings_are_externally_managed ( +struct l_settings *settings) +{ +bool externally_managed; + +if (!l_settings_get_bool (settings,"Settings" ,"ExternallyManaged" , + &externally_managed)) +return false; + +return externally_managed; +} +/* * Decrypts a network profile (if needed). If profile encryption is enabled * and the profile is unencrypted it will be encrypted and written back to -* the file system automatically. +* the file system automatically, unless [Settings].ExternallyManaged is true. * * 'name' is used for decryption and is used as part of the IV. Callers * should provide a unique identifier here if available. For example, the
@@ -581,6 +593,9 @@ bool storage_decrypt(struct l_settings *settings, const char *path,if (!needs_encryption)return true; +if (storage_settings_are_externally_managed (settings)) +return true; +/* Profile never encrypted before. Encrypt and write to disk */ encrypted =__storage_encrypt (settings, name, &elen);if (!encrypted) {
unit/test-storage.c +112 -2
137 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH 2/2 doc: document externally managed profiles
In reply to Matthias KurzDocument [Settings].ExternallyManaged in iwd.network. The setting marks profiles that IWD may read but must not update during normal network operation, while explicit removal remains allowed.
--- src/iwd.network.rst | 8 ++++++++ 1 file changed, 8 insertions(+)
src/iwd.network.rst +8 -0
@@ -174,6 +174,14 @@ The group ``[Settings]`` contains general settings. Properly configured Access Points will typically update this setting appropriately via Transition Disable indications. User customization of this value is thus typically not required. + * - ExternallyManaged + - Values: true, **false** + + If enabled, the profile contents are managed by an external + application. IWD will read the profile but will not update it as a + side effect of network operation, for example to persist connection + metadata or security material learned at runtime. Explicit profile + removal through the KnownNetwork Forget method is still allowed. * - UseDefaultEccGroup - Values: true, false
Signature · 1 line
2.54.0