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