Bug 2298385 - dnf5 automatic sends emails when no updates installed
Summary: dnf5 automatic sends emails when no updates installed
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf5
Version: 40
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Petr Pisar
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-07-17 02:27 UTC by Steven Haigh
Modified: 2024-08-11 04:48 UTC (History)
6 users (show)

Fixed In Version: dnf5-5.2.5.0-2.fc41 dnf5-5.1.17-2.fc39 dnf5-5.1.17-2.fc40
Clone Of:
Environment:
Last Closed: 2024-08-11 03:29:52 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github rpm-software-management dnf5 pull 1604 0 None open Fix a use-after-free in EmitterEmail::notify() 2024-08-01 14:08:52 UTC

Description Steven Haigh 2024-07-17 02:27:56 UTC
Configured DNF with the following:

# cat /etc/dnf/dnf5-plugins/automatic.conf 
[commands]
apply_updates = yes
reboot = when-needed

[emitters]
emit_via = email

[email]
email_to = sample

When no updates are installed, a blank email is still sent. No Subject or From lines or body is present in the email.

Reproducible: Always

Comment 1 Steven Haigh 2024-07-19 01:54:50 UTC
It also seems that when dnf5-automatic actually does something, the emails that come through are just garbage... ie:

€€€€€€€€1€€€€€€€€;	­ËU€€ ÿ¬ËU€€øã;½ü€€øã;½ü€€

Another example just contains:

├░гdААА1АААААААрN;JVАА № ;JVААААV%АААe>АА

A third example:

€€€€€€€€1€€€€€€€@kÿÒ—€€ ÿL[óU€€€€€€€€pØD[óU€€

There is still no subject or anything useful set in the email.

Comment 2 Petr Pisar 2024-08-01 11:12:17 UTC
I confirm the automatic behaves oddly. For me it crashed for the first time in __memcpy_avx_unaligned_erms():

#0  0x00007ff7fb955184 __memcpy_avx_unaligned_erms (libc.so.6 + 0x147184)
#1  0x00007ff7fb873bd4 fmemopen_read (libc.so.6 + 0x65bd4)
#2  0x00007ff7fb875813 _IO_file_underflow@@GLIBC_2.2.5 (libc.so.6 + 0x67813)
#3  0x00007ff7fb877e45 _IO_default_xsgetn (libc.so.6 + 0x69e45)
#4  0x00007ff7fb869a40 _IO_fread (libc.so.6 + 0x5ba40)
#5  0x00007ff7faceb1f7 cr_in_read (libcurl.so.4 + 0x541f7)
#6  0x00007ff7facf8608 cr_eob_read (libcurl.so.4 + 0x61608)
#7  0x00007ff7facf0f20 Curl_client_read (libcurl.so.4 + 0x59f20)
#8  0x00007ff7facf103d Curl_req_send_more (libcurl.so.4 + 0x5a03d)
#9  0x00007ff7fad068da Curl_readwrite (libcurl.so.4 + 0x6f8da)
#10 0x00007ff7face6258 multi_runsingle.lto_priv.0 (libcurl.so.4 + 0x4f258)
#11 0x00007ff7face8c64 curl_multi_perform (libcurl.so.4 + 0x51c64)
#12 0x00007ff7facbb8a3 curl_easy_perform (libcurl.so.4 + 0x248a3)
#13 0x00007ff7f9ee30ad _ZN4dnf512EmitterEmail6notifyEv (automatic_cmd_plugin.so + 0x170ad)
#14 0x00007ff7f9ed61f5 _ZN4dnf516AutomaticCommand3runEv (automatic_cmd_plugin.so + 0xa1f5)
#15 0x0000557b633d5f78 main (dnf5 + 0x39f78)
#16 0x00007ff7fb811248 __libc_start_call_main (libc.so.6 + 0x3248)
#17 0x00007ff7fb81130b __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x330b)
#18 0x0000557b633d88e5 _start (dnf5 + 0x3c8e5)


Since then it always sends an empty e-mail. It does not matter whether it updates a package or not.

Comment 3 Petr Pisar 2024-08-01 12:20:50 UTC
I think I found the bug. EmitterEmail::notify() in dnf5-plugins/automatic_plugin/emitters.cpp invalidates a FILE * pointer before curl_easy_perform() can use it:

                FILE * payload_file = fmemopen(payload.data(), payload.size(), "r");
                curl_easy_setopt(curl, CURLOPT_READDATA, payload_file);
→               fclose(payload_file);

                curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);

                res = curl_easy_perform(curl);

Actually the whole notify() function is absolutely terrible because it almost never checks for errors.

Comment 4 Petr Pisar 2024-08-01 14:06:55 UTC
Sending e-mails when no update is available is intended behavior:

Subject: [fedora-41] dnf5-automatic: No new upgrades available.
X-Mailer: dnf5-automatic
Message-Id: <20240801140158.A0AB951>

Updating and loading repositories:
Repositories loaded.

Resolved transaction:


A side effect of the bug was that the subject was also missing. I will fix the bug.

Comment 5 Fedora Update System 2024-08-02 11:06:28 UTC
FEDORA-2024-f137952d9f (dnf5-5.1.17-2.fc40) has been submitted as an update to Fedora 40.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-f137952d9f

Comment 6 Fedora Update System 2024-08-02 11:06:37 UTC
FEDORA-2024-2ce9a2a74e (dnf5-5.1.17-2.fc39) has been submitted as an update to Fedora 39.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-2ce9a2a74e

Comment 7 Steven Haigh 2024-08-02 14:31:56 UTC
Thanks for taking a look at this.

I've updated my systems that have dnf5 by default. I can see that there's a couple of updates left to install automatically (curl) - so I'll leave that run and confirm that I get an email with some information - as well as a run where (in theory), if there's nothing to update, I shouldn't get an email.

If you don't hear back from me, then assume all is good.

Comment 8 Fedora Update System 2024-08-03 02:20:28 UTC
FEDORA-2024-f137952d9f has been pushed to the Fedora 40 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-f137952d9f`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-f137952d9f

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 9 Fedora Update System 2024-08-03 02:33:01 UTC
FEDORA-2024-2ce9a2a74e has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-2ce9a2a74e`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-2ce9a2a74e

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 10 Fedora Update System 2024-08-11 03:29:52 UTC
FEDORA-2024-2ce9a2a74e (dnf5-5.1.17-2.fc39) has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 11 Fedora Update System 2024-08-11 04:48:45 UTC
FEDORA-2024-f137952d9f (dnf5-5.1.17-2.fc40) has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.