sysctl: returns success even on fail bug

Resolves: RHEL-84138
This commit is contained in:
Jan Rybar 2025-12-04 14:21:54 +01:00
parent 0af78bba10
commit d83883f655
2 changed files with 54 additions and 1 deletions

View File

@ -4,7 +4,7 @@
Summary: System and process monitoring utilities
Name: procps-ng
Version: 4.0.4
Release: 9%{?dist}
Release: 10%{?dist}
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/
@ -13,6 +13,7 @@ Source0: https://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz
Patch1: osh-findings.patch
Patch2: top-fix-guest-tics.patch
Patch3: free-manpage-overcommit-note.patch
Patch4: sysctl-succ-on-fail.patch
BuildRequires: make
BuildRequires: ncurses-devel
@ -149,6 +150,10 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
%files i18n -f %{name}.lang
%changelog
* Thu Dec 04 2025 Jan Rybar <jrybar@redhat.com> - 4.0.4-10
- sysctl: returns success even on fail bug
- Resolves: RHEL-84138
* Wed Oct 29 2025 Jan Rybar <jrybar@redhat.com> - 4.0.4-9
- free manpage: expand note on negative value with overcommit
- Resolves: RHEL-100973

48
sysctl-succ-on-fail.patch Normal file
View File

@ -0,0 +1,48 @@
From cd3a440b562e6efc713ce1524678dd068a85bf91 Mon Sep 17 00:00:00 2001
From: Matteo Croce <teknoraver@meta.com>
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 <teknoraver@meta.com>
---
src/sysctl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/sysctl.c b/src/sysctl.c
index 087ddabe..1914203c 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) {
--
GitLab