Skip to content

Commit 5dcd55b

Browse files
committed
Merge branch 'main' into github
2 parents c25e0ac + cd17e0f commit 5dcd55b

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

src/landlock.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
LandlockRuleset::LandlockRuleset(uint64_t handled_access_fr,
1212
uint64_t handled_access_net)
1313
{
14+
if (LandlockRuleset::abi_version() < 6)
15+
throw std::runtime_error("Landlock is too old.");
16+
1417
const struct landlock_ruleset_attr attr = {
1518
.handled_access_fs = handled_access_fr,
1619
.handled_access_net = handled_access_net};
@@ -37,4 +40,9 @@ void LandlockRuleset::restrict_self() const
3740
throw std::runtime_error("Failed to restrict self via landlock.");
3841
}
3942

43+
[[nodiscard]] int LandlockRuleset::abi_version() noexcept
44+
{
45+
return landlock_create_ruleset(nullptr, 0, LANDLOCK_CREATE_RULESET_VERSION);
46+
}
47+
4048
#endif

src/landlock.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class LandlockRuleset
5959
int32_t parent_fd) const;
6060
void restrict_self() const;
6161

62+
[[nodiscard]] static int abi_version() noexcept;
63+
6264
private:
6365
int ruleset;
6466
};

src/main.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <cstdlib>
1212
#include <boost/asio.hpp>
1313
#include <boost/log/trivial.hpp>
14+
#include <boost/version.hpp>
1415
#include <unistd.h>
1516
#include "capability_managment.hpp"
1617
#include "configuration.hpp"
@@ -88,7 +89,7 @@ int main(int argc, char * argv[])
8889
#if defined(TINS_VERSION_MAJOR) && defined(TINS_VERSION_MINOR) && \
8990
defined(TINS_VERSION_PATCH)
9091
BOOST_LOG_TRIVIAL(info)
91-
<< "libtins version: " << TINS_VERSION_MAJOR << "."
92+
<< "libtins version (compile time): " << TINS_VERSION_MAJOR << "."
9293
<< TINS_VERSION_MINOR << "." << TINS_VERSION_PATCH;
9394
#endif
9495

@@ -100,16 +101,27 @@ int main(int argc, char * argv[])
100101

101102
#ifdef HAVE_SECCOMP
102103
BOOST_LOG_TRIVIAL(info) << "seccomp: true";
104+
auto seccomp_ver = seccomp_version();
105+
BOOST_LOG_TRIVIAL(info)
106+
<< "seccomp version (runtime): " << seccomp_ver->major << "."
107+
<< seccomp_ver->minor << "." << seccomp_ver->micro;
103108
#else
104109
BOOST_LOG_TRIVIAL(info) << "seccomp: false";
105110
#endif
106111

107112
#ifdef HAVE_LANDLOCK
108-
BOOST_LOG_TRIVIAL(info) << "landlock: true";
113+
BOOST_LOG_TRIVIAL(info) << "Landlock: true";
114+
BOOST_LOG_TRIVIAL(info)
115+
<< "Landlock ABI version: " << LandlockRuleset::abi_version();
109116
#else
110-
BOOST_LOG_TRIVIAL(info) << "landlock: false";
117+
BOOST_LOG_TRIVIAL(info) << "Landlock: false";
111118
#endif
112119

120+
BOOST_LOG_TRIVIAL(info)
121+
<< "Boost version (compile time): " << (BOOST_VERSION / 100'000)
122+
<< "." << (BOOST_VERSION / 100 % 1000) << "."
123+
<< (BOOST_VERSION % 100);
124+
113125
const std::shared_ptr<NodeContainer> nodecontainer =
114126
config.get_node_container();
115127

0 commit comments

Comments
 (0)