From 563288ea705e83ff5cb292adf794650c263bca1d Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Tue, 25 Oct 2022 21:11:58 +0300 Subject: xz: Add support for OpenBSD's pledge() sandbox. --- src/xz/file_io.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/xz/file_io.c') diff --git a/src/xz/file_io.c b/src/xz/file_io.c index 046ca7e3..61857029 100644 --- a/src/xz/file_io.c +++ b/src/xz/file_io.c @@ -212,6 +212,17 @@ io_sandbox_enter(int src_fd) if (cap_enter()) goto error; +#elif defined(HAVE_PLEDGE) + // pledge() was introduced in OpenBSD 5.9. + // + // main() unconditionally calls pledge() with fairly relaxed + // promises which work in all situations. Here we make the + // sandbox more strict. + if (pledge("stdio", "")) + goto error; + + (void)src_fd; + #else # error ENABLE_SANDBOX is defined but no sandboxing method was found. #endif -- cgit v1.2.3