File procps-3.2.8-read-sysctls-also-from-boot-sysctl.conf-kernelversion.diff of Package procps

From 0d9241b9af6ad3533477b11583c3e866cc2e6fd3 Mon Sep 17 00:00:00 2001
From: Ludwig Nussel <ludwig.nussel@suse.de>
Date: Tue, 17 May 2011 16:35:18 +0200
Subject: [PATCH 3/3] read sysctls also from /boot/sysctl.conf-$kernelversion

---
 sysctl.8 |    2 +-
 sysctl.c |   12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/sysctl.8 b/sysctl.8
index 406bb59..03a8980 100644
--- a/sysctl.8
+++ b/sysctl.8
@@ -66,7 +66,7 @@ Display all values currently available.
 Display all values currently available in table form.
 .TP
 .B "--system"
-Load settings from system configuration files (/lib/sysctl.d/*.conf,
+Load settings from system configuration files (/boot/sysctl.conf-<kernelversion>, /lib/sysctl.d/*.conf,
 /usr/lib/sysctl.d/*.conf, /usr/local/lib/sysctl.d/*.conf,
 /etc/sysctl.d/*.conf, /run/sysctl.d/*.conf, /etc/sysctl.conf)
 .TP
diff --git a/sysctl.c b/sysctl.c
index 1867777..a38a81c 100644
--- a/sysctl.c
+++ b/sysctl.c
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/utsname.h>
 #include <dirent.h>
 #include <string.h>
 #include <errno.h>
@@ -510,6 +511,7 @@ static int sortpairs(const void* A, const void* B)
 
 static int PreloadSystem(void) {
    unsigned di, i;
+   struct utsname uts;
    const char* dirs[] = {
       "/run/sysctl.d",
       "/etc/sysctl.d",
@@ -556,6 +558,16 @@ static int PreloadSystem(void) {
 
    qsort(cfgs, ncfgs, sizeof(struct cfg*), sortpairs);
 
+   if (uname(&uts) == 0) {
+      char buf[PATH_MAX];
+      snprintf(buf, sizeof(buf), "/boot/sysctl.conf-%s", uts.release);
+      if (access(buf, R_OK) == 0) {
+	 if (!Quiet)
+	    printf("* Applying %s ...\n", buf);
+	 Preload(buf);
+      }
+   }
+
    for (i = 0; i < ncfgs; ++i) {
       if (!Quiet)
 	 printf("* Applying %s ...\n", cfgs[i]->value);
-- 
1.7.3.4

openSUSE Build Service is sponsored by