Skip to content
  • Thomas Haller's avatar
    dns: move PID handling from NMDnsPlugin to NMDnsDnsmasq implementation · b288ea13
    Thomas Haller authored
    We only have two real DNS plugins: "dnsmasq" and "systemd-resolved" (the "unbound"
    plugin is very incomplete and should eventually be dropped).
    
    Of these two, only "dnsmasq" spawns a child process. A lot of the logic
    for that is in the parent class NMDnsPlugin, with the purpose for that
    logic to be reusable.
    
    However:
    
     - We are unlikely to add more DNS plugins. Especially because
       systemd-resolved seems the way forward.
    
     - If we happen to add more plugins, then probably NetworkManager
       should not spawn the process itself. That causes problems with
       restarting the service. Rather, we should let the service manager
       handle the lifetime of such "child" processes. Aside separating
       the lifetime of the DNS plugin process from NetworkManager's,
       this also would allow to sandbox NetworkManager and the DNS plugin
       differently. Currently, NetworkManager itself may might need
       capabilities only to pass them on to the DNS plugin, or (more likely)
       NetworkManager would want to drop additional capabilities for the
       DNS plugin (which we would rather not implement ourself, since that
       seems job of the service management already).
    
     - The current implementation is far from beautiful. For example,
       it does synchronous (blocking) killing of the running process
       from the PID file, and it uses PID fils. This is not something
       we would want to reuse for other plugins. Also, note that
       dnsmasq already spawns the service asynchronosly (of course).
       Hence, we should also kill it asynchronously, but that is complicated
       by having the logic separated in two different classes while
       providing an abstract API between the two.
    
    Move the code to NMDnsDnsmasq. This is the only place that cares about
    this. Also, that makes it actually clearer what is happening, by seeing
    the lifetime handling of the child proceess all in one place.
    b288ea13