1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 This file is part of systemd.
7 Copyright 2010 Lennart Poettering
8 Copyright 2016 Djalal Harouni
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 typedef struct NamespaceInfo NamespaceInfo
;
25 typedef struct BindMount BindMount
;
26 typedef struct TemporaryFileSystem TemporaryFileSystem
;
30 #include "dissect-image.h"
33 typedef enum ProtectHome
{
36 PROTECT_HOME_READ_ONLY
,
39 _PROTECT_HOME_INVALID
= -1
42 typedef enum NamespaceType
{
51 _NAMESPACE_TYPE_INVALID
= -1,
54 typedef enum ProtectSystem
{
58 PROTECT_SYSTEM_STRICT
,
60 _PROTECT_SYSTEM_INVALID
= -1
63 struct NamespaceInfo
{
64 bool ignore_protect_paths
:1;
66 bool protect_control_groups
:1;
67 bool protect_kernel_tunables
:1;
68 bool protect_kernel_modules
:1;
80 struct TemporaryFileSystem
{
86 const char *root_directory
,
87 const char *root_image
,
88 const NamespaceInfo
*ns_info
,
89 char **read_write_paths
,
90 char **read_only_paths
,
91 char **inaccessible_paths
,
92 char **empty_directories
,
93 const BindMount
*bind_mounts
,
94 unsigned n_bind_mounts
,
95 const TemporaryFileSystem
*temporary_filesystems
,
96 unsigned n_temporary_filesystems
,
98 const char *var_tmp_dir
,
99 ProtectHome protect_home
,
100 ProtectSystem protect_system
,
101 unsigned long mount_flags
,
102 DissectImageFlags dissected_image_flags
);
109 int setup_netns(int netns_storage_socket
[2]);
111 const char* protect_home_to_string(ProtectHome p
) _const_
;
112 ProtectHome
protect_home_from_string(const char *s
) _pure_
;
113 ProtectHome
parse_protect_home_or_bool(const char *s
);
115 const char* protect_system_to_string(ProtectSystem p
) _const_
;
116 ProtectSystem
protect_system_from_string(const char *s
) _pure_
;
117 ProtectSystem
parse_protect_system_or_bool(const char *s
);
119 void bind_mount_free_many(BindMount
*b
, unsigned n
);
120 int bind_mount_add(BindMount
**b
, unsigned *n
, const BindMount
*item
);
122 void temporary_filesystem_free_many(TemporaryFileSystem
*t
, unsigned n
);
123 int temporary_filesystem_add(TemporaryFileSystem
**t
, unsigned *n
,
124 const char *path
, const char *options
);
126 const char* namespace_type_to_string(NamespaceType t
) _const_
;
127 NamespaceType
namespace_type_from_string(const char *s
) _pure_
;
129 bool ns_type_supported(NamespaceType type
);