]>
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 | ||
f757855e | 36 | typedef enum SettingsMask { |
7732f92b LP |
37 | SETTING_START_MODE = 1 << 0, |
38 | SETTING_ENVIRONMENT = 1 << 1, | |
39 | SETTING_USER = 1 << 2, | |
40 | SETTING_CAPABILITY = 1 << 3, | |
41 | SETTING_KILL_SIGNAL = 1 << 4, | |
42 | SETTING_PERSONALITY = 1 << 5, | |
43 | SETTING_MACHINE_ID = 1 << 6, | |
44 | SETTING_NETWORK = 1 << 7, | |
45 | SETTING_EXPOSE_PORTS = 1 << 8, | |
46 | SETTING_READ_ONLY = 1 << 9, | |
47 | SETTING_VOLATILE_MODE = 1 << 10, | |
48 | SETTING_CUSTOM_MOUNTS = 1 << 11, | |
5f932eb9 | 49 | SETTING_WORKING_DIRECTORY = 1 << 12, |
7732f92b | 50 | _SETTINGS_MASK_ALL = (1 << 13) -1 |
f757855e LP |
51 | } SettingsMask; |
52 | ||
53 | typedef struct Settings { | |
54 | /* [Run] */ | |
7732f92b | 55 | StartMode start_mode; |
f757855e LP |
56 | char **parameters; |
57 | char **environment; | |
58 | char *user; | |
59 | uint64_t capability; | |
60 | uint64_t drop_capability; | |
61 | int kill_signal; | |
62 | unsigned long personality; | |
63 | sd_id128_t machine_id; | |
5f932eb9 | 64 | char *working_directory; |
f757855e LP |
65 | |
66 | /* [Image] */ | |
67 | int read_only; | |
68 | VolatileMode volatile_mode; | |
69 | CustomMount *custom_mounts; | |
70 | unsigned n_custom_mounts; | |
71 | ||
72 | /* [Network] */ | |
73 | int private_network; | |
74 | int network_veth; | |
75 | char *network_bridge; | |
76 | char **network_interfaces; | |
77 | char **network_macvlan; | |
78 | char **network_ipvlan; | |
f6d6bad1 | 79 | char **network_veth_extra; |
f757855e LP |
80 | ExposePort *expose_ports; |
81 | } Settings; | |
82 | ||
83 | int settings_load(FILE *f, const char *path, Settings **ret); | |
84 | Settings* settings_free(Settings *s); | |
85 | ||
0e265674 LP |
86 | bool settings_network_veth(Settings *s); |
87 | bool settings_private_network(Settings *s); | |
88 | ||
f757855e LP |
89 | DEFINE_TRIVIAL_CLEANUP_FUNC(Settings*, settings_free); |
90 | ||
91 | const struct ConfigPerfItem* nspawn_gperf_lookup(const char *key, unsigned length); | |
92 | ||
93 | 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); | |
94 | 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); | |
95 | 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); | |
96 | 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); | |
97 | 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); | |
98 | 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); | |
f6d6bad1 | 99 | 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); |
7732f92b LP |
100 | 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); |
101 | 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); |