a082bb1e4a
- load sysctls earlier (bnc#664550) - move distro defaults to /lib/sysctl.d to avoid .rpmnew files - enable IPv6 privacy by default (bnc#678066) I've sent the --system and --pattern path upstream but they weren't accepted yet. So this is tentative but we need the /lib/sysctl.d feature to be able to provide distro defaults in a sane way. OBS-URL: https://build.opensuse.org/request/show/71353 OBS-URL: https://build.opensuse.org/package/show/Base:System/procps?expand=0&rev=46
69 lines
2.0 KiB
Diff
69 lines
2.0 KiB
Diff
From 45915cfc03fb82b68425445063a0bcebab1ff230 Mon Sep 17 00:00:00 2001
|
|
From: Ludwig Nussel <ludwig.nussel@suse.de>
|
|
Date: Wed, 18 May 2011 08:16:39 +0200
|
|
Subject: [PATCH procps 1/3] add --system switch
|
|
|
|
instead of requiring distributions to construct a loop around sysctl
|
|
in boot scripts just scan a set of default directories if the --system
|
|
switch is used.
|
|
---
|
|
sysctl.c | 35 +++++++++++++++++++++++++++++++++++
|
|
1 files changed, 35 insertions(+), 0 deletions(-)
|
|
|
|
diff --git a/sysctl.c b/sysctl.c
|
|
index 9be79ce..3445efe 100644
|
|
--- a/sysctl.c
|
|
+++ b/sysctl.c
|
|
@@ -453,6 +453,37 @@ static int Preload(const char *restrict const filename) {
|
|
return rc;
|
|
}
|
|
|
|
+static int PreloadSystem(void) {
|
|
+ unsigned i;
|
|
+ const char* dirs[] = {
|
|
+ "/lib/sysctl.d",
|
|
+ "/usr/lib/sysctl.d",
|
|
+ "/usr/local/lib/sysctl.d",
|
|
+ "/etc/sysctl.d",
|
|
+ };
|
|
+ for (i=0; i < sizeof(dirs)/sizeof(dirs[0]); ++i) {
|
|
+ struct dirent* de;
|
|
+ DIR* dp = opendir(dirs[i]);
|
|
+ if (!dp)
|
|
+ continue;
|
|
+ while (( de = readdir(dp) )) {
|
|
+ char buf[PATH_MAX];
|
|
+ if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) {
|
|
+ continue;
|
|
+ }
|
|
+ if (strlen(de->d_name) < 6 || !strcmp(de->d_name+strlen(de->d_name)-6, ".conf"))
|
|
+ continue;
|
|
+ snprintf(buf, sizeof(buf), "%s/%s", dirs[i], de->d_name);
|
|
+ if (!Quiet)
|
|
+ printf("* Applying %s ...\n", buf);
|
|
+ Preload(buf);
|
|
+ }
|
|
+ closedir(dp);
|
|
+ }
|
|
+ if (!Quiet)
|
|
+ printf("* Applying %s ...\n", DEFAULT_PRELOAD);
|
|
+ return Preload(DEFAULT_PRELOAD);
|
|
+}
|
|
|
|
|
|
/*
|
|
@@ -488,6 +519,10 @@ int main(int argc, char *argv[]) {
|
|
fprintf(stdout, "sysctl (%s)\n",procps_version);
|
|
exit(0);
|
|
}
|
|
+ if (!strcmp("--system",*argv)) {
|
|
+ IgnoreError = true;
|
|
+ return PreloadSystem();
|
|
+ }
|
|
fprintf(stderr, ERR_UNKNOWN_PARAMETER, *argv);
|
|
return Usage(me);
|
|
}
|
|
--
|
|
1.7.3.4
|
|
|