| 1 |
Description: sysctl: Add verboten keys |
| 2 |
sysctl --all goes through the entire /proc/sys tree. For the majority |
| 3 |
of parameters, reading the virtual file does nothing except print a |
| 4 |
value. |
| 5 |
. |
| 6 |
However stat_refresh gives no output but flushes the vm data. |
| 7 |
sysctl now has a verboten list which is a list of parameters that |
| 8 |
should never be read with --all. |
| 9 |
Author: Craig Small <[email protected]> |
| 10 |
Origin: upstream, https://gitlab.com/procps-ng/procps/-/commit/276253f09245498008212303935675354856fd37 |
| 11 |
Bug-Debian: https://bugs.debian.org/978688 |
| 12 |
Applied-Upstream: 4.0.5 |
| 13 |
Last-Update: 2025-04-14 |
| 14 |
--- |
| 15 |
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ |
| 16 |
--- a/src/sysctl.c |
| 17 |
+++ b/src/sysctl.c |
| 18 |
@@ -1,7 +1,7 @@ |
| 19 |
/* |
| 20 |
* Sysctl - A utility to read and manipulate the sysctl parameters |
| 21 |
* |
| 22 |
- * Copyright © 2009-2023 Craig Small <[email protected]> |
| 23 |
+ * Copyright © 2009-2024 Craig Small <[email protected]> |
| 24 |
* Copyright © 2012-2023 Jim Warner <[email protected]> |
| 25 |
* Copyright © 2017-2018 Werner Fink <[email protected]> |
| 26 |
* Copyright © 2014 Jaromir Capik <[email protected]> |
| 27 |
@@ -64,6 +64,12 @@ |
| 28 |
"retrans_time", |
| 29 |
"" |
| 30 |
}; |
| 31 |
+/* Verboten parameters must never be read as they cause side-effects */ |
| 32 |
+static const char *VERBOTEN[] = { |
| 33 |
+ "stat_refresh", |
| 34 |
+ NULL |
| 35 |
+}; |
| 36 |
+ |
| 37 |
static bool IgnoreDeprecated; |
| 38 |
static bool NameOnly; |
| 39 |
static bool PrintName; |
| 40 |
@@ -475,6 +481,16 @@ |
| 41 |
return 0; |
| 42 |
} |
| 43 |
|
| 44 |
+static bool is_verboten(const char *filename) |
| 45 |
+{ |
| 46 |
+ int i; |
| 47 |
+ for (i = 0; VERBOTEN[i]; i++) { |
| 48 |
+ if (strcmp(VERBOTEN[i], filename) == 0) |
| 49 |
+ return TRUE; |
| 50 |
+ } |
| 51 |
+ return FALSE; |
| 52 |
+} |
| 53 |
+ |
| 54 |
/* |
| 55 |
* Display all the sysctl settings |
| 56 |
*/ |
| 57 |
@@ -498,6 +514,8 @@ |
| 58 |
char *restrict tmpdir; |
| 59 |
if (IgnoreDeprecated && is_deprecated(de->d_name)) |
| 60 |
continue; |
| 61 |
+ if (is_verboten(de->d_name)) |
| 62 |
+ continue; |
| 63 |
tmpdir = |
| 64 |
(char *restrict) xmalloc(strlen(path) + |
| 65 |
strlen(de->d_name) + |
| 66 |
--- a/man/sysctl.8 |
| 67 |
+++ b/man/sysctl.8 |
| 68 |
@@ -11,7 +11,7 @@ |
| 69 |
.\" (at your option) any later version. |
| 70 |
.\" |
| 71 |
.\" |
| 72 |
-.TH SYSCTL "8" "2023-08-19" "procps-ng" "System Administration" |
| 73 |
+.TH SYSCTL "8" "2024-07-19" "procps-ng" "System Administration" |
| 74 |
.SH NAME |
| 75 |
sysctl \- configure kernel parameters at runtime |
| 76 |
.SH SYNOPSIS |
| 77 |
@@ -71,7 +71,7 @@ |
| 78 |
The file argument may be specified as regular expression. |
| 79 |
.TP |
| 80 |
\fB\-a\fR, \fB\-\-all\fR |
| 81 |
-Display all values currently available. |
| 82 |
+Display all values currently available except deprecated and verboten parameters. |
| 83 |
.TP |
| 84 |
\fB\-\-deprecated\fR |
| 85 |
Include deprecated parameters to |
| 86 |
@@ -83,8 +83,8 @@ |
| 87 |
.TP |
| 88 |
\fB\-\-system\fR |
| 89 |
Load settings from all system configuration files. See the |
| 90 |
-.B SYSTEM FILE PRECEDENCE |
| 91 |
-section below. |
| 92 |
+.B System file precedence |
| 93 |
+sub-section below. |
| 94 |
.TP |
| 95 |
\fB\-r\fR, \fB\-\-pattern\fR \fIpattern\fR |
| 96 |
Only apply settings that match |
| 97 |
@@ -116,7 +116,19 @@ |
| 98 |
.TP |
| 99 |
\fB\-V\fR, \fB\-\-version\fR |
| 100 |
Display version information and exit. |
| 101 |
-.SH SYSTEM FILE PRECEDENCE |
| 102 |
+.SH FILES |
| 103 |
+.TS |
| 104 |
+Li. |
| 105 |
+/proc/sys |
| 106 |
+/etc/sysctl.d/\fR*\fP.conf |
| 107 |
+/run/sysctl.d/\fR*\fP.conf |
| 108 |
+/usr/local/lib/sysctl.d/\fR*\fP.conf |
| 109 |
+/usr/lib/sysctl.d/\fR*\fP.conf |
| 110 |
+/lib/sysctl.d/\fR*\fP.conf |
| 111 |
+/etc/sysctl.conf |
| 112 |
+.TE |
| 113 |
+.SH NOTES |
| 114 |
+.SS System file precedence |
| 115 |
When using the \fB\-\-system\fR option, |
| 116 |
.B sysctl |
| 117 |
will read files from directories in the following list in given |
| 118 |
@@ -140,23 +152,8 @@ |
| 119 |
replaced (by having a new configuration file with the same name in a |
| 120 |
directory of higher priority) or partially replaced (by having a configuration |
| 121 |
file that is ordered later). |
| 122 |
-.SH EXAMPLES |
| 123 |
-/sbin/sysctl \-a |
| 124 |
-.br |
| 125 |
-/sbin/sysctl \-n kernel.hostname |
| 126 |
-.br |
| 127 |
-/sbin/sysctl \-w kernel.domainname="example.com" |
| 128 |
-.br |
| 129 |
-/sbin/sysctl \-p/etc/sysctl.conf |
| 130 |
-.br |
| 131 |
-/sbin/sysctl \-a \-\-pattern forward |
| 132 |
-.br |
| 133 |
-/sbin/sysctl \-a \-\-pattern forward$ |
| 134 |
-.br |
| 135 |
-/sbin/sysctl \-a \-\-pattern 'net.ipv4.conf.(eth|wlan)0.arp' |
| 136 |
-.br |
| 137 |
-/sbin/sysctl \-\-pattern '\[char94]net.ipv6' \-\-system |
| 138 |
-.SH DEPRECATED PARAMETERS |
| 139 |
+ |
| 140 |
+.SS Deprecated parameters |
| 141 |
The |
| 142 |
.B base_reachable_time |
| 143 |
and |
| 144 |
@@ -168,28 +165,34 @@ |
| 145 |
to \fB/proc\fR file system by other means. For example: |
| 146 |
.PP |
| 147 |
echo 256 > /proc/sys/net/ipv6/neigh/eth0/base_reachable_time |
| 148 |
-.SH FILES |
| 149 |
-.I /proc/sys |
| 150 |
+ |
| 151 |
+.SS Verboten parameters |
| 152 |
+Certain kernel parameters should not be read due to side-effects and will be |
| 153 |
+skipped by \fBsysctl\fR using the \fB\-\-all\fR option. |
| 154 |
+.TP |
| 155 |
+.B stat_refresh |
| 156 |
+This parameter returns no value but flushes per-cpu vm statistics. |
| 157 |
+ |
| 158 |
+.SH EXAMPLES |
| 159 |
+/sbin/sysctl \-a |
| 160 |
.br |
| 161 |
-.I /etc/sysctl.d/*.conf |
| 162 |
+/sbin/sysctl \-n kernel.hostname |
| 163 |
+.br |
| 164 |
+/sbin/sysctl \-w kernel.domainname="example.com" |
| 165 |
.br |
| 166 |
-.I /run/sysctl.d/*.conf |
| 167 |
+/sbin/sysctl \-p/etc/sysctl.conf |
| 168 |
.br |
| 169 |
-.I /usr/local/lib/sysctl.d/*.conf |
| 170 |
+/sbin/sysctl \-a \-\-pattern forward |
| 171 |
.br |
| 172 |
-.I /usr/lib/sysctl.d/*.conf |
| 173 |
+/sbin/sysctl \-a \-\-pattern forward$ |
| 174 |
.br |
| 175 |
-.I /lib/sysctl.d/*.conf |
| 176 |
+/sbin/sysctl \-a \-\-pattern 'net.ipv4.conf.(eth|wlan)0.arp' |
| 177 |
.br |
| 178 |
-.I /etc/sysctl.conf |
| 179 |
+/sbin/sysctl \-\-pattern '\[char94]net.ipv6' \-\-system |
| 180 |
.SH SEE ALSO |
| 181 |
.BR proc (5), |
| 182 |
.BR sysctl.conf (5), |
| 183 |
.BR regex (7) |
| 184 |
-.SH AUTHOR |
| 185 |
-.UR [email protected] |
| 186 |
-George Staikos |
| 187 |
-.UE |
| 188 |
.SH "REPORTING BUGS" |
| 189 |
Please send bug reports to |
| 190 |
.UR [email protected] |