diff options
| author | Lexi Winter <ivy@FreeBSD.org> | 2025-06-16 02:43:15 +0100 |
|---|---|---|
| committer | Lexi Winter <ivy@FreeBSD.org> | 2025-06-16 02:43:15 +0100 |
| commit | 8129d0ef4629f44cd89e3b79e8b66129bb9dc866 (patch) | |
| tree | 271a7698c45d301a6f89f79fb1f2d0cac62f39da /liblfjail/jail.cc | |
| parent | 737fb60605e8b9c64d6dd9e4c982a4e7ee2ef5d3 (diff) | |
| download | lfjail-8129d0ef4629f44cd89e3b79e8b66129bb9dc866.tar.gz lfjail-8129d0ef4629f44cd89e3b79e8b66129bb9dc866.tar.bz2 | |
updates
Diffstat (limited to 'liblfjail/jail.cc')
| -rw-r--r-- | liblfjail/jail.cc | 23 |
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 |
