Commit Graph

12 Commits

Author SHA1 Message Date
Yu Watanabe
4b774c740b musl: build-path: fix reading DT_RUNPATH or DT_RPATH
musl records DT_STRTAB as offset, rather than address. So, need to add
obtained bias to read runpath or rpath.
2025-11-13 08:02:05 +09:00
Daan De Meyer
0c15577abe basic + fundamental: Clean up includes
Split out of #37344.
2025-05-25 10:06:07 +02:00
Daan De Meyer
56c710ce37 alloc-util: Remove unneeded stdlib.h include 2025-05-09 11:33:33 +02:00
Mike Yuan
c0ebcb818e build-path: teach pin_callout_binary() to search $PATH too
Prompted by 2caa462504
2025-04-06 02:39:06 +02:00
Mike Yuan
28b6bfd370 build-path: port to open_and_check_executable(), do not return resolved path
Follow-up for b58c240312

We need to be extremely careful with using the path associated with fd,
since it contains the resolved path if a symlink was opened. In particular,
it's really not desirable to return the resolved executable path in
pin_callout_binary(), which would end up as argv[0] in udev_event_spawn(),
potentially changing the behavior of spawned process.
2025-04-06 02:39:05 +02:00
Yu Watanabe
b58c240312 build-path: make pin_callout_binary() optionally provides the path to the found executable 2025-04-04 21:02:18 +09:00
Yu Watanabe
2c31eda469 build-path: check if found path is executable binary
Otherwise, the path may point to a non-executable, e.g. a directory.
2025-04-04 20:56:11 +09:00
Lennart Poettering
2caa462504 build-path: make invoke_callout_binary() honour $PATH as last resort
If we cannot find the callout we need in the build dir let's look for it
in $PATH as last resort.

This makes invoke_callout_binary() usable for all binaries we install
into $PATH (as opposed to /usr/lib/systemd), but has no effect
on callout binaries specified with full path.

This is useful, since we soon want to invoke journalctl as a callout.
2025-04-03 19:40:30 +09:00
Luca Boccassi
ba2caa8a38 build-path: fix SIGSEGV on RISC-V and MIPS
On RISC-V and MIPS DT_STRTAB is an offset, not a full address.

Follow-up for 91d149cfb4
2024-04-30 18:11:10 +02:00
Lennart Poettering
2287565d46 pid1: port executor binary pinning to new build path logic 2024-02-21 09:25:46 +01:00
Lennart Poettering
950ca1788e build-path: allow overriding of all callout binary paths via an env var 2024-02-21 09:25:46 +01:00
Lennart Poettering
91d149cfb4 basic: add "build path" logic
We have a number of components these days that are split into multiple
binaries, i.e. a primary one, and a worker callout usually. These
binaries are closely related, they typically speak a protocol that is
internal, and not safe to mix and match. Examples for this:

- homed and its worker binary homework
- userdbd and its worker binary userwork
- import and the various pull/import/export handlers
- sysupdate the same
- the service manager and the executor binary

Running any of these daemons directly from the meson build tree is
messy, since the implementations will typically invoke the installed
callout binaries, not the ones from the build tree. This is very
annoying, and not obvious at first.

Now, we could always invoke relevant binaries from $(dirname
/proc/self/exe) first, before using the OS installed ones. But that's
typically not what is desired, because this means in the installed case
(i.e. the usual one) we'll look for these callout binaries at a place
they typically will not be found (because these callouts generally are
located in libexecdir, not bindir when installed).

Hence, let's try to do things a bit smarter, and follow what build
systems such as meson have already been doing to make sure dynamic
library discovery works correctly when binaries are run from a build
directory: let's start looking at rpath/runpath in the main binary that
is executed: if there's an rpath/runpath set, then we'll look for the
callout binaries next to the main binary, otherwise we won't. This
should generally be the right thing to do as meson strips the rpath
during installation, and thus we'll look for the callouts in the build
dir if in build dir mode, and in the OS otherwise.
2024-02-21 09:25:46 +01:00