• Thomas Haller's avatar
    libnm,core: add _nm_connection_aggregate() to replace nm_connection_for_each_setting_value() · 7771473f
    Thomas Haller authored
    We should no longer use nm_connection_for_each_setting_value() and
    nm_setting_for_each_value(). It's fundamentally broken as it does
    not work with properties that are not backed by a GObject property
    and it cannot be fixed because it is public API.
    Add an internal function _nm_connection_aggregate() to replace it.
    Compare the implementation of the aggregation functionality inside
    libnm with the previous two checks for secret-flags that it replaces:
    - previous approach broke abstraction and require detailed knowledge of
      secret flags. Meaning, they must special case NMSettingVpn and
      GObject-property based secrets.
      If we implement a new way for implementing secrets (like we will need
      for WireGuard), then this the new way should only affect libnm-core,
      not require changes elsewhere.
    - it's very inefficient to itereate over all settings. It involves
      cloning and sorting the list of settings, and retrieve and clone all
      GObject properties. Only to look at secret properties alone.
    _nm_connection_aggregate() is supposed to be more flexible then just
    the two new aggregate types that perform a "find-any" search. The
    @arg argument and boolean return value can suffice to implement
    different aggregation types in the future.
    Also fixes the check of NMAgentManager for secret flags for VPNs
    is a property that either has a secret or a secret-flag. The previous
    implementation would only look at present secrets and
    check their flags. It wouldn't check secret-flags that are
    NM_SETTING_SECRET_FLAG_NONE, but have no secret.
nm-agent-manager.c 52.4 KB