leapp-repository/SOURCES/0007-fix-livemode-do-not-stop-if-dbus-already-appears-to-.patch
eabdullin b1bd6e77a6 Import from CS git
(cherry picked from commit 5bdc5cf293)
2025-05-15 11:55:21 +03:00

62 lines
3.2 KiB
Diff

From 96c911454e4e68a749503b644c31df3a853e8a0b Mon Sep 17 00:00:00 2001
From: Michal Hecko <mhecko@redhat.com>
Date: Thu, 20 Mar 2025 22:29:36 +0100
Subject: [PATCH 07/37] fix(livemode): do not stop if dbus already appears to
be enabled
Some of the systemd units might be already enabled in the target
userspace container, causing an unhandled FileAlreadyExists error
when we attempt to enable them. This commit ignores such errors, working
on under the assumption that the services we wanted to enable are
already enabled. Hence, we ignore the possibility that the file which
unexpectedly resides at the destination of the symlink which enables the
service might contain some unexpected/incorrect content.
---
.../libraries/prepareliveimage.py | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/repos/system_upgrade/common/actors/livemode/modify_userspace_for_livemode/libraries/prepareliveimage.py b/repos/system_upgrade/common/actors/livemode/modify_userspace_for_livemode/libraries/prepareliveimage.py
index c573c84a..686c4cd6 100644
--- a/repos/system_upgrade/common/actors/livemode/modify_userspace_for_livemode/libraries/prepareliveimage.py
+++ b/repos/system_upgrade/common/actors/livemode/modify_userspace_for_livemode/libraries/prepareliveimage.py
@@ -1,3 +1,4 @@
+import errno
import grp
import os
import os.path
@@ -253,16 +254,30 @@ def enable_dbus(context):
Enable dbus-daemon into the target userspace
Looks like it's not enabled by default when installing into a container.
"""
- api.current_logger().info('Configuring the dbus services')
+ dbus_daemon_service = '/usr/lib/systemd/system/dbus-daemon.service'
links = ['/etc/systemd/system/multi-user.target.wants/dbus-daemon.service',
'/etc/systemd/system/dbus.service',
'/etc/systemd/system/messagebus.service']
+ api.current_logger().info(('Enabling dbus services. Leapp will attempt to create the following '
+ 'symlinks: {0}, all pointing to {1}').format(', '.join(links),
+ dbus_daemon_service))
+
for link in links:
+ api.current_logger().debug('Creating symlink at {0} that points to {1}'.format(link, dbus_daemon_service))
try:
os.symlink('/usr/lib/systemd/system/dbus-daemon.service', context.full_path(link))
except OSError as err:
+ if err.errno == errno.EEXIST:
+ # @Note: We are not catching FileExistsError because of python2 (there is no such error class)
+ # We are performing installations within container, so the systemd symlinks that are created
+ # during installation should have correct destination
+ api.current_logger().debug(
+ 'A file already exists at {0}, assuming it is a symlink with a correct content.'
+ )
+ continue
+
details = {'Problem': 'An error occurred while creating the systemd symlink', 'source_error': str(err)}
raise StopActorExecutionError('Cannot enable the dbus services', details=details)
--
2.49.0