]> granicus.if.org Git - procps-ng/commitdiff
sysctl: Return non-zero if param setting failed
authorJan Rybar <jrybar@redhat.com>
Wed, 15 Sep 2021 11:07:43 +0000 (21:07 +1000)
committerCraig Small <csmall@dropbear.xyz>
Wed, 15 Sep 2021 11:07:43 +0000 (21:07 +1000)
Real usecase:
'sysctl -w user.max_uts_namespaces=2147483648; echo $?'
returns 0 even though it failed with EINVAL

The close_stream() realised there was an issue and printed an
error but didn't change the return value.

Slightly modified merge request.

References:
 procps-ng/procps!76

Signed-off-by: Craig Small <csmall@dropbear.xyz>
NEWS
sysctl.c

diff --git a/NEWS b/NEWS
index be6359bdfa059919e27963fd0e76a11cedfe083e..ee21f717982127cd59b7c858b3e9709724ac3e1b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ procps-ng-NEXT
   * slabtop: Don't combine d and o options                 issue #160
   * sysctl: Add support for systemd glob patterns          issue #191
   * sysctl: Check resolved path to be under /proc/sys      issue #179
+  * sysctl: return non-zero if EINVAL return for write     merge #76
   * top: added LOGID similar to 3.3.13 ps LUID
   * top: added EXE identical to 3.3.17 ps EXE
   * top: exploit some library smaps_rollup provisions      issue #112
index 41806601dcf7f054a682224ac62ef4b835850b29..75636b79e3d4bd63a04dc6600fe05ffebe0294fc 100644 (file)
--- a/sysctl.c
+++ b/sysctl.c
@@ -586,7 +586,7 @@ static int WriteSetting(
                rc = EXIT_SUCCESS;
             if (close_stream(fp) != 0) {
                 xwarn(_("setting key \"%s\""), path);
-                return rc;
+                return EXIT_FAILURE;
             }
         }
     }