You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
systemd/SOURCES/0328-generators-change-Time...

222 lines
12 KiB

From cfff52ac273243140b894b735221c0eef2891fe8 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 6 Jun 2023 09:29:51 +0200
Subject: [PATCH] generators: change TimeoutSec=0 to TimeoutSec=infinity
With these settings we intend to turn off timeouts for possibly
interactive/slow commands. The officially documented way to turn off the
time-outs is to setting them to infinity. So far we set them to zero
here though.
This lead to some confusiong, for example #18224. Let's fix this by
uniformly spelling out TimeoutSec=infinity.
This doesn't change behaviour. It just makes our generated files match
what we document, without relying on historic compat support.
Fixes: #18224
(cherry picked from commit a9b837aa34a2d0bff1687427c66bed3b74cf0fed)
Related: #2190226
---
src/cryptsetup/cryptsetup-generator.c | 3 ++-
src/gpt-auto-generator/gpt-auto-generator.c | 2 +-
src/hibernate-resume/hibernate-resume-generator.c | 3 ++-
src/integritysetup/integritysetup-generator.c | 2 +-
src/shared/generator.c | 8 ++++----
.../test-12-dev-sdx.expected/systemd-fsck-root.service | 2 +-
.../test-13-label.expected/systemd-fsck-root.service | 2 +-
.../test-14-uuid.expected/systemd-fsck-root.service | 2 +-
.../test-15-partuuid.expected/systemd-fsck-root.service | 2 +-
.../systemd-fsck-root.service | 2 +-
.../systemd-fsck-root.service | 2 +-
.../systemd-makefs@dev-sdx12.service | 2 +-
.../systemd-mkswap@dev-sdy2.service | 2 +-
.../systemd-mkswap@dev-sdy3.service | 2 +-
14 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index 07903f1044..9e8e7e746f 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -551,7 +551,8 @@ static int create_disk(
if (!noauto && !nofail) {
r = write_drop_in(arg_dest, dmname, 40, "device-timeout",
"# Automatically generated by systemd-cryptsetup-generator\n\n"
- "[Unit]\nJobTimeoutSec=0");
+ "[Unit]\n"
+ "JobTimeoutSec=infinity\n");
if (r < 0)
log_warning_errno(r, "Failed to write device timeout drop-in: %m");
}
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index 143faa0c39..0bab43e69a 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -112,7 +112,7 @@ static int add_cryptsetup(
r = write_drop_in_format(arg_dest, dmname, 50, "job-timeout",
"# Automatically generated by systemd-gpt-auto-generator\n\n"
"[Unit]\n"
- "JobTimeoutSec=0"); /* the binary handles timeouts anyway */
+ "JobTimeoutSec=infinity"); /* the binary handles timeouts anyway */
if (r < 0)
log_warning_errno(r, "Failed to write device timeout drop-in, ignoring: %m");
diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c
index 82c2a56493..6714fbf408 100644
--- a/src/hibernate-resume/hibernate-resume-generator.c
+++ b/src/hibernate-resume/hibernate-resume-generator.c
@@ -94,7 +94,8 @@ static int process_resume(void) {
r = write_drop_in(arg_dest, device_unit, 40, "device-timeout",
"# Automatically generated by systemd-hibernate-resume-generator\n\n"
- "[Unit]\nJobTimeoutSec=0");
+ "[Unit]\n"
+ "JobTimeoutSec=infinity\n");
if (r < 0)
log_warning_errno(r, "Failed to write device timeout drop-in: %m");
diff --git a/src/integritysetup/integritysetup-generator.c b/src/integritysetup/integritysetup-generator.c
index 15f508902d..5df6d81a84 100644
--- a/src/integritysetup/integritysetup-generator.c
+++ b/src/integritysetup/integritysetup-generator.c
@@ -100,7 +100,7 @@ static int create_disk(
"[Service]\n"
"Type=oneshot\n"
"RemainAfterExit=yes\n"
- "TimeoutSec=0\n"
+ "TimeoutSec=infinity\n"
"ExecStart=" ROOTLIBEXECDIR "/systemd-integritysetup attach '%s' '%s' '%s' '%s'\n"
"ExecStop=" ROOTLIBEXECDIR "/systemd-integritysetup detach '%s'\n",
name_escaped, device, empty_to_dash(key_file_escaped), empty_to_dash(options),
diff --git a/src/shared/generator.c b/src/shared/generator.c
index 5d617bbe99..f1c5e506ab 100644
--- a/src/shared/generator.c
+++ b/src/shared/generator.c
@@ -218,7 +218,7 @@ static int write_fsck_sysroot_service(
"Type=oneshot\n"
"RemainAfterExit=yes\n"
"ExecStart=" SYSTEMD_FSCK_PATH " %7$s\n"
- "TimeoutSec=0\n",
+ "TimeoutSec=infinity\n",
program_invocation_short_name,
escaped,
unit,
@@ -513,7 +513,7 @@ int generator_hook_up_mkswap(
"Type=oneshot\n"
"RemainAfterExit=yes\n"
"ExecStart="SYSTEMD_MAKEFS_PATH " swap %s\n"
- "TimeoutSec=0\n",
+ "TimeoutSec=infinity\n",
program_invocation_short_name,
where_unit,
escaped);
@@ -594,7 +594,7 @@ int generator_hook_up_mkfs(
"Type=oneshot\n"
"RemainAfterExit=yes\n"
"ExecStart="SYSTEMD_MAKEFS_PATH " %s %s\n"
- "TimeoutSec=0\n",
+ "TimeoutSec=infinity\n",
program_invocation_short_name,
where_unit,
type,
@@ -738,7 +738,7 @@ int generator_write_cryptsetup_service_section(
"[Service]\n"
"Type=oneshot\n"
"RemainAfterExit=yes\n"
- "TimeoutSec=0\n" /* The binary handles timeouts on its own */
+ "TimeoutSec=infinity\n" /* The binary handles timeouts on its own */
"KeyringMode=shared\n" /* Make sure we can share cached keys among instances */
"OOMScoreAdjust=500\n" /* Unlocking can allocate a lot of memory if Argon2 is used */
"ExecStart=" SYSTEMD_CRYPTSETUP_PATH " attach '%s' '%s' '%s' '%s'\n"
diff --git a/test/test-fstab-generator/test-12-dev-sdx.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-12-dev-sdx.expected/systemd-fsck-root.service
index 95d943b87a..147348899d 100644
--- a/test/test-fstab-generator/test-12-dev-sdx.expected/systemd-fsck-root.service
+++ b/test/test-fstab-generator/test-12-dev-sdx.expected/systemd-fsck-root.service
@@ -14,4 +14,4 @@ Before=shutdown.target
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-fsck /dev/sdx1
-TimeoutSec=0
+TimeoutSec=infinity
diff --git a/test/test-fstab-generator/test-13-label.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-13-label.expected/systemd-fsck-root.service
index d6c59ff608..85c1936bce 100644
--- a/test/test-fstab-generator/test-13-label.expected/systemd-fsck-root.service
+++ b/test/test-fstab-generator/test-13-label.expected/systemd-fsck-root.service
@@ -14,4 +14,4 @@ Before=shutdown.target
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-fsck /dev/disk/by-label/Root
-TimeoutSec=0
+TimeoutSec=infinity
diff --git a/test/test-fstab-generator/test-14-uuid.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-14-uuid.expected/systemd-fsck-root.service
index cd9583c4dd..1c7eaea103 100644
--- a/test/test-fstab-generator/test-14-uuid.expected/systemd-fsck-root.service
+++ b/test/test-fstab-generator/test-14-uuid.expected/systemd-fsck-root.service
@@ -14,4 +14,4 @@ Before=shutdown.target
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-fsck /dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7
-TimeoutSec=0
+TimeoutSec=infinity
diff --git a/test/test-fstab-generator/test-15-partuuid.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-15-partuuid.expected/systemd-fsck-root.service
index 650ed8070a..ab27bfd79c 100644
--- a/test/test-fstab-generator/test-15-partuuid.expected/systemd-fsck-root.service
+++ b/test/test-fstab-generator/test-15-partuuid.expected/systemd-fsck-root.service
@@ -14,4 +14,4 @@ Before=shutdown.target
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-fsck /dev/disk/by-partuuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7
-TimeoutSec=0
+TimeoutSec=infinity
diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service
index 95d943b87a..147348899d 100644
--- a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service
+++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected/systemd-fsck-root.service
@@ -14,4 +14,4 @@ Before=shutdown.target
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-fsck /dev/sdx1
-TimeoutSec=0
+TimeoutSec=infinity
diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/systemd-fsck-root.service b/test/test-fstab-generator/test-18-options.fstab.expected/systemd-fsck-root.service
index 95d943b87a..147348899d 100644
--- a/test/test-fstab-generator/test-18-options.fstab.expected/systemd-fsck-root.service
+++ b/test/test-fstab-generator/test-18-options.fstab.expected/systemd-fsck-root.service
@@ -14,4 +14,4 @@ Before=shutdown.target
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-fsck /dev/sdx1
-TimeoutSec=0
+TimeoutSec=infinity
diff --git a/test/test-fstab-generator/test-18-options.fstab.expected/systemd-makefs@dev-sdx12.service b/test/test-fstab-generator/test-18-options.fstab.expected/systemd-makefs@dev-sdx12.service
index 303c1ee680..4670c23e27 100644
--- a/test/test-fstab-generator/test-18-options.fstab.expected/systemd-makefs@dev-sdx12.service
+++ b/test/test-fstab-generator/test-18-options.fstab.expected/systemd-makefs@dev-sdx12.service
@@ -15,4 +15,4 @@ Before=shutdown.target
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-makefs ext4 /dev/sdx12
-TimeoutSec=0
+TimeoutSec=infinity
diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy2.service b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy2.service
index 0911f03f62..0b0e7270ba 100644
--- a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy2.service
+++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy2.service
@@ -15,4 +15,4 @@ Before=shutdown.target
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-makefs swap /dev/sdy2
-TimeoutSec=0
+TimeoutSec=infinity
diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy3.service b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy3.service
index 6201fec86b..1164c99476 100644
--- a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy3.service
+++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/systemd-mkswap@dev-sdy3.service
@@ -15,4 +15,4 @@ Before=shutdown.target
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-makefs swap /dev/sdy3
-TimeoutSec=0
+TimeoutSec=infinity