Blame SOURCES/0005-Ignore-processing-variable-files-with-unsupported-en.patch
|
|
58179d |
From 490cf87dd27926d16fb10735b467cbc490d5c9f1 Mon Sep 17 00:00:00 2001
|
|
|
58179d |
From: Jan Kolarik <jkolarik@redhat.com>
|
|
|
58179d |
Date: Wed, 23 Nov 2022 08:44:41 +0000
|
|
|
58179d |
Subject: [PATCH] Ignore processing variable files with unsupported encoding
|
|
|
58179d |
(RhBug:2141215)
|
|
|
58179d |
|
|
|
58179d |
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.
|
|
|
58179d |
|
|
|
58179d |
= changelog =
|
|
|
58179d |
type: bugfix
|
|
|
58179d |
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2141215
|
|
|
58179d |
---
|
|
|
58179d |
dnf/conf/substitutions.py | 9 ++++++---
|
|
|
58179d |
1 file changed, 6 insertions(+), 3 deletions(-)
|
|
|
58179d |
|
|
|
58179d |
diff --git a/dnf/conf/substitutions.py b/dnf/conf/substitutions.py
|
|
|
58179d |
index 1281bdf0..4d0f0d55 100644
|
|
|
58179d |
--- a/dnf/conf/substitutions.py
|
|
|
58179d |
+++ b/dnf/conf/substitutions.py
|
|
|
58179d |
@@ -18,13 +18,15 @@
|
|
|
58179d |
# Red Hat, Inc.
|
|
|
58179d |
#
|
|
|
58179d |
|
|
|
58179d |
+import logging
|
|
|
58179d |
import os
|
|
|
58179d |
import re
|
|
|
58179d |
|
|
|
58179d |
-import dnf
|
|
|
58179d |
-import dnf.exceptions
|
|
|
58179d |
+from dnf.i18n import _
|
|
|
58179d |
|
|
|
58179d |
ENVIRONMENT_VARS_RE = re.compile(r'^DNF_VAR_[A-Za-z0-9_]+$')
|
|
|
58179d |
+logger = logging.getLogger('dnf')
|
|
|
58179d |
+
|
|
|
58179d |
|
|
|
58179d |
class Substitutions(dict):
|
|
|
58179d |
# :api
|
|
|
58179d |
@@ -60,7 +62,8 @@ class Substitutions(dict):
|
|
|
58179d |
val = fp.readline()
|
|
|
58179d |
if val and val[-1] == '\n':
|
|
|
58179d |
val = val[:-1]
|
|
|
58179d |
- except (OSError, IOError):
|
|
|
58179d |
+ except (OSError, IOError, UnicodeDecodeError) as e:
|
|
|
58179d |
+ logger.warning(_("Error when parsing a variable from file '{0}': {1}").format(filepath, e))
|
|
|
58179d |
continue
|
|
|
58179d |
if val is not None:
|
|
|
58179d |
self[fsvar] = val
|
|
|
58179d |
--
|
|
|
58179d |
2.39.0
|
|
|
58179d |
|