Skip to content

Commit 6a87995

Browse files
committed
Do not create dangling symlinks for containerized RHSM
When setting RHSM into the container mode, we are creating symlinks to /etc/rhsm and /etc/pki/entitlement directories. However, this creates dangling symlinks if RHSM is not installed or user manually removes one of these dirs. If any of these directories is missing, skip other actions and log the warning. Usually it means that RHSM is not actually used or installed at all, so in these cases we can do the skip. The only corner case when system could use RHSM without /etc/pki/entitlement is when RHSM is configured to put these certificate on a different path, and we do not support nor cover such a scenario as we are not scanning the RHSM configuration at all. This also solves the problems on systems that does not have RHSM available at all.
1 parent b6e409e commit 6a87995

File tree

1 file changed

+14
-0
lines changed
  • repos/system_upgrade/common/libraries

1 file changed

+14
-0
lines changed

repos/system_upgrade/common/libraries/rhsm.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,27 @@ def set_container_mode(context):
325325
could be affected and the generated repo file in the container could be
326326
affected as well (e.g. when the release is set, using rhsm, on the host).
327327
328+
We want to put RHSM into the container mode always when /etc/rhsm and
329+
/etc/pki/entitlement directories exists, even when leapp is executed with
330+
--no-rhsm option. If any of these directories are missing, skip other
331+
actions - most likely RHSM is not installed in such a case.
332+
328333
:param context: An instance of a mounting.IsolatedActions class
329334
:type context: mounting.IsolatedActions class
330335
"""
331336
if not context.is_isolated():
332337
api.current_logger().error('Trying to set RHSM into the container mode'
333338
'on host. Skipping the action.')
334339
return
340+
if (not os.path.exists(context.full_path('/etc/rhsm'))
341+
or not os.path.exists(context.full_path('/etc/pki/entitlement'))):
342+
api.current_logger().warning(
343+
'Cannot set the container mode for the subscription-manager as'
344+
' one of required directories is missing. Most likely RHSM is not'
345+
' installed. Skipping other actions.'
346+
)
347+
return
348+
335349
try:
336350
context.call(['ln', '-s', '/etc/rhsm', '/etc/rhsm-host'])
337351
context.call(['ln', '-s', '/etc/pki/entitlement', '/etc/pki/entitlement-host'])

0 commit comments

Comments
 (0)