No, just a single instance (with e.g. -i), running outside of a systemd
service (but on a systemd bootet system). The main issue is that
sd_booted() only checks if the system is booted with systemd, but not
if the executable is running inside a systemd service.
>
> If not, I do not see the issue. Systemd does not start SWUpdate, and
> SWUpdate generates itself the sockets.
>
> > That's a bigger design
> > flaw. As there is no reliable way to detect if the service is
> > running
> > under systemd, we indeed must rely on fixed socket paths. But the
> > socket paths must not depend on the TMPDIR.
>
> But we know if SWUpdate is running in foreground as one-shot updater,
> or
> it is running as daemon.
>
> TMPDIR (name is not the best, I agree) is just the HOME directory for
> SWUpdate's temporary files, including sockets. It can be set to
> whatever
> we want before starting. Which are the issues you are currently
> seeing
> with it ?
If we change TMPDIR inside the systemd unit file, the sockets provided
by systemd are still created below /run. However swupdate wants to
connect to the sockets under $TMPDIR/ and there are none. Hence it
thinks no sockets were provided by systemd and creates these. Later in
the cleanup, the (incorrect) logic checks if the system was bootet
using systemd and the sockets created by swupdate are not removed.
>
> >
> > >
> > > I guess that to improve like you want to have, something more
> > > should
> > > be
> > > done. SWUpdate should store if it runs in foreground or not, and
> > > raise
> > > the error just in case it is planned that it is started by
> > > systemd.
> >
> > The socket cleanup logic needs to handle that case correctly, as it
> > needs to track if sockets were created and not if the init system
> > is
> > systemd.
>
> Well, it is the same. Socket creation outside of SWUpdate happens
> just
> if systemd did it. There are not other use cases.
Still, we need to track if the sockets were created by swupdate and
hence need to be cleaned up by swupdate.
>
> >
> > Finally, all the sd_bootet checks can be removed as the output is
> > meaningless anyways.
> > All sd_* functions also behave correctly on non
> > systemd bootet systems.
>
> Ok, I need some more information. Where is coming ds_boot() if we
> have
> no systemd ?
We need to distinguish between compile time and runtime. We already
have ifdefs to enable / disable systemd support. At runtime, we
currently check (in case sd support was compiled in), if the system is
booted with systemd (i.e. pid1 is systemd). These checks are
irrelevant, as all sd_* functions internally already do that.
>
> > That's explicitly stated in the man page.
>
> I do not know what you mean.
man sd_booted
>
> On systems without systemd, there is no libsystemd. libsystemd cannot
> be
> built at all, and I mean on OE build when virtual_init is not set to
> systemd. This requires the introduction of CONFIG_SYSTEMD here, while
> everything could be cleaner just by checking the return code of
> sd_booted, if available.
>
> So please explain me better, I have not yet understood.
Yes, exactly. My plan is to keep the compile time guards, but remove
the runtime guards, as these are not required.
Best regards,
Felix