]> git.proxmox.com Git - pmg-api.git/commit
cluster config: restrict slurp scope to avoid issue parsing network interfaces
authorFiona Ebner <f.ebner@proxmox.com>
Mon, 10 Jul 2023 11:36:46 +0000 (13:36 +0200)
committerStoiko Ivanov <s.ivanov@proxmox.com>
Mon, 10 Jul 2023 15:29:05 +0000 (17:29 +0200)
commit22b7ba385434a1efb7de566be67788ceafda38c5
tree6678e1318ee74ef45e1017b3367d0ed8acab67d3
parentd649469164b3b39773912aa4c6184abbd27e84a4
cluster config: restrict slurp scope to avoid issue parsing network interfaces

As reported in the community forum [0], there is an edge case, where
querying the network interfaces would not work. In particular, this
could happen if the hostname cannot be resolved to a non-loopback IP
(when installing PMG on Debian and forgetting to adapt /etc/hosts for
example).

The issue manifested as follows:
- When setting up the RESTEnvironemnt, the cluster config is read.
- This reader uses slurp mode by setting the line ending to undef
  locally.
- But the subroutine call PVE::Network::get_local_ip() is still part
  of that local context.
- When resolving the hostname to a non-loopback IP address failed, the
  function would read (via the PVE::INotify module) the network
  interfaces file.
- As part of that, /proc/net/dev was read all at once, while the
  interface parsing code expects it line-by-line.
- The result for reading network interfaces was cached without having
  detected the interfaces in /proc/net/dev.
- When a new request came in, the cached result was used (even
  changing the file to invalidate the cache would only work as long
  as the cluster config file exists, because otherwise, there would be
  an attempt to read the cluster config which would read the updated
  version of the interfaces file while slurping again).

[0]: https://forum.proxmox.com/threads/129958/

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
src/PMG/ClusterConfig.pm