Skip to content
  • Thomas Haller's avatar
    dns: change main.rc-manager=file behavior to always follow symlink · 644aa42f
    Thomas Haller authored
    With "main.rc-manager=file", if /etc/resolv.conf is a symlink, NetworkManager
    would follow the symlink and update the file instead.
    
    However, note that realpath() only returns a target, if the file actually
    exists. That means, if /etc/resolv.conf is a dangling symlink, NetworkManager
    would replace the symlink with a file.
    
    This was the only case in which NetworkManager would every change a symlink
    resolv.conf to a file. I think this is undesired behavior.
    
    This is a change in long established behavior. Although note that there were several
    changes regarding rc-manager settings in the past. See for example commit [1] and [2].
    
    Now, first still try using realpath() as before. Only if that fails, try
    to resolve /etc/resolv.conf as a symlink with readlink().
    
    Following the dangling symlink is likely not a problem for the user, it
    probably is even desired. The part that most likely can cause problems
    is if the destination file is not writable. That happens for example, if
    the destination's parent directories are missing. In this case, NetworkManager
    will now fail to write resolv.conf and log a warning. This has the potential of
    breaking existing setups, but it really is a mis-configuration from the user's
    side.
    
    This fixes for example the problem, if the user configures
    /etc/resolv.conf as symlink to /tmp/my-resolv.conf. At boot, the file
    would not exist, and NetworkManager would previously always replace the
    link with a plain file. Instead, it should follow the symlink and create
    the file.
    
    [1] 718fd224
    [2] 15177a34
    
    https://github.com/NetworkManager/NetworkManager/pull/127
    644aa42f
To find the state of this project's repository at the time of any of these versions, check out the tags.