summaryrefslogtreecommitdiff
path: root/src/sysctl
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-10-06 16:32:17 -0400
committerDave Reisner <dreisner@archlinux.org>2012-10-06 16:41:30 -0400
commit1a3f40f912670d3dea3811a4560b368412090b81 (patch)
tree507506240220ce3f087e167c40804abc4a272b69 /src/sysctl
parent8bd3b8620c80d0f2383f2fb04315411fc8077ca1 (diff)
sysctl: avoiding exiting with error on -EEXIST
If the final key in any sysctl.d file is a duplicate, systemd-sysctl will exit with an error (and no explaination why). Ignore this, as duplicate keys are to be expected when overriding settings in the directory hierarchy.
Diffstat (limited to 'src/sysctl')
-rw-r--r--src/sysctl/sysctl.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index e77f496089..a68d67fd4b 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -167,9 +167,13 @@ static int parse_file(const char *path, bool ignore_enoent) {
r = hashmap_put(sysctl_options, property, new_value);
if (r < 0) {
- if (r == -EEXIST)
+ if (r == -EEXIST) {
+ /* ignore this "error" to avoid returning it
+ * for the function when this is the last key
+ * in the file being parsed. */
+ r = 0;
log_debug("Skipping previously assigned sysctl variable %s", property);
- else
+ } else
log_error("Failed to add sysctl variable %s to hashmap: %s", property, strerror(-r));
free(property);