mirror of
https://github.com/troglobit/finit.git
synced 2026-10-22 11:36:07 +00:00
Fix #492: add per-service directories, systemd RuntimeDirectory style
A service that drops privileges cannot create its own PID file in /run, root owns it. Finit can create the file with pidfile-create, but the daemon still cannot touch it to confirm a SIGHUP. Five new settings, block format only: runtime-dir, state-dir, cache-dir, logs-dir, and config-dir. The value is a directory name, resolved under /run, /var/lib, /var/cache, /var/log, and /etc, respectively. The directory is created before the service starts, mode 0755 owned by user/group, and the full path is exported to the process as RUNTIME_DIRECTORY, STATE_DIRECTORY, CACHE_DIRECTORY, LOGS_DIRECTORY, and CONFIGURATION_DIRECTORY. Mode and ownership are asserted at creation only, a daemon may tighten them afterwards. The runtime directory is removed when the unit stops, after any exec-stop-post script, like systemd with RuntimeDirectoryPreserve=no. A completed run/task counts as stopped unless remain-after-exit keeps it up. The other four persist across restarts. These are the first settings with no legacy token: they are validated by service_set_dir() and stored on the svc that service_register() now returns. systemd accepts a list of directories per setting; this is a single name for now, widening later is compatible since libconfuse accepts a bare value for a list option. The test sysroot gains libnss_files.so.2, which ldd cannot see, glibc dlopen()s it. Without it getpwnam() fails inside the chroot, so user/group settings never resolved and directory ownership could not be tested. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
8 files changed
+299
-2
No files matched your search
+6
-1
@@ -34,7 +34,12 @@ BBBIN = busybox-$(ARCH)
|
||||
BBHOME ?= https://github.com/troglobit/busybox-builder/releases/download
|
||||
BBURL ?= $(BBHOME)/$(BBVER)/$(BBBIN)
|
||||
|
||||
_libs_src = $(shell ldd $(FINITBIN) | grep -Eo '/[^ ]+')
|
||||
# glibc dlopen()s NSS modules at runtime, so ldd does not list them, but
|
||||
# without libnss_files getpwnam() cannot resolve users inside the chroot
|
||||
_libs_nss = $(firstword $(wildcard /lib/$(ARCH)-linux-gnu/libnss_files.so.2 \
|
||||
/usr/lib/$(ARCH)-linux-gnu/libnss_files.so.2 \
|
||||
/lib64/libnss_files.so.2 /lib/libnss_files.so.2))
|
||||
_libs_src = $(shell ldd $(FINITBIN) | grep -Eo '/[^ ]+') $(_libs_nss)
|
||||
libs = $(foreach path,$(_libs_src),$(abspath $(DEST))$(path))
|
||||
|
||||
all: $(libs) $(DEST)/bin/$(BBBIN)
|
||||
|
||||
Reference in new issue
Block a user