!797 【openEuler-24.03-LTS】fix the systemctl disable cannot delete residual symlink after the unit is deleted
From: @yixiangzhike Reviewed-by: @protkhn Signed-off-by: @protkhn
This commit is contained in:
commit
42d4f7c5de
@ -0,0 +1,74 @@
|
|||||||
|
From 5163c9b1e56293b1bb2803420613c5b374570892 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Luca Boccassi <bluca@debian.org>
|
||||||
|
Date: Fri, 7 Jun 2024 21:39:45 +0100
|
||||||
|
Subject: [PATCH] install: allow removing symlinks even for units that are gone
|
||||||
|
|
||||||
|
If a symlink is leftover, still allow cleaning it up via 'disable'. This
|
||||||
|
happens when a unit is stopped and removed, but not disabled, and a reload
|
||||||
|
has already happened. At that point, cleaning up the old symlinks becomes
|
||||||
|
impossible through the APIs, and needs to be done manually. Always allow
|
||||||
|
cleaning up symlinks, if they exist, by only erroring out if there is an
|
||||||
|
OOM.
|
||||||
|
|
||||||
|
Follow-up for f31f10a6207efc9ae9e0b1f73975b5b610914017
|
||||||
|
|
||||||
|
Conflict:Adaptation TEST-26-SYSTEMCTL.sh to testsuite-26.sh
|
||||||
|
Reference:https://github.com/systemd/systemd/commit/5163c9b1e56293b1bb2803420613c5b374570892
|
||||||
|
|
||||||
|
---
|
||||||
|
src/shared/install.c | 14 ++++++++++----
|
||||||
|
test/units/testsuite-26.sh | 6 ++++++
|
||||||
|
2 files changed, 16 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/shared/install.c b/src/shared/install.c
|
||||||
|
index 0f4dab4..62d9c3c 100644
|
||||||
|
--- a/src/shared/install.c
|
||||||
|
+++ b/src/shared/install.c
|
||||||
|
@@ -2224,7 +2224,9 @@ static int install_context_mark_for_removal(
|
||||||
|
else {
|
||||||
|
log_debug_errno(r, "Unit %s not found, removing name.", i->name);
|
||||||
|
r = install_changes_add(changes, n_changes, r, i->path ?: i->name, NULL);
|
||||||
|
- if (r < 0)
|
||||||
|
+ /* In case there's no unit, we still want to remove any leftover symlink, even if
|
||||||
|
+ * the unit might have been removed already, hence treating ENOENT as non-fatal. */
|
||||||
|
+ if (r != -ENOENT)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
} else if (r < 0) {
|
||||||
|
@@ -2822,9 +2824,13 @@ static int do_unit_file_disable(
|
||||||
|
r = install_info_add(&ctx, *name, NULL, lp->root_dir, /* auxiliary= */ false, &info);
|
||||||
|
if (r >= 0)
|
||||||
|
r = install_info_traverse(&ctx, lp, info, SEARCH_LOAD|SEARCH_FOLLOW_CONFIG_SYMLINKS, NULL);
|
||||||
|
-
|
||||||
|
- if (r < 0)
|
||||||
|
- return install_changes_add(changes, n_changes, r, *name, NULL);
|
||||||
|
+ if (r < 0) {
|
||||||
|
+ r = install_changes_add(changes, n_changes, r, *name, NULL);
|
||||||
|
+ /* In case there's no unit, we still want to remove any leftover symlink, even if
|
||||||
|
+ * the unit might have been removed already, hence treating ENOENT as non-fatal. */
|
||||||
|
+ if (r != -ENOENT)
|
||||||
|
+ return r;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
/* If we enable multiple units, some with install info and others without,
|
||||||
|
* the "empty [Install] section" warning is not shown. Let's make the behavior
|
||||||
|
diff --git a/test/units/testsuite-26.sh b/test/units/testsuite-26.sh
|
||||||
|
index 1e11c42..d08b03a 100755
|
||||||
|
--- a/test/units/testsuite-26.sh
|
||||||
|
+++ b/test/units/testsuite-26.sh
|
||||||
|
@@ -311,6 +311,12 @@ systemctl cat "$UNIT_NAME"
|
||||||
|
systemctl help "$UNIT_NAME"
|
||||||
|
systemctl service-watchdogs
|
||||||
|
systemctl service-watchdogs "$(systemctl service-watchdogs)"
|
||||||
|
+# Ensure that the enablement symlinks can still be removed after the user is gone, to avoid having leftovers
|
||||||
|
+systemctl enable "$UNIT_NAME"
|
||||||
|
+systemctl stop "$UNIT_NAME"
|
||||||
|
+rm -f "/usr/lib/systemd/system/$UNIT_NAME"
|
||||||
|
+systemctl daemon-reload
|
||||||
|
+systemctl disable "$UNIT_NAME"
|
||||||
|
|
||||||
|
# show/set-environment
|
||||||
|
# Make sure PATH is set
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -25,7 +25,7 @@
|
|||||||
Name: systemd
|
Name: systemd
|
||||||
Url: https://systemd.io/
|
Url: https://systemd.io/
|
||||||
Version: 255
|
Version: 255
|
||||||
Release: 30
|
Release: 31
|
||||||
License: MIT and LGPLv2+ and GPLv2+
|
License: MIT and LGPLv2+ and GPLv2+
|
||||||
Summary: System and Service Manager
|
Summary: System and Service Manager
|
||||||
|
|
||||||
@ -75,6 +75,7 @@ Patch6021: backport-pid1-add-env-var-to-override-default-mount-rate-limit-i
|
|||||||
Patch6022: backport-core-escape-spaces-in-paths-during-serialization.patch
|
Patch6022: backport-core-escape-spaces-in-paths-during-serialization.patch
|
||||||
Patch6023: backport-core-escape-spaces-when-serializing-as-well.patch
|
Patch6023: backport-core-escape-spaces-when-serializing-as-well.patch
|
||||||
Patch6024: backport-network-networkd-address-don-t-set-up-firewall-rules.patch
|
Patch6024: backport-network-networkd-address-don-t-set-up-firewall-rules.patch
|
||||||
|
Patch6025: backport-install-allow-removing-symlinks-even-for-units-that-.patch
|
||||||
|
|
||||||
Patch9008: update-rtc-with-system-clock-when-shutdown.patch
|
Patch9008: update-rtc-with-system-clock-when-shutdown.patch
|
||||||
Patch9009: udev-add-actions-while-rename-netif-failed.patch
|
Patch9009: udev-add-actions-while-rename-netif-failed.patch
|
||||||
@ -1667,6 +1668,9 @@ fi
|
|||||||
%{_unitdir}/veritysetup.target
|
%{_unitdir}/veritysetup.target
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Dec 12 2024 yixiangzhike <yixiangzhike007@163.com> - 255-31
|
||||||
|
- fix the systemctl disable cannot delete residual symlink after the unit is deleted
|
||||||
|
|
||||||
* Tue Dec 10 2024 zhangyao <zhangyao108@huawei.com> - 255-30
|
* Tue Dec 10 2024 zhangyao <zhangyao108@huawei.com> - 255-30
|
||||||
- DESC:fix memory leak in src/cryptsetup/cryptsetup-generator.c
|
- DESC:fix memory leak in src/cryptsetup/cryptsetup-generator.c
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user