Get rid of bp::search_path

Boost filesystem was making some trouble when compiling with libc++. The
CI uses libc++ for LLVM builds, and the symbol names are different
between libc++ and libstdc++ (gnu). This difference would make the code
segfault inside Boost::filesystem. This patch gets rid of
Boost::filesystem linking.
Caveat: execAndWait now needs full file path.

Change-Id: Ia1abedc426f971884abda6c1ccbb897ad29c98ec
diff --git a/src/main-firewall.cpp b/src/main-firewall.cpp
index 277dc40..d9d0066 100644
--- a/src/main-firewall.cpp
+++ b/src/main-firewall.cpp
@@ -6,6 +6,7 @@
 #include <unistd.h>
 #include "VELIA_VERSION.h"
 #include "firewall/Firewall.h"
+#include "system_vars.h"
 #include "utils/exceptions.h"
 #include "utils/exec.h"
 #include "utils/journal.h"
@@ -69,7 +70,7 @@
         auto srSess = std::make_shared<sysrepo::Session>(srConn);
         velia::firewall::SysrepoFirewall firewall(srSess, [] (const auto& config) {
             spdlog::get("firewall")->debug("running nft...");
-            velia::utils::execAndWait(spdlog::get("firewall"), "nft", {"-f", "-"}, config);
+            velia::utils::execAndWait(spdlog::get("firewall"), NFT_EXECUTABLE, {"-f", "-"}, config);
 
             spdlog::get("firewall")->debug("nft config applied.");
         });
diff --git a/src/system/system_vars.h.in b/src/system/system_vars.h.in
index c1ce6c9..bb91fc6 100644
--- a/src/system/system_vars.h.in
+++ b/src/system/system_vars.h.in
@@ -1,2 +1,3 @@
 #define NOBODY_UID @NOBODY_UID@
 #define NOBODY_GID @NOBODY_GID@
+#define NFT_EXECUTABLE "@NFT_EXECUTABLE@"
diff --git a/src/utils/exec.cpp b/src/utils/exec.cpp
index 2d8bfc8..f8e8a9a 100644
--- a/src/utils/exec.cpp
+++ b/src/utils/exec.cpp
@@ -14,7 +14,7 @@
 
 void velia::utils::execAndWait(
         velia::Log logger,
-        const std::string& program,
+        const std::string& absolutePath,
         std::initializer_list<std::string> args,
         std::string_view std_in,
         const std::set<ExecOptions> opts)
@@ -39,9 +39,9 @@
         }
     };
 
-    logger->trace("exec: {} {}", program, boost::algorithm::join(args, " "));
+    logger->trace("exec: {} {}", absolutePath, boost::algorithm::join(args, " "));
     bp::child c(
-            bp::search_path(program),
+            absolutePath,
             boost::process::args=std::move(args),
             bp::std_in < stdinPipe, bp::std_out > bp::null, bp::std_err > stderrStream,
             bp::extend::on_exec_setup=onExecSetup);
@@ -50,13 +50,13 @@
     stdinPipe.close();
 
     c.wait();
-    logger->trace("{} exited", program);
+    logger->trace("{} exited", absolutePath);
 
     if (c.exit_code()) {
         std::istreambuf_iterator<char> begin(stderrStream), end;
         std::string stderrOutput(begin, end);
-        logger->critical("{} ended with a non-zero exit code. stderr: {}", program, stderrOutput);
+        logger->critical("{} ended with a non-zero exit code. stderr: {}", absolutePath, stderrOutput);
 
-        throw std::runtime_error(program + " returned non-zero exit code " + std::to_string(c.exit_code()));
+        throw std::runtime_error(absolutePath + " returned non-zero exit code " + std::to_string(c.exit_code()));
     }
 }
diff --git a/src/utils/exec.h b/src/utils/exec.h
index 3fd997c..80292b7 100644
--- a/src/utils/exec.h
+++ b/src/utils/exec.h
@@ -12,16 +12,16 @@
 
 namespace velia::utils {
 /**
- * Spawns a new process and waits until it returns. stdout is thrown away. Throws if the program has a non-zero exit
- * code with a message containing the stderr of the process.
+ * Spawns a new process with an executable specified by `absolutePath` and waits until it returns. stdout is thrown
+ * away. Throws if the program has a non-zero exit code with a message containing the stderr of the process.
  *
  * @param logger Logger to use.
- * @param program The name of the program to spawn. PATH is searched for this program.
+ * @param absolutePath Full path to the excutable.
  * @param args Arguments to pass to the program. Can be {} if no arguments should be passed.
  * @param std_in stdin input fo the program.
  */
 enum class ExecOptions {
     DropRoot
 };
-void execAndWait(velia::Log logger, const std::string& program, std::initializer_list<std::string> args, std::string_view std_in, const std::set<ExecOptions> opts = {});
+void execAndWait(velia::Log logger, const std::string& absolutePath, std::initializer_list<std::string> args, std::string_view std_in, const std::set<ExecOptions> opts = {});
 }