Support connecting to NETCONF clients via SSH

libnetconf doesn't have nice APIs for ssh connection, but allows users
to supply the connection by themselves. One way is to use libssh (which
libnetconf uses) and supply that. However, I found that using libssh to
implement an interactive CLI isn't very easy and I'd have to implement a
lot of functionality (like authentication) by myself, attempts were
made, but I was really only imitating the interface of OpenSSH.
Fortunately, libnetconf can also communicate over file descriptors, and
it is easy to get that from OpenSSH, so I fork it and use its
stdin/stdout. On top of that, OpenSSH is very clever and knows that I'm
using it like this, so it still allows entering passwords and accepting
host keys even though its stdin/stdout isn't a terminal.

Change-Id: I27816e038bed0a82a028c8e83c15455fd514c35e
diff --git a/src/cli-netconf.cpp b/src/cli-netconf.cpp
new file mode 100644
index 0000000..4f9275a
--- /dev/null
+++ b/src/cli-netconf.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2020 CESNET, https://photonics.cesnet.cz/
+ *
+ * Written by Václav Kubernát <kubernat@cesnet.cz>
+ *
+*/
+
+#include <boost/fusion/adapted.hpp>
+#include <boost/spirit/home/x3.hpp>
+#include <optional>
+#include <stdexcept>
+#include <unistd.h>
+#include "cli-netconf.hpp"
+
+SshProcess sshProcess(const std::string& target, const std::string& port)
+{
+    namespace bp = boost::process;
+    bp::pipe in;
+    bp::pipe out;
+    auto sshPath = bp::search_path("ssh");
+    if (sshPath.empty()) {
+        throw std::runtime_error("ssh not found in PATH.");
+    }
+    if (target.front() == '@') {
+        throw std::runtime_error("Invalid username.");
+    }
+    bp::child ssh(sshPath,
+            target,
+            "-p",
+            port,
+            "-s",
+            "netconf",
+            bp::std_out > out, bp::std_in < in);
+
+    return {std::move(ssh), std::move(in), std::move(out)};
+}