Skip to content
  • Thomas Haller's avatar
    keyfile: add helper functions to record loaded UUID files · 3fc5765e
    Thomas Haller authored
    This code will be used later.
    
    We want to remember which keyfiles are currently loaded (or hidden).
    
    With the addition or multiple keyfile directories (soon), there are
    two cases where this matters:
    
     - if there are multiple keyfiles which reference the same UUID,
       we can only load one of them. That is already a problem today
       with only one keyfile directory, where multiple files can reference
       the same UUID.
       The implementation will pick the file based on priorities (like
       the file modification date). However, the user may call explicitly
       call `nmcli connection load`. In that case, we cannot reload
       all files to find out whether the to be loaded file is hidden
       according to the defined priorities. We cannot do that, because we
       must not make decisions based on files on disk, which we are not told
       to reload. So, during a `nmcli connection load` we must look at
       unrelated files, to determine how to load the file.
       Instead, we do allow the user to load any file, even if it would be
       shadowed by other files. When we do that, we may want to persist which
       file is currently loaded, so that a service restart and a `nmcli connection
       reload` does not undo the load again. This can be later later be solved by
       writing a symlink
    
           "/var/run/NetworkManager/system-connections/.loaded-$UUID.nmkeyfile"
    
       which targets the currently active file.
    
     - if a profile was loaded from read-only persistant storage, the user
       may still delete the profile. We also need to remember the deletion
       of the file. That will be achieved by symlinking "/dev/null" as
       "/etc/NetworkManager/system-connections/.loaded-$UUID.nmkeyfile".
    
    Add helper functions to read and write these symlinks.
    3fc5765e