Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15:Update
systemd.23200
0001-mount-swap-cryptsetup-introduce-an-option-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-mount-swap-cryptsetup-introduce-an-option-to-prevent.patch of Package systemd.23200
From c61c3e2ac903e6c8a53d0e70ec04eb0fe3a58fd6 Mon Sep 17 00:00:00 2001 From: Franck Bui <fbui@suse.com> Date: Thu, 31 Oct 2019 18:32:08 +0100 Subject: [PATCH 1/1] mount/swap/cryptsetup: introduce an option to prevent systemd from making a unit wanted by its device unit systemd introduced a behavior that consisted in activating automatically a unit generated by either fstab-generator or cryptsetup-generator each time its device unit is entering in plugged state and regardless of whether it happened during the boot process or much later. This behavior is confusing for a lot of users and interacts badly with tools which are operating on block devices. Fortunately this feature has been removed by upstream since v242 for both mount and swap units, with commits 142b8142d7bb84f07ac33fc00527a4d48ac8ef9f and 9b88bb5023dfa3cea406c14fdaa3d8e3e320907a respectively. However for backward compatibility reasons we can't simply drop it, therefore this patch introduces a new (but temporary) kernel command line option named 'systemd.device_wants_unit' so one can choose to prevent systemd from starting automagically a unit which was generated by {cryptsetup,fstab}-generator by setting it to 'off'. The default value for this option is 'on' so no behavior change will happen by default but please note that next major versions of SLE will permanently switch it to 'off' without any possibilities to change it. With this option enabled, it's now possible to prevent all swap units to be activated by masking the swap target. [fbui: fixes jsc#SLE-7689] --- src/basic/proc-cmdline.c | 15 +++++++++++++++ src/basic/proc-cmdline.h | 2 ++ src/core/unit.c | 3 ++- src/cryptsetup/cryptsetup-generator.c | 8 +++++--- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/basic/proc-cmdline.c b/src/basic/proc-cmdline.c index 8592a428d5..3936e809b6 100644 --- a/src/basic/proc-cmdline.c +++ b/src/basic/proc-cmdline.c @@ -247,6 +247,21 @@ int shall_restore_state(void) { return r > 0 ? ret : true; } +bool shall_device_want_unit(void) { + static int device_wants_unit = -1; + + if (device_wants_unit < 0) { + bool ret; + + if (proc_cmdline_get_bool("systemd.device_wants_unit", &ret) > 0) + device_wants_unit = ret; + else + device_wants_unit = true; + } + + return device_wants_unit; +} + static const char * const rlmap[] = { "emergency", SPECIAL_EMERGENCY_TARGET, "-b", SPECIAL_EMERGENCY_TARGET, diff --git a/src/basic/proc-cmdline.h b/src/basic/proc-cmdline.h index ebfed355e9..bb4ebe5ee7 100644 --- a/src/basic/proc-cmdline.h +++ b/src/basic/proc-cmdline.h @@ -52,3 +52,5 @@ static inline bool proc_cmdline_value_missing(const char *key, const char *value return false; } + +bool shall_device_want_unit(void); diff --git a/src/core/unit.c b/src/core/unit.c index febce9d242..736863e48c 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -46,6 +46,7 @@ #include "mkdir.h" #include "parse-util.h" #include "path-util.h" +#include "proc-cmdline.h" #include "process-util.h" #include "set.h" #include "signal-util.h" @@ -3172,7 +3173,7 @@ int unit_add_node_link(Unit *u, const char *what, bool wants, UnitDependency dep if (r < 0) return r; - if (wants) { + if (wants && shall_device_want_unit()) { r = unit_add_dependency(device, UNIT_WANTS, u, false); if (r < 0) return r; diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index 312cdf3d1f..ce47f9f0da 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -195,9 +195,11 @@ static int create_disk( return log_error_errno(r, "Failed to write file %s: %m", p); if (!noauto) { - r = generator_add_symlink(arg_dest, d, "wants", n); - if (r < 0) - return r; + if (shall_device_want_unit()) { + r = generator_add_symlink(arg_dest, d, "wants", n); + if (r < 0) + return r; + } r = generator_add_symlink(arg_dest, netdev ? "remote-cryptsetup.target" : "cryptsetup.target", -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor