Blame SOURCES/0039-Ignore-processing-variable-files-with-unsupported-en.patch
Branch: c8s-sig-hyperscale
dd22ad
From 23742561dcb168604d9668815a8c1ebbdf516d39 Mon Sep 17 00:00:00 2001
dd22ad
From: Jan Kolarik <jkolarik@redhat.com>
dd22ad
Date: Wed, 23 Nov 2022 08:44:41 +0000
dd22ad
Subject: [PATCH 2/2] Ignore processing variable files with unsupported
dd22ad
encoding (RhBug:2141215)
dd22ad
dd22ad
This issue could be seen for example when there are some temporary files stored by text editors in the `/etc/dnf/vars` folder. These files could be in the binary format and causes `UnicodeDecodeError` exception to be thrown during processing of the var files.
dd22ad
dd22ad
= changelog =
dd22ad
type: bugfix
dd22ad
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2141215
dd22ad
---
dd22ad
dnf/conf/substitutions.py | 9 ++++++---
dd22ad
1 file changed, 6 insertions(+), 3 deletions(-)
dd22ad
dd22ad
diff --git a/dnf/conf/substitutions.py b/dnf/conf/substitutions.py
dd22ad
index 1281bdf0..4d0f0d55 100644
dd22ad
--- a/dnf/conf/substitutions.py
dd22ad
+++ b/dnf/conf/substitutions.py
dd22ad
@@ -18,13 +18,15 @@
dd22ad
# Red Hat, Inc.
dd22ad
#
dd22ad
dd22ad
+import logging
dd22ad
import os
dd22ad
import re
dd22ad
dd22ad
-import dnf
dd22ad
-import dnf.exceptions
dd22ad
+from dnf.i18n import _
dd22ad
dd22ad
ENVIRONMENT_VARS_RE = re.compile(r'^DNF_VAR_[A-Za-z0-9_]+$')
dd22ad
+logger = logging.getLogger('dnf')
dd22ad
+
dd22ad
dd22ad
class Substitutions(dict):
dd22ad
# :api
dd22ad
@@ -60,7 +62,8 @@ class Substitutions(dict):
dd22ad
val = fp.readline()
dd22ad
if val and val[-1] == '\n':
dd22ad
val = val[:-1]
dd22ad
- except (OSError, IOError):
dd22ad
+ except (OSError, IOError, UnicodeDecodeError) as e:
dd22ad
+ logger.warning(_("Error when parsing a variable from file '{0}': {1}").format(filepath, e))
dd22ad
continue
dd22ad
if val is not None:
dd22ad
self[fsvar] = val
dd22ad
--
dd22ad
2.39.0
dd22ad