From 7547ebbd7b7c316520259e7ca6071dc9fe8bd8aa Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Mon, 23 Dec 2019 12:57:49 +1000 Subject: [PATCH] Add SHUTDOWN_PREFIX build variable, controls name of shutdown executable Useful for installing Dinit alongside eg Sys V init. --- BUILD.txt | 15 ++++++++++++++- src/Makefile | 12 ++++++------ src/dinit.cc | 2 +- src/mconfig-gen.cc | 1 + 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/BUILD.txt b/BUILD.txt index 43d5fb3..7d656b0 100644 --- a/BUILD.txt +++ b/BUILD.txt @@ -63,7 +63,12 @@ SYSCONTROLSOCKET=... BUILD_SHUTDOWN=yes|no Whether to build the "shutdown" (and "halt" etc) utilities. These are only useful if dinit is the system init (i.e. the PID 1 process). You probably don't want this - unless building for Linux. + unless building for Linux. +SHUTDOWN_PREFIX=... + Name prefix for "shutdown", "halt" and "reboot" commands (if they are built). This affects + both the output, and what command dinit will execute as part of system shutdown. + If you want to install Dinit alongside another init system with its own shutdown/halt/reboot + commands, set this (for eg. to "dinit-"). USE_UTMPX=1|0 Whether to build support for manipulating the utmp/utmpx database via the related POSIX functions. If not set to any value, support is enabled for certain systems automatically @@ -72,6 +77,7 @@ SANITIZE_OPTS=... Any options to enable run-time sanitizers or additional safety checks. This will be used only when building tests. It can safely be left blank. + Running test suite =-=-=-=-=-=-=-=-=- @@ -96,6 +102,13 @@ If you get this, either disable the address sanitizer or make sure you have over Any test failures will abort the test suite run immediately. +To run the integration tests: + + make check-igr + +(The integration tests are more fragile than the unit tests, but give a better indication that +Dinit will actually work correctly on your system). + In addition to the standard test suite, there is experimental support for fuzzing the control protocol handling using LLVM/clang's fuzzer (libFuzzer). Change to the `src/tests/cptests` directory and build the "fuzz" target: diff --git a/src/Makefile b/src/Makefile index 88ecb15..c9910eb 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,7 +6,7 @@ HOSTLDFLAGS ?= $(LDFLAGS) STRIPOPTS ?= -s ifeq ($(BUILD_SHUTDOWN),yes) - SHUTDOWN=shutdown + SHUTDOWN=$(SHUTDOWN_PREFIX)shutdown endif dinit_objects = dinit.o load-service.o service.o proc-service.o baseproc-service.o control.o dinit-log.o \ @@ -27,7 +27,7 @@ all: dinit dinitctl dinitcheck $(SHUTDOWN) fi includes/mconfig.h: mconfig-gen - ./mconfig-gen SBINDIR=$(SBINDIR) SYSCONTROLSOCKET=$(SYSCONTROLSOCKET) \ + ./mconfig-gen SBINDIR=$(SBINDIR) SYSCONTROLSOCKET=$(SYSCONTROLSOCKET) SHUTDOWN_PREFIX=$(SHUTDOWN_PREFIX) \ $(if $(USE_UTMPX),USE_UTMPX=$(USE_UTMPX),) > includes/mconfig.h mconfig-gen: mconfig-gen.cc ../mconfig @@ -44,8 +44,8 @@ dinitctl: dinitctl.o dinitcheck: dinitcheck.o options-processing.o $(CXX) -o dinitcheck dinitcheck.o options-processing.o $(LDFLAGS) -shutdown: shutdown.o - $(CXX) -o shutdown shutdown.o $(LDFLAGS) +$(SHUTDOWNPREFIX)shutdown: shutdown.o + $(CXX) -o $(SHUTDOWNPREFIX)shutdown shutdown.o $(LDFLAGS) $(objects): %.o: %.cc $(CXX) $(CXXOPTS) -MMD -MP -Iincludes -Idasynq -c $< -o $@ @@ -63,8 +63,8 @@ install: all install -d $(DESTDIR)$(SBINDIR) install $(STRIPOPTS) dinit dinitctl dinitcheck $(SHUTDOWN) $(DESTDIR)$(SBINDIR) ifeq ($(BUILD_SHUTDOWN),yes) - ln -f $(DESTDIR)$(SBINDIR)/shutdown $(DESTDIR)$(SBINDIR)/halt - ln -f $(DESTDIR)$(SBINDIR)/shutdown $(DESTDIR)$(SBINDIR)/reboot + ln -f $(DESTDIR)$(SBINDIR)/$(SHUTDOWN) $(DESTDIR)$(SBINDIR)/$(SHUTDOWNPREFIX)halt + ln -f $(DESTDIR)$(SBINDIR)/$(SHUTDOWN) $(DESTDIR)$(SBINDIR)/$(SHUTDOWNPREFIX)reboot endif clean: diff --git a/src/dinit.cc b/src/dinit.cc index a5a7cd4..1c78278 100644 --- a/src/dinit.cc +++ b/src/dinit.cc @@ -174,7 +174,7 @@ namespace { log_flush_timer_t log_flush_timer; // These need to be at namespace scope to prevent causing stack allocations when using them: - constexpr auto shutdown_exec = literal(SBINDIR) + "/" + "shutdown"; + constexpr auto shutdown_exec = literal(SBINDIR) + "/" + SHUTDOWN_PREFIX + "shutdown"; constexpr auto error_exec_sd = literal("Error executing ") + shutdown_exec + ": "; } diff --git a/src/mconfig-gen.cc b/src/mconfig-gen.cc index 4ab7075..3b6af17 100644 --- a/src/mconfig-gen.cc +++ b/src/mconfig-gen.cc @@ -71,6 +71,7 @@ int main(int argc, char **argv) cout << "\n// Constants\n"; cout << "constexpr static char SYSCONTROLSOCKET[] = " << stringify(vars["SYSCONTROLSOCKET"]) << ";\n"; cout << "constexpr static char SBINDIR[] = " << stringify(vars["SBINDIR"]) << ";\n"; + cout << "constexpr static char SHUTDOWN_PREFIX[] = " << stringify(vars["SHUTDOWN_PREFIX"]) << ";\n"; cout << "\n#endif\n"; return 0; -- 2.25.1