summaryrefslogtreecommitdiff
path: root/src/sysctl
diff options
context:
space:
mode:
authorUmut Tezduyar Lindskog <umut.tezduyar@axis.com>2015-02-07 14:12:41 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-02-07 12:19:37 -0500
commitb99802f769f9c0a5c2bc94e59ed43279492daa04 (patch)
tree3cbd5cc1afb1bdd64e477a1d4c5f1ca3dc08f2fb /src/sysctl
parent2a7e23fbba3a42265c49e62404ab3f9ed25bc9b7 (diff)
sysctl: consider --prefix while parsing the files
not while applying the parsed sysctl values. Otherwise info "Overwriting earlier assignment of %s in file %s" is visible many times even though the given --prefix doesn't try to set the overridden value. This also optimizes the startup tiny bit since we have udev rules running on network devices and setting sysctl through the rules.
Diffstat (limited to 'src/sysctl')
-rw-r--r--src/sysctl/sysctl.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index 973e67e3c8..275a5b74ae 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -78,22 +78,6 @@ static int apply_sysctl(const char *property, const char *value) {
n = stpcpy(p, "/proc/sys/");
strcpy(n, property);
- if (!strv_isempty(arg_prefixes)) {
- char **i;
- bool good = false;
-
- STRV_FOREACH(i, arg_prefixes)
- if (path_startswith(p, *i)) {
- good = true;
- break;
- }
-
- if (!good) {
- log_debug("Skipping %s", p);
- return 0;
- }
- }
-
k = write_string_file(p, value);
if (k < 0) {
log_full(k == -ENOENT ? LOG_DEBUG : LOG_WARNING,
@@ -173,6 +157,20 @@ static int parse_file(Hashmap *sysctl_options, const char *path, bool ignore_eno
p = normalize_sysctl(strstrip(p));
value = strstrip(value);
+ if (!strv_isempty(arg_prefixes)) {
+ char **i, *t;
+ STRV_FOREACH(i, arg_prefixes) {
+ t = path_startswith(*i, "/proc/sys/");
+ if (t == NULL)
+ t = *i;
+ if (path_startswith(p, t))
+ goto found;
+ }
+ /* not found */
+ continue;
+ }
+
+found:
existing = hashmap_get2(sysctl_options, p, &v);
if (existing) {
if (streq(value, existing))