diff --git a/backport-0007-sysctl-return-error-on-permission-denied.patch b/backport-0007-sysctl-return-error-on-permission-denied.patch new file mode 100644 index 0000000000000000000000000000000000000000..e9d68048c2a39303d989e5df9e64d3f3163fbb3a --- /dev/null +++ b/backport-0007-sysctl-return-error-on-permission-denied.patch @@ -0,0 +1,48 @@ +From cd3a440b562e6efc713ce1524678dd068a85bf91 Mon Sep 17 00:00:00 2001 +From: Matteo Croce +Date: Fri, 7 Jun 2024 00:29:32 +0200 +Subject: [PATCH] sysctl: return error on permission denied + +When trying to write to a readonly sysctl or a directory by mistake, +sysctl still returns success: + + # sysctl kernel.version=foo + sysctl: setting key "kernel.version": Operation not permitted + # echo $? + 0 + # sysctl kernel=foo + sysctl: setting key "kernel": Operation not permitted + # echo $? + 0 + +Let sysctl return error in both the cases above. + +Signed-off-by: Matteo Croce +--- + src/sysctl.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/sysctl.c b/src/sysctl.c +index 087ddab..1914203 100644 +--- a/src/sysctl.c ++++ b/src/sysctl.c +@@ -585,14 +585,14 @@ static int WriteSetting( + errno = EPERM; + xwarn(_("setting key \"%s\""), dotted_key); + free(dotted_key); +- return rc; ++ return EXIT_FAILURE; + } + + if (S_ISDIR(ts.st_mode)) { + errno = EISDIR; + xwarn(_("setting key \"%s\""), dotted_key); + free(dotted_key); +- return rc; ++ return EXIT_FAILURE; + } + + if (!DryRun) { +-- +2.43.0 + diff --git a/procps-ng.spec b/procps-ng.spec index 88913cfed3b5ca94d6ff275861588dfe65d561e2..70e71d10b9f48eeb663681bd0a8401e61ecbc39c 100644 --- a/procps-ng.spec +++ b/procps-ng.spec @@ -1,6 +1,6 @@ Name: procps-ng Version: 4.0.5 -Release: 4 +Release: 5 Summary: Utilities that provide system information. License: GPL-2.0-or-later AND LGPL-2.0-or-later AND LGPL-2.1-or-later URL: https://sourceforge.net/projects/procps-ng/ @@ -18,6 +18,7 @@ Patch6: backport-0003-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.p Patch7: backport-0004-library-internal-expand-buffer-for-stat-fd.patch Patch8: backport-0005-library-address-a-potential-race-resulting-in-a-fault.patch Patch9: backport-0006-library-avoid-strdup-calls-in-sd2proc-if-possible.patch +Patch10: backport-0007-sysctl-return-error-on-permission-denied.patch BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel @@ -95,6 +96,9 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof %{_mandir}/man?/* %changelog +* Mon Nov 3 2025 liuh - 4.0.5-5 +- sysctl: return error on permission denied + * Thu Aug 28 2025 Zhu Jin - 4.0.5-4 - library: address a potential race resulting in a fault and avoid strdup() calls in sd2proc() if possible