summaryrefslogtreecommitdiff
path: root/sysctl.c
diff options
context:
space:
mode:
authorSami Kerola <kerolasa@iki.fi>2012-02-13 21:21:43 +0100
committerSami Kerola <kerolasa@iki.fi>2012-02-14 11:22:15 +0100
commite01765d30b7c4767868d5379fbfb36d1dc15eba4 (patch)
tree8d09762ad21f2bc4e45853fab1a2dbd8691b8cd6 /sysctl.c
parent96ba57b5687f2163674ff2da3272de1231f85662 (diff)
downloadprocps-ng-e01765d30b7c4767868d5379fbfb36d1dc15eba4.tar.gz
sysctl: deprecate parameters
According to arp(7) manual page base_reachable_time and retrans_time are obsolete since kernel 2.6.12. Based on that the print all listing will not show these two parameters, and attempt to set them will fail. Reported-by: Alexandre Cavalcante Alencar <alexandre.alencar@gmail.com> Bug-Debian: http://bugs.debian.org/599556 Reference: http://www.mail-archive.com/bk-commits-head@vger.kernel.org/msg03396.html Reference: http://www.opensubscriber.com/message/linux-kernel@vger.kernel.org/7344177.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sysctl.c')
-rw-r--r--sysctl.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/sysctl.c b/sysctl.c
index eb57058..c27fe02 100644
--- a/sysctl.c
+++ b/sysctl.c
@@ -47,6 +47,12 @@ static bool false = 0;
*/
static const char PROC_PATH[] = "/proc/sys/";
static const char DEFAULT_PRELOAD[] = "/etc/sysctl.conf";
+static const char *DEPRECATED[] = {
+ "base_reachable_time",
+ "retrans_time",
+ ""
+};
+static bool IgnoreDeprecated;
static bool NameOnly;
static bool PrintName;
static bool PrintNewline;
@@ -96,6 +102,7 @@ static void __attribute__ ((__noreturn__))
fputs(_(" -a, --all display all variables\n"
" -A alias of -a\n"
" -X alias of -a\n"
+ " --deprecated include deprecated parameters to listing\n"
" -b, --binary print value without new line\n"
" -e, --ignore ignore unknown variables errors\n"
" -N, --names print variable names without values\n"
@@ -275,6 +282,16 @@ static int ReadSetting(const char *restrict const name)
return rc;
}
+int is_deprecated(char *filename)
+{
+ int i;
+ for (i = 0; strlen(DEPRECATED[i]); i++) {
+ if (strcmp(DEPRECATED[i], filename) == 0)
+ return 1;
+ }
+ return 0;
+}
+
/*
* Display all the sysctl settings
*/
@@ -296,6 +313,8 @@ static int DisplayAll(const char *restrict const path)
readdir(dp); /* skip .. */
while ((de = readdir(dp))) {
char *restrict tmpdir;
+ if (IgnoreDeprecated && is_deprecated(de->d_name))
+ continue;
tmpdir =
(char *restrict) xmalloc(strlen(path) +
strlen(de->d_name) +
@@ -369,6 +388,10 @@ static int WriteSetting(const char *setting)
outname[equals - name] = 0;
/* change / to . */
slashdot(outname, '/', '.');
+ if(is_deprecated(strrchr(outname, '.') + 1)) {
+ xwarnx(_("%s is deprecated, value not set"), outname);
+ goto out;
+ }
if (stat(tmpname, &ts) < 0) {
if (!IgnoreError) {
@@ -618,10 +641,12 @@ int main(int argc, char *argv[])
const char *preloadfile = DEFAULT_PRELOAD;
enum {
- SYSTEM_OPTION = CHAR_MAX + 1
+ DEPRECATED_OPTION = CHAR_MAX + 1,
+ SYSTEM_OPTION
};
static const struct option longopts[] = {
{"all", no_argument, NULL, 'a'},
+ {"deprecated", no_argument, NULL, DEPRECATED_OPTION},
{"binary", no_argument, NULL, 'b'},
{"ignore", no_argument, NULL, 'e'},
{"names", no_argument, NULL, 'N'},
@@ -645,6 +670,7 @@ int main(int argc, char *argv[])
PrintNewline = true;
IgnoreError = false;
Quiet = false;
+ IgnoreDeprecated = true;
if (argc < 2)
Usage(stderr);
@@ -693,6 +719,9 @@ int main(int argc, char *argv[])
case 'X': /* same as -a -x */
DisplayAllOpt = true;
break;
+ case DEPRECATED_OPTION:
+ IgnoreDeprecated = false;
+ break;
case SYSTEM_OPTION:
IgnoreError = true;
return PreloadSystem();