Blame SOURCES/0002-issue144.patch

f8071f
From f1207f311ec04aeda07759e04538d65d41d4ea4a Mon Sep 17 00:00:00 2001
f8071f
Message-Id: <f1207f311ec04aeda07759e04538d65d41d4ea4a.1624465064.git.dcaratti@redhat.com>
f8071f
From: dcaratti <davide.caratti@gmail.com>
f8071f
Date: Wed, 23 Jun 2021 18:12:41 +0200
f8071f
Subject: [PATCH] Allow empty values of "plugin_dir" in mptcpd.conf. (#145)
f8071f
f8071f
The plugin dirname is $(libdir)/mptcpd/ on standard configurations:
f8071f
use this value in case the value of plugin_dir is empty in
f8071f
/etc/mptcpd/mptcpd.conf.
f8071f
---
f8071f
 src/Makefile.am     |  3 ++-
f8071f
 src/configuration.c | 27 ++++++++++-----------------
f8071f
 2 files changed, 12 insertions(+), 18 deletions(-)
f8071f
f8071f
diff --git a/src/Makefile.am b/src/Makefile.am
f8071f
index 09ca74c..4aa5037 100644
f8071f
--- a/src/Makefile.am
f8071f
+++ b/src/Makefile.am
f8071f
@@ -31,7 +31,8 @@ libpath_manager_la_LIBADD =			\
f8071f
 
f8071f
 libpath_manager_la_CPPFLAGS =	\
f8071f
 	$(AM_CPPFLAGS)		\
f8071f
-	-DMPTCPD_CONFIG_FILE='"$(sysconfdir)/@PACKAGE@/@PACKAGE@.conf"'
f8071f
+	-DMPTCPD_CONFIG_FILE='"$(sysconfdir)/@PACKAGE@/@PACKAGE@.conf"' \
f8071f
+	-DMPTCPD_DEFAULT_PLUGINDIR='"$(libdir)/@PACKAGE@"'
f8071f
 
f8071f
 EXTRA_DIST = mptcp.service.in
f8071f
 
f8071f
diff --git a/src/configuration.c b/src/configuration.c
f8071f
index 2a48405..70a8e19 100644
f8071f
--- a/src/configuration.c
f8071f
+++ b/src/configuration.c
f8071f
@@ -304,8 +304,6 @@ static bool check_file_perms(char const *f)
f8071f
 static bool parse_config_file(struct mptcpd_config *config,
f8071f
                               char const *filename)
f8071f
 {
f8071f
-        bool parsed = true;
f8071f
-
f8071f
         assert(filename != NULL);
f8071f
 
f8071f
         if (!check_file_perms(filename))
f8071f
@@ -337,22 +335,17 @@ static bool parse_config_file(struct mptcpd_config *config,
f8071f
                                               group,
f8071f
                                               "plugin-dir");
f8071f
 
f8071f
-                if (plugin_dir == NULL) {
f8071f
-                        l_error("No plugin directory set in mptcpd "
f8071f
-                                "configuration.");
f8071f
+                set_plugin_dir(config,
f8071f
+			       plugin_dir ? plugin_dir :
f8071f
+					    l_strdup(MPTCPD_DEFAULT_PLUGINDIR));
f8071f
 
f8071f
-                        parsed = false;
f8071f
-                } else {
f8071f
-                        set_plugin_dir(config, plugin_dir);
f8071f
-
f8071f
-                        // Default plugin name.  Can be NULL.
f8071f
-                        char *const default_plugin =
f8071f
-                                l_settings_get_string(settings,
f8071f
-                                                      group,
f8071f
-                                                      "path-manager");
f8071f
+                // Default plugin name.  Can be NULL.
f8071f
+                char *const default_plugin =
f8071f
+                        l_settings_get_string(settings,
f8071f
+                                              group,
f8071f
+                                              "path-manager");
f8071f
 
f8071f
-                        set_default_plugin(config, default_plugin);
f8071f
-                }
f8071f
+                set_default_plugin(config, default_plugin);
f8071f
         } else {
f8071f
                 l_debug("Unable to mptcpd load settings from file '%s'",
f8071f
                         filename);
f8071f
@@ -360,7 +353,7 @@ static bool parse_config_file(struct mptcpd_config *config,
f8071f
 
f8071f
         l_settings_free(settings);
f8071f
 
f8071f
-        return parsed;
f8071f
+        return true;
f8071f
 }
f8071f
 
f8071f
 /**
f8071f
-- 
f8071f
2.31.1
f8071f