Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates-src > by-pkgid > ab4b662b9827b6375ffd451bf4abd615 > files > 568

systemd-44-24.fc17.src.rpm

From 07ea1c26afae48acf33fc1d3240808d902930296 Mon Sep 17 00:00:00 2001
From: Dave Reisner <dreisner@archlinux.org>
Date: Sat, 6 Oct 2012 16:32:17 -0400
Subject: [PATCH] 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.
(cherry picked from commit 1a3f40f912670d3dea3811a4560b368412090b81)
---
 src/sysctl/sysctl.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index be03f78..e64aea7 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -169,9 +169,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);