]>
Commit | Line | Data |
---|---|---|
f757855e LP |
1 | #pragma once |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2015 Lennart Poettering | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU Lesser General Public License as published by | |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public License | |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
20 | ***/ | |
21 | ||
22 | #include <stdio.h> | |
23 | ||
24 | #include "macro.h" | |
7a8f6325 | 25 | #include "nspawn-expose-ports.h" |
71d35b6b | 26 | #include "nspawn-mount.h" |
f757855e | 27 | |
7732f92b LP |
28 | typedef enum StartMode { |
29 | START_PID1, /* Run parameters as command line as process 1 */ | |
30 | START_PID2, /* Use stub init process as PID 1, run parameters as command line as process 2 */ | |
31 | START_BOOT, /* Search for init system, pass arguments as parameters */ | |
32 | _START_MODE_MAX, | |
33 | _START_MODE_INVALID = -1 | |
34 | } StartMode; | |
35 | ||
0de7acce LP |
36 | typedef enum UserNamespaceMode { |
37 | USER_NAMESPACE_NO, | |
38 | USER_NAMESPACE_FIXED, | |
39 | USER_NAMESPACE_PICK, | |
40 | _USER_NAMESPACE_MODE_MAX, | |
41 | _USER_NAMESPACE_MODE_INVALID = -1, | |
42 | } UserNamespaceMode; | |
43 | ||
f757855e | 44 | typedef enum SettingsMask { |
7732f92b LP |
45 | SETTING_START_MODE = 1 << 0, |
46 | SETTING_ENVIRONMENT = 1 << 1, | |
47 | SETTING_USER = 1 << 2, | |
48 | SETTING_CAPABILITY = 1 << 3, | |
49 | SETTING_KILL_SIGNAL = 1 << 4, | |
50 | SETTING_PERSONALITY = 1 << 5, | |
51 | SETTING_MACHINE_ID = 1 << 6, | |
52 | SETTING_NETWORK = 1 << 7, | |
53 | SETTING_EXPOSE_PORTS = 1 << 8, | |
54 | SETTING_READ_ONLY = 1 << 9, | |
55 | SETTING_VOLATILE_MODE = 1 << 10, | |
56 | SETTING_CUSTOM_MOUNTS = 1 << 11, | |
5f932eb9 | 57 | SETTING_WORKING_DIRECTORY = 1 << 12, |
0de7acce | 58 | SETTING_USERNS = 1 << 13, |
9c1e04d0 AP |
59 | SETTING_NOTIFY_READY = 1 << 14, |
60 | _SETTINGS_MASK_ALL = (1 << 15) -1 | |
f757855e LP |
61 | } SettingsMask; |
62 | ||
63 | typedef struct Settings { | |
64 | /* [Run] */ | |
7732f92b | 65 | StartMode start_mode; |
f757855e LP |
66 | char **parameters; |
67 | char **environment; | |
68 | char *user; | |
69 | uint64_t capability; | |
70 | uint64_t drop_capability; | |
71 | int kill_signal; | |
72 | unsigned long personality; | |
73 | sd_id128_t machine_id; | |
5f932eb9 | 74 | char *working_directory; |
0de7acce LP |
75 | UserNamespaceMode userns_mode; |
76 | uid_t uid_shift, uid_range; | |
9c1e04d0 | 77 | bool notify_ready; |
f757855e LP |
78 | |
79 | /* [Image] */ | |
80 | int read_only; | |
81 | VolatileMode volatile_mode; | |
82 | CustomMount *custom_mounts; | |
83 | unsigned n_custom_mounts; | |
0de7acce | 84 | int userns_chown; |
f757855e LP |
85 | |
86 | /* [Network] */ | |
87 | int private_network; | |
88 | int network_veth; | |
89 | char *network_bridge; | |
22b28dfd | 90 | char *network_zone; |
f757855e LP |
91 | char **network_interfaces; |
92 | char **network_macvlan; | |
93 | char **network_ipvlan; | |
f6d6bad1 | 94 | char **network_veth_extra; |
f757855e LP |
95 | ExposePort *expose_ports; |
96 | } Settings; | |
97 | ||
98 | int settings_load(FILE *f, const char *path, Settings **ret); | |
99 | Settings* settings_free(Settings *s); | |
100 | ||
0e265674 LP |
101 | bool settings_network_veth(Settings *s); |
102 | bool settings_private_network(Settings *s); | |
103 | ||
f757855e LP |
104 | DEFINE_TRIVIAL_CLEANUP_FUNC(Settings*, settings_free); |
105 | ||
c9f7b4d3 | 106 | const struct ConfigPerfItem* nspawn_gperf_lookup(const char *key, GPERF_LEN_TYPE length); |
f757855e LP |
107 | |
108 | int config_parse_capability(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
109 | int config_parse_id128(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
110 | int config_parse_expose_port(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
111 | int config_parse_volatile_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
112 | int config_parse_bind(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
113 | int config_parse_tmpfs(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
7b4318b6 | 114 | int config_parse_overlay(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); |
f6d6bad1 | 115 | int config_parse_veth_extra(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); |
22b28dfd | 116 | int config_parse_network_zone(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); |
7732f92b LP |
117 | int config_parse_boot(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); |
118 | int config_parse_pid2(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
0de7acce | 119 | int config_parse_private_users(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); |