summaryrefslogtreecommitdiff
path: root/src/sysctl
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-04-24 19:55:16 +0200
committerLennart Poettering <lennart@poettering.net>2015-04-24 19:56:47 +0200
commite50b33bebdfd9ab38f037fbdb38445c64d3aae98 (patch)
treec23f0c7720b78747ed0f1534c035f361353bcbfb /src/sysctl
parent742f41adb1b7251fcdf2201632c2a980282cdcc4 (diff)
downloadsystemd-e50b33bebdfd9ab38f037fbdb38445c64d3aae98.tar.gz
sysctl: don't propagate ENOENT sysctl options
We shouldn't fail the sysctl service if an option is missing. Previously the warning about this was already downgraded to LOG_DEBUG, but we really shouldn't propagate such errors either.
Diffstat (limited to 'src/sysctl')
-rw-r--r--src/sysctl/sysctl.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index 43c765f064..fe277a2015 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -42,24 +42,23 @@ static char **arg_prefixes = NULL;
static const char conf_file_dirs[] = CONF_DIRS_NULSTR("sysctl");
static int apply_all(Hashmap *sysctl_options) {
- int r = 0;
char *property, *value;
Iterator i;
-
- assert(sysctl_options);
+ int r = 0;
HASHMAP_FOREACH_KEY(value, property, sysctl_options, i) {
int k;
k = sysctl_write(property, value);
if (k < 0) {
- log_full(k == -ENOENT ? LOG_DEBUG : LOG_WARNING,
- "Failed to write '%s' to '%s': %s", value, property, strerror(-k));
+ log_full_errno(k == -ENOENT ? LOG_DEBUG : LOG_WARNING, k,
+ "Failed to write '%s' to '%s': %m", value, property);
- if (r == 0)
+ if (r == 0 && k != -ENOENT)
r = k;
}
}
+
return r;
}
@@ -208,13 +207,14 @@ static int parse_argv(int argc, char *argv[]) {
* we need to keep compatibility. We now support any
* sysctl name available. */
sysctl_normalize(optarg);
+
if (startswith(optarg, "/proc/sys"))
p = strdup(optarg);
else
p = strappend("/proc/sys/", optarg);
-
if (!p)
return log_oom();
+
if (strv_consume(&arg_prefixes, p) < 0)
return log_oom();