diff --git a/0037-automatic-Expand-email_to-in-command_email-emitter-t.patch b/0037-automatic-Expand-email_to-in-command_email-emitter-t.patch new file mode 100644 index 0000000..e6fa92b --- /dev/null +++ b/0037-automatic-Expand-email_to-in-command_email-emitter-t.patch @@ -0,0 +1,98 @@ +From a73cc59429846abe44b19f92dc1d05ebdcab4c7b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Thu, 19 Jun 2025 13:09:35 +0200 +Subject: [PATCH] automatic: Expand email_to in command_email emitter to + individual arguments + +Upstream commit: aa1ba2d1566198127518d0ccb38eaf5481b4649e + +If /etc/dnf/automatic.conf has: + + [emitters] + emit_via = command_email + [command_email] + email_to = root,test + +a command incompatible with s-nail-14.9.25, a "mail" command +implementation, was executed: + + execve("/usr/bin/mail", ["mail", "-Ssendwait", "-s", "Updates available on 'fedora-43'.", "-r", "root", "root test"], ...) = 0 + +The cause was that s-nail does not support multiple recipients in +a single argument. + +This patch changes how "{email_to}" expands in command_format +formatting string. Now it expands into multiple, space separated arguments. +The new syntax is also accepted by mailx tool. + +Implementation detail: A list of email_to recipients passed in +CommandEmitterMixIn does not inherit from "list" Python class or any +other iterator. It's libdnf.module.VectorString class generated by +Swig without. There the custom ShellQuotedLists formatting dictionary +needs to refer to libdnf.module.VectorString type and include "libdnf" +Python module explicitly. + +A test will be added to ci-dnf-stack repository. + +Resolve: #2241 +Resolve: https://issues.redhat.com/browse/RHEL-94331 +--- + dnf/automatic/emitter.py | 21 +++++++++++++++++---- + 1 file changed, 17 insertions(+), 4 deletions(-) + +diff --git a/dnf/automatic/emitter.py b/dnf/automatic/emitter.py +index 1c8ff6bf8..ee1954296 100644 +--- a/dnf/automatic/emitter.py ++++ b/dnf/automatic/emitter.py +@@ -22,6 +22,7 @@ from __future__ import absolute_import + from __future__ import print_function + from __future__ import unicode_literals + from dnf.i18n import _ ++import libdnf + import logging + import dnf.pycomp + import smtplib +@@ -132,6 +133,20 @@ class EmailEmitter(Emitter): + logger.error(msg) + + ++class ShellQuotedLists(dict): ++ """ ++ Dictionary which returns values quoted with dnf.pycomp.shlex_quote(). ++ If a looked-up value is a list or libdnf.module.VectorString, it will ++ quote the list members and then concatenate them with a space and return ++ the resulting string. ++ """ ++ def __getitem__(self, key): ++ value = super(ShellQuotedLists, self).__getitem__(key) ++ if isinstance(value, (list, libdnf.module.VectorString)): ++ return ' '.join(dnf.pycomp.shlex_quote(item) for item in value) ++ else: ++ return dnf.pycomp.shlex_quote(value) ++ + class CommandEmitterMixIn(object): + """ + Executes a desired command, and pushes data into its stdin. +@@ -147,9 +162,7 @@ class CommandEmitterMixIn(object): + msg = self._prepare_msg() + # all strings passed to shell should be quoted to avoid accidental code + # execution +- quoted_msg = dict((key, dnf.pycomp.shlex_quote(val)) +- for key, val in msg.items()) +- command = command_fmt.format(**quoted_msg) ++ command = command_fmt.format_map(ShellQuotedLists(msg)) + stdin_feed = stdin_fmt.format(**msg).encode('utf-8') + + # Execute the command +@@ -177,7 +190,7 @@ class CommandEmailEmitter(CommandEmitterMixIn, EmailEmitter): + return {'subject': subject, + 'body': body, + 'email_from': self._conf.email_from, +- 'email_to': ' '.join(self._conf.email_to)} ++ 'email_to': self._conf.email_to} + + + class StdIoEmitter(Emitter): +-- +2.52.0 + diff --git a/dnf.spec b/dnf.spec index ff10a37..59e31f6 100644 --- a/dnf.spec +++ b/dnf.spec @@ -72,7 +72,7 @@ It supports RPMs, modules and comps groups & environments. Name: dnf Version: 4.20.0 -Release: 18%{?dist}.alma.1 +Release: 19%{?dist}.alma.1 Summary: %{pkg_summary} # For a breakdown of the licensing, see PACKAGE-LICENSING License: GPL-2.0-or-later AND GPL-1.0-only @@ -114,6 +114,7 @@ Patch33: 0033-Obsolete-RHEL-9-only-multisig-DNF-plugin.patch Patch34: 0034-Add-deprecation-warning-for-module-commands.patch Patch35: 0035-Add-modularity-deprecation-warning-to-doc-pages.patch Patch36: 0036-automatic-Fix-detecting-releasever_minor.patch +Patch37: 0037-automatic-Expand-email_to-in-command_email-emitter-t.patch # AlmaLinux Patch Patch1001: 0001-Add-link-to-AlmaLinux-bugtracker.patch @@ -479,10 +480,14 @@ popd # bootc subpackage does not include any files %changelog -* Fri Aug 01 2025 Eduard Abdullin - 4.20.0-18.alma.1 +* Fri Jan 16 2026 Eduard Abdullin - 4.20.0-19.alma.1 - Add x86_64_v2 to _BASEARCH_MAP - Add link to AlmaLinux bugtracker +* Fri Jan 09 2026 Petr Pisar - 4.20.0-19 +- automatic: Expand email_to in command_email emitter to individual arguments + (RHEL-94331) + * Tue Jul 29 2025 Petr Pisar - 4.20.0-18 - Fix detecting releasever_minor in dnf-automatic (RHEL-106141)