]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/nspawn/nspawn-settings.h
Merge pull request #5054 from evverx/fix-double-free-in-link
[thirdparty/systemd.git] / src / nspawn / nspawn-settings.h
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"
25 #include "nspawn-expose-ports.h"
26 #include "nspawn-mount.h"
27
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
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
44 typedef enum SettingsMask {
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,
57 SETTING_WORKING_DIRECTORY = 1 << 12,
58 SETTING_USERNS = 1 << 13,
59 SETTING_NOTIFY_READY = 1 << 14,
60 _SETTINGS_MASK_ALL = (1 << 15) -1
61 } SettingsMask;
62
63 typedef struct Settings {
64 /* [Run] */
65 StartMode start_mode;
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;
74 char *working_directory;
75 UserNamespaceMode userns_mode;
76 uid_t uid_shift, uid_range;
77 bool notify_ready;
78
79 /* [Image] */
80 int read_only;
81 VolatileMode volatile_mode;
82 CustomMount *custom_mounts;
83 unsigned n_custom_mounts;
84 int userns_chown;
85
86 /* [Network] */
87 int private_network;
88 int network_veth;
89 char *network_bridge;
90 char *network_zone;
91 char **network_interfaces;
92 char **network_macvlan;
93 char **network_ipvlan;
94 char **network_veth_extra;
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
101 bool settings_network_veth(Settings *s);
102 bool settings_private_network(Settings *s);
103
104 DEFINE_TRIVIAL_CLEANUP_FUNC(Settings*, settings_free);
105
106 const struct ConfigPerfItem* nspawn_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
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);
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);
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);
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);
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);
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);