]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/namespace.h
core: on DynamicUser= make sure that protecting sensitive paths is enforced (#4596)
[thirdparty/systemd.git] / src / core / namespace.h
1 #pragma once
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2010 Lennart Poettering
7 Copyright 2016 Djalal Harouni
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 typedef struct NameSpaceInfo NameSpaceInfo;
24
25 #include <stdbool.h>
26
27 #include "macro.h"
28
29 typedef enum ProtectHome {
30 PROTECT_HOME_NO,
31 PROTECT_HOME_YES,
32 PROTECT_HOME_READ_ONLY,
33 _PROTECT_HOME_MAX,
34 _PROTECT_HOME_INVALID = -1
35 } ProtectHome;
36
37 typedef enum ProtectSystem {
38 PROTECT_SYSTEM_NO,
39 PROTECT_SYSTEM_YES,
40 PROTECT_SYSTEM_FULL,
41 PROTECT_SYSTEM_STRICT,
42 _PROTECT_SYSTEM_MAX,
43 _PROTECT_SYSTEM_INVALID = -1
44 } ProtectSystem;
45
46 struct NameSpaceInfo {
47 bool ignore_protect_paths:1;
48 bool private_dev:1;
49 bool protect_control_groups:1;
50 bool protect_kernel_tunables:1;
51 bool protect_kernel_modules:1;
52 };
53
54 int setup_namespace(const char *chroot,
55 const NameSpaceInfo *ns_info,
56 char **read_write_paths,
57 char **read_only_paths,
58 char **inaccessible_paths,
59 const char *tmp_dir,
60 const char *var_tmp_dir,
61 ProtectHome protect_home,
62 ProtectSystem protect_system,
63 unsigned long mount_flags);
64
65 int setup_tmp_dirs(const char *id,
66 char **tmp_dir,
67 char **var_tmp_dir);
68
69 int setup_netns(int netns_storage_socket[2]);
70
71 const char* protect_home_to_string(ProtectHome p) _const_;
72 ProtectHome protect_home_from_string(const char *s) _pure_;
73
74 const char* protect_system_to_string(ProtectSystem p) _const_;
75 ProtectSystem protect_system_from_string(const char *s) _pure_;