core: reliably check if varlink socket has been deserialized
authorMike Yuan <me@yhndnzj.com>
Tue, 23 Jul 2024 15:55:12 +0000 (17:55 +0200)
committerMike Yuan <me@yhndnzj.com>
Tue, 23 Jul 2024 17:38:57 +0000 (19:38 +0200)
commitd4e5c66ed469c822ca5346c7a445ec1446b1d17f
treebc2295d186f2407c9ef13b72a21d11b77768fae4
parent7973f33e818d1fca5df21c1335579035ca8f91c1
core: reliably check if varlink socket has been deserialized

Follow-up for 6906c028e83b77b35eaaf87b27d0fe5c6e1984b7

The mentioned commit uses access() to check if varlink socket
already exists in the filesystem, but that isn't sufficient.

> Varlink sockets are not serialized until v252, so upgrading from
> v251 or older means we will not listen anymore on the varlink sockets.
>
> See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1074789
> for more details as this was found when updating from Debian Bullseye to a new version.

After this commit, the set up of varlink_server is effectively
split into two steps. manager_varlink_init_system(), which is
called after deserialization, would no longer skip listening
even if Manager.varlink_server is in place, but actually
check if we're listening on desired sockets.
Then, manager_deserialize() can be switched back to using
manager_setup_varlink_server().

Alternative to #33817

Co-authored-by: Luca Boccassi <bluca@debian.org>
src/core/core-varlink.c
src/core/core-varlink.h
src/core/manager-serialize.c