]>
Commit | Line | Data |
---|---|---|
c2f1db8f | 1 | #pragma once |
15ae422b LP |
2 | |
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2010 Lennart Poettering | |
c575770b | 7 | Copyright 2016 Djalal Harouni |
15ae422b LP |
8 | |
9 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
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 | |
15ae422b LP |
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 | |
5430f7f2 | 17 | Lesser General Public License for more details. |
15ae422b | 18 | |
5430f7f2 | 19 | You should have received a copy of the GNU Lesser General Public License |
15ae422b LP |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
21 | ***/ | |
22 | ||
c575770b | 23 | typedef struct NameSpaceInfo NameSpaceInfo; |
d2d6c096 | 24 | typedef struct BindMount BindMount; |
c575770b | 25 | |
15ae422b LP |
26 | #include <stdbool.h> |
27 | ||
417116f2 LP |
28 | #include "macro.h" |
29 | ||
1b8689f9 LP |
30 | typedef enum ProtectHome { |
31 | PROTECT_HOME_NO, | |
32 | PROTECT_HOME_YES, | |
33 | PROTECT_HOME_READ_ONLY, | |
34 | _PROTECT_HOME_MAX, | |
35 | _PROTECT_HOME_INVALID = -1 | |
36 | } ProtectHome; | |
37 | ||
38 | typedef enum ProtectSystem { | |
39 | PROTECT_SYSTEM_NO, | |
40 | PROTECT_SYSTEM_YES, | |
41 | PROTECT_SYSTEM_FULL, | |
3f815163 | 42 | PROTECT_SYSTEM_STRICT, |
1b8689f9 LP |
43 | _PROTECT_SYSTEM_MAX, |
44 | _PROTECT_SYSTEM_INVALID = -1 | |
45 | } ProtectSystem; | |
417116f2 | 46 | |
c575770b | 47 | struct NameSpaceInfo { |
af964954 | 48 | bool ignore_protect_paths:1; |
c575770b DH |
49 | bool private_dev:1; |
50 | bool protect_control_groups:1; | |
51 | bool protect_kernel_tunables:1; | |
52 | bool protect_kernel_modules:1; | |
53 | }; | |
54 | ||
d2d6c096 LP |
55 | struct BindMount { |
56 | char *source; | |
57 | char *destination; | |
58 | bool read_only:1; | |
59 | bool recursive:1; | |
60 | bool ignore_enoent:1; | |
61 | }; | |
62 | ||
63 | int setup_namespace( | |
64 | const char *root_directory, | |
65 | const NameSpaceInfo *ns_info, | |
66 | char **read_write_paths, | |
67 | char **read_only_paths, | |
68 | char **inaccessible_paths, | |
69 | const BindMount *bind_mounts, | |
70 | unsigned n_bind_mounts, | |
71 | const char *tmp_dir, | |
72 | const char *var_tmp_dir, | |
73 | ProtectHome protect_home, | |
74 | ProtectSystem protect_system, | |
75 | unsigned long mount_flags); | |
76 | ||
77 | int setup_tmp_dirs( | |
78 | const char *id, | |
79 | char **tmp_dir, | |
80 | char **var_tmp_dir); | |
613b411c LP |
81 | |
82 | int setup_netns(int netns_storage_socket[2]); | |
417116f2 | 83 | |
1b8689f9 LP |
84 | const char* protect_home_to_string(ProtectHome p) _const_; |
85 | ProtectHome protect_home_from_string(const char *s) _pure_; | |
86 | ||
87 | const char* protect_system_to_string(ProtectSystem p) _const_; | |
88 | ProtectSystem protect_system_from_string(const char *s) _pure_; | |
d2d6c096 LP |
89 | |
90 | void bind_mount_free_many(BindMount *b, unsigned n); | |
91 | int bind_mount_add(BindMount **b, unsigned *n, const BindMount *item); |