aboutsummaryrefslogtreecommitdiffstats
path: root/liblfjail/jail.cc
diff options
context:
space:
mode:
Diffstat (limited to 'liblfjail/jail.cc')
-rw-r--r--liblfjail/jail.cc23
1 files changed, 8 insertions, 15 deletions
diff --git a/liblfjail/jail.cc b/liblfjail/jail.cc
index 82bec5c..cf5d600 100644
--- a/liblfjail/jail.cc
+++ b/liblfjail/jail.cc
@@ -7,6 +7,7 @@
#include "generic_error.hh"
#include "fileutils.hh"
#include "jail_zfs.hh"
+#include "spawn.hh"
namespace {
@@ -102,26 +103,18 @@ void jail_destroy(context const &ctx, jail const &jailconf) {
zfs::destroy_for_jail(ctx, jailconf);
}
-void jail_install(context const &, jail const &/*jailconf*/) {
- auto sout = std::string();
- auto serr = std::string();
-
- throw generic_error("not implemented");
-#if 0
- int ret = lfjail::cexecl(
- std::back_inserter(sout),
- std::back_inserter(serr),
- "/usr/sbin/pkg",
+void jail_install(context const &, jail const &jailconf) {
+ auto executor = exec::execl("/usr/sbin/pkg",
"pkg", "-r", jailconf.root_path, "install", "-y",
"FreeBSD-runtime", "FreeBSD-utilities", "FreeBSD-periodic",
"FreeBSD-rc", "FreeBSD-syslogd", "FreeBSD-newsyslog",
"FreeBSD-pkg-bootstrap", "pkg");
- if (!serr.empty())
- throw generic_error("pkg install failed: {}", serr);
- if (ret != 0)
- throw generic_error("pkg install failed: {}", ret);
-#endif
+ auto output = std::string();
+ auto ret = spawn(std::move(executor),
+ capture(STDOUT_FILENO, output)).wait();
+ if (!ret)
+ throw generic_error("pkg install failed");
}
} // namespace lfjail