Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base/comps/PackageKit/PackageKit.comp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[components.PackageKit]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
From f941b31cf19ef3614379e78cc6393abecc1ae654 Mon Sep 17 00:00:00 2001
From: Tomasz Bojanowski <tomasz@bojanowski.me>
Date: Wed, 25 Nov 2026 21:37:30 +0100
Subject: [PATCH] command-not-found: Don't recurse when gettext is not in PATH

The non-interactive fallback in command_not_found_handle runs
"$(gettext PackageKit 'command not found')". If gettext cannot be found
in PATH, that lookup calls the handler again from the command
substitution, which takes the same branch and forks again, with nothing
to stop it. A single missing command in a non-interactive bash is then
enough to exhaust memory.

Only call gettext if "type -P" finds an executable in PATH, and print
the untranslated message otherwise. "type -P" does not go through the
handler and, unlike "command -v", ignores aliases.

Fixes: https://github.com/PackageKit/PackageKit/issues/1000
Fixes: https://github.com/PackageKit/PackageKit/issues/1026
---
contrib/command-not-found/PackageKit.sh.in | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/contrib/command-not-found/PackageKit.sh.in b/contrib/command-not-found/PackageKit.sh.in
index ed0391f89..49d26f409 100644
--- a/contrib/command-not-found/PackageKit.sh.in
+++ b/contrib/command-not-found/PackageKit.sh.in
@@ -30,7 +30,14 @@ command_not_found_handle () {
'@LIBEXECDIR@/pk-command-not-found' "$@"
retval=$?
elif [[ -n "${BASH_VERSION-}" ]]; then
- printf >&2 'bash: %s%s\n' "${1:+$1: }" "$(gettext PackageKit 'command not found')"
+ # gettext may be missing from PATH; running it then would
+ # re-enter this function from the command substitution, forever.
+ # type -P, because command -v also reports aliases
+ if type -P gettext >/dev/null 2>&1; then
+ printf >&2 'bash: %s%s\n' "${1:+$1: }" "$(gettext PackageKit 'command not found')"
+ else
+ printf >&2 'bash: %s%s\n' "${1:+$1: }" 'command not found'
+ fi
fi

# return success or failure
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[metadata]
category = "upstream-backport"
upstream-status = "upstreamable"
commits = [{ url = "https://github.com/PackageKit/PackageKit/pull/1052/commits/f941b31cf19ef3614379e78cc6393abecc1ae654" }]
bugs = [
{ url = "https://github.com/PackageKit/PackageKit/issues/1000" },
{ url = "https://github.com/PackageKit/PackageKit/issues/1026" },
{ url = "https://github.com/PackageKit/PackageKit/pull/1052" },
]

# The non-interactive fallback in /etc/profile.d/PackageKit.sh prints its
# message with "$(gettext ...)". When gettext is not in PATH, that lookup
# re-enters command_not_found_handle and forks without bound, so a single
# missing command in a non-interactive login shell exhausts the system.
[[overlays]]
description = "Add the upstream patch that stops command_not_found_handle recursing without gettext"
type = "file-add"
file = "command-not-found-dont-recurse-without-gettext.patch"
source = "../command-not-found-dont-recurse-without-gettext.patch"

# patch-add would pick the next free number (3002), which falls in the
# RHEL-only %autopatch range and is skipped on Azure Linux. Use the spec's
# "proposed upstream" range so the unconditional %autopatch -M 2000 applies it.
[[overlays]]
description = "Register the command-not-found recursion fix as Patch0502"
type = "spec-insert-tag"
tag = "Patch0502"
value = "command-not-found-dont-recurse-without-gettext.patch"
1 change: 0 additions & 1 deletion base/comps/components.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ overlay-files = ["overlays/*.overlay.toml"]
[components.OpenCL-ICD-Loader]
[components.OpenIPMI]
[components.PEGTL]
[components.PackageKit]
[components.PackageKit-Qt]
[components.PyQt-builder]
[components.PyQt4]
Expand Down
2 changes: 1 addition & 1 deletion locks/PackageKit.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ version = 1
import-commit = 'e8defa2673a997877478e081f99f2075618a1032'
upstream-commit = 'c277ece8b8436351dae8cebe077dc68d61b3f46a'
manual-bump = 2
input-fingerprint = 'sha256:17b64b48b2f4fb3776288a9e29985a714591e1a3927785944a171adcf1d9990a'
input-fingerprint = 'sha256:9e466c48685e49aa4e5babffeb3c5c7541af441279c3e77cbcb3d06fb27abd62'
resolution-input-hash = 'sha256:ee2b4b2a7474232699f7ef1461160019159849dcc0daf2dcff1aabf35416ecec'
6 changes: 5 additions & 1 deletion specs/p/PackageKit/PackageKit.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## (rpmautospec version 0.8.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
release_number = 2;
release_number = 3;
base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
Expand Down Expand Up @@ -44,6 +44,7 @@ Patch2001: PackageKit-0.3.8-Fedora-Vendor.conf.patch

## RHEL patches (3001~4000)
Patch3001: PackageKit-0.3.8-RHEL-Vendor.conf.patch
Patch0502: command-not-found-dont-recurse-without-gettext.patch

BuildRequires: docbook-utils
BuildRequires: docbook5-schemas
Expand Down Expand Up @@ -398,6 +399,9 @@ systemctl disable packagekit-offline-update.service > /dev/null 2>&1 || :

%changelog
## START: Generated by rpmautospec
* Tue Dec 01 2026 Muhammad Falak R Wani <falakreyaz@gmail.com> - 1.3.6-3
- fix(PackageKit): stop command-not-found recursing without gettext

* Mon Oct 05 2026 Dan Streetman <ddstreet@ieee.org> - 1.3.6-2
- chore: update 'lock' files and render changed components

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
From f941b31cf19ef3614379e78cc6393abecc1ae654 Mon Sep 17 00:00:00 2001
From: Tomasz Bojanowski <tomasz@bojanowski.me>
Date: Wed, 25 Nov 2026 21:37:30 +0100
Subject: [PATCH] command-not-found: Don't recurse when gettext is not in PATH

The non-interactive fallback in command_not_found_handle runs
"$(gettext PackageKit 'command not found')". If gettext cannot be found
in PATH, that lookup calls the handler again from the command
substitution, which takes the same branch and forks again, with nothing
to stop it. A single missing command in a non-interactive bash is then
enough to exhaust memory.

Only call gettext if "type -P" finds an executable in PATH, and print
the untranslated message otherwise. "type -P" does not go through the
handler and, unlike "command -v", ignores aliases.

Fixes: https://github.com/PackageKit/PackageKit/issues/1000
Fixes: https://github.com/PackageKit/PackageKit/issues/1026
---
contrib/command-not-found/PackageKit.sh.in | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/contrib/command-not-found/PackageKit.sh.in b/contrib/command-not-found/PackageKit.sh.in
index ed0391f89..49d26f409 100644
--- a/contrib/command-not-found/PackageKit.sh.in
+++ b/contrib/command-not-found/PackageKit.sh.in
@@ -30,7 +30,14 @@ command_not_found_handle () {
'@LIBEXECDIR@/pk-command-not-found' "$@"
retval=$?
elif [[ -n "${BASH_VERSION-}" ]]; then
- printf >&2 'bash: %s%s\n' "${1:+$1: }" "$(gettext PackageKit 'command not found')"
+ # gettext may be missing from PATH; running it then would
+ # re-enter this function from the command substitution, forever.
+ # type -P, because command -v also reports aliases
+ if type -P gettext >/dev/null 2>&1; then
+ printf >&2 'bash: %s%s\n' "${1:+$1: }" "$(gettext PackageKit 'command not found')"
+ else
+ printf >&2 'bash: %s%s\n' "${1:+$1: }" 'command not found'
+ fi
fi

# return success or failure