• Thomas Haller's avatar
    device: support dynamic "connection.stable-id" in form of text-substitution · f0d40525
    Thomas Haller authored
    Usecase: when connecting to a public Wi-Fi with MAC address randomization
    ("wifi.cloned-mac-address=random") you get on every re-connect a new
    IP address due to the changing MAC address.
    "wifi.cloned-mac-address=stable" is the solution for that. But that
    means, every time when reconnecting to this network, the same ID will
    be reused. We want an ID that is stable for a while, but at a later
    point a new ID should e generated when revisiting the Wi-Fi network.
    Extend the stable-id to become dynamic and support templates/substitutions.
    Currently supported is "${CONNECTION}", "${BOOT}" and "${RANDOM}".
    Any unrecognized pattern is treated verbaim/untranslated.
    "$$" is treated special to allow escaping the '$' character. This allows
    the user to still embed verbatim '$' characters with the guarantee that
    future versions of NetworkManager will still generate the same ID.
    Of course, a user could just avoid '$' in the stable-id unless using
    it for dynamic substitutions.
    Later we might want to add more recognized substitutions. For example, it
    could be useful to generate new IDs based on the current time. The ${} syntax
    is extendable to support arguments like "${PERIODIC:weekly}".
    Also allow "connection.stable-id" to be set as global default value.
    Previously that made no sense because the stable-id was static
    and is anyway strongly tied to the identity of the connection profile.
    Now, with dynamic stable-ids it gets much more useful to specify
    a global default.
    Note that pre-existing stable-ids don't change and still generate
    the same addresses -- unless they contain one of the new ${} patterns.
nm-core-utils.c 124 KB