]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/nspawn/nspawn-settings.h
log: minimize includes in log.h
[thirdparty/systemd.git] / src / nspawn / nspawn-settings.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 This file is part of systemd.
6
7 Copyright 2015 Lennart Poettering
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 #include <stdio.h>
24
25 #include "sd-id128.h"
26
27 #include "macro.h"
28 #include "nspawn-expose-ports.h"
29 #include "nspawn-mount.h"
30
31 typedef enum StartMode {
32 START_PID1, /* Run parameters as command line as process 1 */
33 START_PID2, /* Use stub init process as PID 1, run parameters as command line as process 2 */
34 START_BOOT, /* Search for init system, pass arguments as parameters */
35 _START_MODE_MAX,
36 _START_MODE_INVALID = -1
37 } StartMode;
38
39 typedef enum UserNamespaceMode {
40 USER_NAMESPACE_NO,
41 USER_NAMESPACE_FIXED,
42 USER_NAMESPACE_PICK,
43 _USER_NAMESPACE_MODE_MAX,
44 _USER_NAMESPACE_MODE_INVALID = -1,
45 } UserNamespaceMode;
46
47 typedef enum SettingsMask {
48 SETTING_START_MODE = 1 << 0,
49 SETTING_ENVIRONMENT = 1 << 1,
50 SETTING_USER = 1 << 2,
51 SETTING_CAPABILITY = 1 << 3,
52 SETTING_KILL_SIGNAL = 1 << 4,
53 SETTING_PERSONALITY = 1 << 5,
54 SETTING_MACHINE_ID = 1 << 6,
55 SETTING_NETWORK = 1 << 7,
56 SETTING_EXPOSE_PORTS = 1 << 8,
57 SETTING_READ_ONLY = 1 << 9,
58 SETTING_VOLATILE_MODE = 1 << 10,
59 SETTING_CUSTOM_MOUNTS = 1 << 11,
60 SETTING_WORKING_DIRECTORY = 1 << 12,
61 SETTING_USERNS = 1 << 13,
62 SETTING_NOTIFY_READY = 1 << 14,
63 SETTING_PIVOT_ROOT = 1 << 15,
64 SETTING_SYSCALL_FILTER = 1 << 16,
65 _SETTINGS_MASK_ALL = (1 << 17) -1
66 } SettingsMask;
67
68 typedef struct Settings {
69 /* [Run] */
70 StartMode start_mode;
71 char **parameters;
72 char **environment;
73 char *user;
74 uint64_t capability;
75 uint64_t drop_capability;
76 int kill_signal;
77 unsigned long personality;
78 sd_id128_t machine_id;
79 char *working_directory;
80 char *pivot_root_new;
81 char *pivot_root_old;
82 UserNamespaceMode userns_mode;
83 uid_t uid_shift, uid_range;
84 bool notify_ready;
85 char **syscall_whitelist;
86 char **syscall_blacklist;
87
88 /* [Image] */
89 int read_only;
90 VolatileMode volatile_mode;
91 CustomMount *custom_mounts;
92 unsigned n_custom_mounts;
93 int userns_chown;
94
95 /* [Network] */
96 int private_network;
97 int network_veth;
98 char *network_bridge;
99 char *network_zone;
100 char **network_interfaces;
101 char **network_macvlan;
102 char **network_ipvlan;
103 char **network_veth_extra;
104 ExposePort *expose_ports;
105 } Settings;
106
107 int settings_load(FILE *f, const char *path, Settings **ret);
108 Settings* settings_free(Settings *s);
109
110 bool settings_network_veth(Settings *s);
111 bool settings_private_network(Settings *s);
112
113 DEFINE_TRIVIAL_CLEANUP_FUNC(Settings*, settings_free);
114
115 const struct ConfigPerfItem* nspawn_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
116
117 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);
118 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);
119 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);
120 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);
121 int config_parse_pivot_root(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);
122 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);
123 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);
124 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);
125 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);
126 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);
127 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);
128 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);
129 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);
130 int config_parse_syscall_filter(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);