Tests: Add a few test files.
[xz.git] / src / xz / sandbox.h
blobf41b4725ce3f03b473feb385ce4a463c1806d1d4
1 // SPDX-License-Identifier: 0BSD
3 ///////////////////////////////////////////////////////////////////////////////
4 //
5 /// \file sandbox.h
6 /// \brief Sandbox support
7 //
8 // Author: Lasse Collin
9 //
10 ///////////////////////////////////////////////////////////////////////////////
12 #if defined(HAVE_PLEDGE) || defined(HAVE_LINUX_LANDLOCK_H) \
13 || defined(HAVE_CAP_RIGHTS_LIMIT)
14 # define ENABLE_SANDBOX 1
15 #endif
18 /// \brief Enables early sandboxing that can always be enabled
19 ///
20 /// This requires that tuklib_progname() and io_init() have been called.
21 extern void sandbox_init(void);
24 /// \brief Enable sandboxing that only allows opening files for reading
25 extern void sandbox_enable_read_only(void);
28 /// \brief Tell sandboxing code that strict sandboxing can be used
29 ///
30 /// This function only sets a flag which will be read by
31 /// sandbox_enable_strict_if_allowed().
32 extern void sandbox_allow_strict(void);
35 /// \brief Enable sandboxing that allows reading from one file
36 ///
37 /// This does nothing if sandbox_allow_strict() hasn't been called.
38 ///
39 /// \param src_fd File descriptor open for reading
40 /// \param pipe_event_fd user_abort_pipe[0] from file_io.c
41 /// \param pipe_write_fd user_abort_pipe[1] from file_io.c
42 extern void sandbox_enable_strict_if_allowed(
43 int src_fd, int pipe_event_fd, int pipe_write_fd);