diff --git a/.dnf.metadata b/.dnf.metadata new file mode 100644 index 0000000..8fa9d1a --- /dev/null +++ b/.dnf.metadata @@ -0,0 +1 @@ +f9c31cf46094c4bbf021e1872a9eb72d8a3f2136 SOURCES/dnf-4.7.0.tar.gz diff --git a/SOURCES/0048-smtplib-catch-OSError-not-SMTPException.patch b/SOURCES/0048-smtplib-catch-OSError-not-SMTPException.patch new file mode 100644 index 0000000..7535b48 --- /dev/null +++ b/SOURCES/0048-smtplib-catch-OSError-not-SMTPException.patch @@ -0,0 +1,36 @@ +From a1feaf8c26433325dd939a4bb0c47b50b44cfe2d Mon Sep 17 00:00:00 2001 +From: Evan Goode +Date: Mon, 13 Mar 2023 14:50:41 -0400 +Subject: [PATCH 48/49] smtplib: catch OSError, not SMTPException + +Upstream commit: aab7defca4fd827ede02336e5a0cf95e8691fb74 + +Some, but not all, types of connection error are caught by smtplib and +reraised as an smtplib.SMTPException. Notably, TimeoutError, +socket.gaierror (name resolution failure), and ConnectionRefusedError +and are not caught. + +The more generic OSError should be caught here instead. + +Resolves #1905 +Resolves: https://issues.redhat.com/browse/RHEL-46030 +--- + dnf/automatic/emitter.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/dnf/automatic/emitter.py b/dnf/automatic/emitter.py +index 4aea4b02..648f1a1d 100644 +--- a/dnf/automatic/emitter.py ++++ b/dnf/automatic/emitter.py +@@ -106,7 +106,7 @@ class EmailEmitter(Emitter): + smtp = smtplib.SMTP(self._conf.email_host, timeout=300) + smtp.sendmail(email_from, email_to, message.as_string()) + smtp.close() +- except smtplib.SMTPException as exc: ++ except OSError as exc: + msg = _("Failed to send an email via '%s': %s") % ( + self._conf.email_host, exc) + logger.error(msg) +-- +2.48.1 + diff --git a/SOURCES/0049-automatic-Check-availability-of-config-file.patch b/SOURCES/0049-automatic-Check-availability-of-config-file.patch new file mode 100644 index 0000000..9553662 --- /dev/null +++ b/SOURCES/0049-automatic-Check-availability-of-config-file.patch @@ -0,0 +1,87 @@ +From 201675a56b89d6f3543ce5d734deebe6c4d9049f Mon Sep 17 00:00:00 2001 +From: Marek Blaha +Date: Thu, 17 Oct 2024 13:30:21 +0200 +Subject: [PATCH 49/49] automatic: Check availability of config file + +If a configuration file is explicitly specified on the command line, +ensure that it exists and is readable. If the file is not found, notify +the user immediately and terminate the process. + +This resolves issues where users may run dnf-automatic with unrecognized +positional arguments, such as `dnf-automatic install`. + +The most natural approach to handle a non-existing config file would be +by catching the exception thrown by the `read()` method of the +`libdnf.conf.ConfigParser` class. Unfortunately, the Python bindings +override the `read()` method at the SWIG level, causing it to suppress any +potentially raised IOError. +For details see this section of the commit +https://github.com/rpm-software-management/libdnf/commit/8f1fedf8551b72d6bc24018f5980714b3a103aeb + +def ConfigParser__newRead(self, filenames): + parsedFNames = [] + try: + if isinstance(filenames, str) or isinstance(filenames, unicode): + filenames = [filenames] + except NameError: + pass + for fname in filenames: + try: + self.readFileName(fname) + parsedFNames.append(fname) + except IOError: + pass + except Exception as e: + raise RuntimeError("Parsing file '%s' failed: %s" % (fname, str(e))) + return parsedFNames +ConfigParser.read = ConfigParser__newRead + +Resolves: https://issues.redhat.com/browse/RHEL-46030 +--- + dnf/automatic/main.py | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +diff --git a/dnf/automatic/main.py b/dnf/automatic/main.py +index ccd9ab64..3d73ffce 100644 +--- a/dnf/automatic/main.py ++++ b/dnf/automatic/main.py +@@ -73,7 +73,7 @@ def build_emitters(conf): + + def parse_arguments(args): + parser = argparse.ArgumentParser() +- parser.add_argument('conf_path', nargs='?', default=dnf.const.CONF_AUTOMATIC_FILENAME) ++ parser.add_argument('conf_path', nargs='?') + parser.add_argument('--timer', action='store_true') + parser.add_argument('--installupdates', dest='installupdates', action='store_true') + parser.add_argument('--downloadupdates', dest='downloadupdates', action='store_true') +@@ -88,7 +88,17 @@ def parse_arguments(args): + class AutomaticConfig(object): + def __init__(self, filename=None, downloadupdates=None, + installupdates=None): +- if not filename: ++ if filename: ++ # Specific config file was explicitely requested. Check that it exists ++ # and is readable. ++ if os.access(filename, os.F_OK): ++ if not os.access(filename, os.R_OK): ++ raise dnf.exceptions.Error( ++ "Configuration file \"{}\" is not readable.".format(filename)) ++ else: ++ raise dnf.exceptions.Error( ++ "Configuration file \"{}\" not found.".format(filename)) ++ else: + filename = dnf.const.CONF_AUTOMATIC_FILENAME + self.commands = CommandsConfig() + self.email = EmailConfig() +@@ -295,6 +305,8 @@ def wait_for_network(repos, timeout): + + def main(args): + (opts, parser) = parse_arguments(args) ++ conf = None ++ emitters = None + + try: + conf = AutomaticConfig(opts.conf_path, opts.downloadupdates, +-- +2.48.1 + diff --git a/SOURCES/0050-Fix-missing-import-in-automatic.patch b/SOURCES/0050-Fix-missing-import-in-automatic.patch new file mode 100644 index 0000000..3e6dbf2 --- /dev/null +++ b/SOURCES/0050-Fix-missing-import-in-automatic.patch @@ -0,0 +1,25 @@ +From 75c59dcb38d5672ffcfea9bb4cc999ab30294fe9 Mon Sep 17 00:00:00 2001 +From: Marek Blaha +Date: Wed, 29 Jan 2025 13:29:34 +0100 +Subject: [PATCH] Fix missing import in automatic + +Fixes omitted `import os` in previous commit. +--- + dnf/automatic/main.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/dnf/automatic/main.py b/dnf/automatic/main.py +index 3d73ffce..9d680e9e 100644 +--- a/dnf/automatic/main.py ++++ b/dnf/automatic/main.py +@@ -24,6 +24,7 @@ from __future__ import unicode_literals + + import argparse + import logging ++import os + import random + import socket + import time +-- +2.48.1 + diff --git a/SOURCES/almalinux_bugtracker.patch b/SOURCES/almalinux_bugtracker.patch deleted file mode 100644 index 9aebb2e..0000000 --- a/SOURCES/almalinux_bugtracker.patch +++ /dev/null @@ -1,32 +0,0 @@ -diff -aruN dnf-4.7.0/dnf/const.py.in dnf-4.7.0_alma/dnf/const.py.in ---- dnf-4.7.0/dnf/const.py.in 2021-04-12 18:26:33.000000000 +0300 -+++ dnf-4.7.0_alma/dnf/const.py.in 2021-12-30 10:30:33.806575400 +0300 -@@ -55,4 +55,4 @@ - USER_AGENT = "dnf/%s" % VERSION - - BUGTRACKER_COMPONENT=NAME.lower() --BUGTRACKER='https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=%s' % BUGTRACKER_COMPONENT -+BUGTRACKER='https://bugs.almalinux.org/' -diff -aruN dnf-4.7.0/doc/conf.py.in dnf-4.7.0_alma/doc/conf.py.in ---- dnf-4.7.0/doc/conf.py.in 2021-04-12 18:26:33.000000000 +0300 -+++ dnf-4.7.0_alma/doc/conf.py.in 2021-12-30 10:34:07.810855800 +0300 -@@ -267,5 +267,5 @@ - .. _DNF: https://github.com/rpm-software-management/dnf/ - .. _hawkey: http://rpm-software-management.github.io/hawkey/ - .. _YUM: http://yum.baseurl.org/ --.. _bugzilla: https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=dnf -+.. _bugzilla: https://bugs.almalinux.org/ - """ -diff -aruN dnf-4.7.0/tests/test_config.py dnf-4.7.0_alma/tests/test_config.py ---- dnf-4.7.0/tests/test_config.py 2021-04-12 18:26:33.000000000 +0300 -+++ dnf-4.7.0_alma/tests/test_config.py 2021-12-30 10:33:24.147815500 +0300 -@@ -55,8 +55,7 @@ - def test_bugtracker(self): - conf = Conf() - self.assertEqual(conf.bugtracker_url, -- "https://bugzilla.redhat.com/enter_bug.cgi" + -- "?product=Fedora&component=dnf") -+ "https://bugs.almalinux.org/") - - def test_conf_from_file(self): - conf = Conf() diff --git a/SPECS/dnf.spec b/SPECS/dnf.spec index 7f50402..4cffac6 100644 --- a/SPECS/dnf.spec +++ b/SPECS/dnf.spec @@ -66,7 +66,7 @@ It supports RPMs, modules and comps groups & environments. Name: dnf Version: 4.7.0 -Release: 20%{?dist}.alma +Release: 21%{?dist} Summary: %{pkg_summary} # For a breakdown of the licensing, see PACKAGE-LICENSING License: GPLv2+ @@ -123,11 +123,11 @@ Patch0044: 0044-Document-symbols-in-dnf-history-list-output.patch Patch0045: 0045-RHEL-1245-Remove-usrbin-from-syspath-noimpor-garbage.patch Patch0046: 0046-RHEL-6393-Fix-japanese-translations.patch Patch0047: 0047-RHEL-11786-Fix-substitution-in-kvp-in-add_new_repo.patch +Patch0048: 0048-smtplib-catch-OSError-not-SMTPException.patch +Patch0049: 0049-automatic-Check-availability-of-config-file.patch +Patch0050: 0050-Fix-missing-import-in-automatic.patch -#Almalinux patches -Patch10000: almalinux_bugtracker.patch - BuildArch: noarch BuildRequires: cmake BuildRequires: gettext @@ -426,15 +426,18 @@ popd %{python3_sitelib}/%{name}/automatic/ %changelog -* Wed Mar 27 2024 Eduard Abdullin - 4.7.0-20.alma -- AlmaLinux changes +* Wed Jan 29 2025 Marek Blaha - 4.7.0-21 +- automatic: catch OSError, not SMTPException on smtp errors (RHEL-71545) +- automatic: Check availability of config file (RHEL-71545) * Mon Oct 16 2023 Jaroslav Rohel - 4.7.0-20 - Remove /usr/bin from sys.path to avoid accidentally importing garbage (RHEL-1245) - Fix japanese translations (RHEL-6393) - Fix substitution in kay-value-pair list in add_new_repo (RHEL-11786) + * Wed Jun 28 2023 Jaroslav Rohel - 4.7.0-19 - Document symbols in `dnf history list` output (RhBug:2172067) + * Wed May 31 2023 Nicola Sella - 4.7.0-18 - Return an error when transaction fails (RhBug:2170093) @@ -448,6 +451,7 @@ popd * Thu Jan 05 2023 Nicola Sella - 4.7.0-15 - Ignore processing variable files with unsupported encoding (RhBug:2141215) - Better explain traceback of rpm.error with dnf + * Wed Nov 30 2022 Nicola Sella - 4.7.0-14 - Document changes to offline-upgrade command (RhBug:1939975,2139324)