nspawn-settings.c revision 0e2656744f6d2e2cf65788a497f266d469865e30
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen/***
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen This file is part of systemd.
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen Copyright 2015 Lennart Poettering
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen systemd is free software; you can redistribute it and/or modify it
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen under the terms of the GNU Lesser General Public License as published by
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen (at your option) any later version.
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen systemd is distributed in the hope that it will be useful, but
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen Lesser General Public License for more details.
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen You should have received a copy of the GNU Lesser General Public License
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen***/
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen#include "util.h"
7eb08da4b388b920c8a894b1500c9cc7dc1f31efTom Gundersen#include "conf-parser.h"
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen#include "strv.h"
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen#include "cap-list.h"
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
04b67d49254d956d31bcfe80340fb9df7ed332d3Tom Gundersen#include "nspawn-settings.h"
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen
a501033335ed402c8f7e86fe41a15531ba69abd7Tom Gundersenint settings_load(FILE *f, const char *path, Settings **ret) {
a501033335ed402c8f7e86fe41a15531ba69abd7Tom Gundersen _cleanup_(settings_freep) Settings *s = NULL;
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen int r;
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen assert(path);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen assert(ret);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen s = new0(Settings, 1);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen if (!s)
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen return -ENOMEM;
daeb71a36a98834664e4d95773a3629b746f4db8Tom Gundersen
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen s->boot = -1;
3aeb37bc4f32b5edc334f2ac7c5d3c7b0a121328Tom Gundersen s->personality = PERSONALITY_INVALID;
c6f7c917a1b494d4455800823472227463f87438Tom Gundersen
9bf3b53533cdc9b95c921b71da755401f223f765Lennart Poettering s->read_only = -1;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen s->volatile_mode = _VOLATILE_MODE_INVALID;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen s->private_network = -1;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen s->network_veth = -1;
a501033335ed402c8f7e86fe41a15531ba69abd7Tom Gundersen
a501033335ed402c8f7e86fe41a15531ba69abd7Tom Gundersen r = config_parse(NULL, path, f,
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen "Exec\0"
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen "Network\0"
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen "Files\0",
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen config_item_perf_lookup, nspawn_gperf_lookup,
97f2d76d4f4dfab8b0629c09926a05a1e5621125Tom Gundersen false,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen false,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen true,
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek s);
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek if (r < 0)
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek return r;
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek *ret = s;
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek s = NULL;
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek return 0;
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek}
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen
9a4b012e43f23516373bf398dd9a458439d19939Tom GundersenSettings* settings_free(Settings *s) {
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen
5b9d4dc05560ddda89e48b6b39365824b15e1300Tom Gundersen if (!s)
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen return NULL;
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen strv_free(s->parameters);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen strv_free(s->environment);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen free(s->user);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen strv_free(s->network_interfaces);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen strv_free(s->network_macvlan);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen strv_free(s->network_ipvlan);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen free(s->network_bridge);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen expose_port_free_all(s->expose_ports);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen custom_mount_free_all(s->custom_mounts, s->n_custom_mounts);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen free(s);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen return NULL;
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen}
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersenbool settings_private_network(Settings *s) {
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen assert(s);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen return
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen s->private_network > 0 ||
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen s->network_veth > 0 ||
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen s->network_bridge ||
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen s->network_interfaces ||
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen s->network_macvlan ||
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen s->network_ipvlan;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen}
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersenbool settings_network_veth(Settings *s) {
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen assert(s);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen return
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen s->network_veth > 0 ||
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen s->network_bridge;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen}
03e334a1c7dc8c20c38902aa039440763acc9b17Lennart Poettering
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom GundersenDEFINE_CONFIG_PARSE_ENUM(config_parse_volatile_mode, volatile_mode, VolatileMode, "Failed to parse volatile mode");
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersenint config_parse_expose_port(
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen const char *unit,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen const char *filename,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen unsigned line,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen const char *section,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen unsigned section_line,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen const char *lvalue,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen int ltype,
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen const char *rvalue,
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen void *data,
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen void *userdata) {
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen Settings *s = data;
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen int r;
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen assert(filename);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen assert(lvalue);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen assert(rvalue);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen r = expose_port_parse(&s->expose_ports, rvalue);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen if (r == -EEXIST) {
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Duplicate port specification, ignoring: %s", rvalue);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen return 0;
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen }
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen if (r < 0) {
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse host port %s: %m", rvalue);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen return 0;
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen }
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen return 0;
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen}
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersenint config_parse_capability(
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen const char *unit,
6e37cd2f4af8928d905203108a4331e375d7127cThomas Hindoe Paaboel Andersen const char *filename,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen unsigned line,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen const char *section,
187dc6e554f2d5b4b5a3bee72c73ff5df6418aa6Thomas Hindoe Paaboel Andersen unsigned section_line,
187dc6e554f2d5b4b5a3bee72c73ff5df6418aa6Thomas Hindoe Paaboel Andersen const char *lvalue,
187dc6e554f2d5b4b5a3bee72c73ff5df6418aa6Thomas Hindoe Paaboel Andersen int ltype,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen const char *rvalue,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen void *data,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen void *userdata) {
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen uint64_t u = 0, *result = data;
ecb08ec6a5c52f2d940f3b8147e2a480affd46e1Zbigniew Jędrzejewski-Szmek int r;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen assert(filename);
ed88bcfb7c15029f9fc95ee2380759a9eb782d46Zbigniew Jędrzejewski-Szmek assert(lvalue);
ed88bcfb7c15029f9fc95ee2380759a9eb782d46Zbigniew Jędrzejewski-Szmek assert(rvalue);
ed88bcfb7c15029f9fc95ee2380759a9eb782d46Zbigniew Jędrzejewski-Szmek
ed88bcfb7c15029f9fc95ee2380759a9eb782d46Zbigniew Jędrzejewski-Szmek for (;;) {
ed88bcfb7c15029f9fc95ee2380759a9eb782d46Zbigniew Jędrzejewski-Szmek _cleanup_free_ char *word = NULL;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen int cap;
ecb08ec6a5c52f2d940f3b8147e2a480affd46e1Zbigniew Jędrzejewski-Szmek
ecb08ec6a5c52f2d940f3b8147e2a480affd46e1Zbigniew Jędrzejewski-Szmek r = extract_first_word(&rvalue, &word, NULL, 0);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen if (r < 0) {
5fde13d748749f0e06e2e6cdd15f0980a79ea82cTom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Failed to extract capability string, ignoring: %s", rvalue);
5fde13d748749f0e06e2e6cdd15f0980a79ea82cTom Gundersen return 0;
5fde13d748749f0e06e2e6cdd15f0980a79ea82cTom Gundersen }
5fde13d748749f0e06e2e6cdd15f0980a79ea82cTom Gundersen if (r == 0)
e9f3d2d508bfd9fb5b54e82994bda365a71eb864Zbigniew Jędrzejewski-Szmek break;
e9f3d2d508bfd9fb5b54e82994bda365a71eb864Zbigniew Jędrzejewski-Szmek
e9f3d2d508bfd9fb5b54e82994bda365a71eb864Zbigniew Jędrzejewski-Szmek cap = capability_from_name(word);
36f822c4bd077f9121757e24b6516e5c7ada63b5Zbigniew Jędrzejewski-Szmek if (cap < 0) {
36f822c4bd077f9121757e24b6516e5c7ada63b5Zbigniew Jędrzejewski-Szmek log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse capability, ignoring: %s", word);
ecb08ec6a5c52f2d940f3b8147e2a480affd46e1Zbigniew Jędrzejewski-Szmek continue;
36f822c4bd077f9121757e24b6516e5c7ada63b5Zbigniew Jędrzejewski-Szmek }
98a375f6d5cac24eb80d6d4e00699851324afdecTom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen u |= 1 << ((uint64_t) cap);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen }
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen if (u == 0)
ecb08ec6a5c52f2d940f3b8147e2a480affd46e1Zbigniew Jędrzejewski-Szmek return 0;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen *result |= u;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen return 0;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen}
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen
f8a0bb5285024b6ce372c3157e761e6543ebdcd2Andreas Henrikssonint config_parse_id128(
a2a5291b3f5ab6ed4c92f51d0fd10a03047380d8Zbigniew Jędrzejewski-Szmek const char *unit,
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen const char *filename,
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen unsigned line,
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen const char *section,
74df0fca09b3c31ed19e14ba80f996fdff772417Lennart Poettering unsigned section_line,
b5884878a2874447b2a9f07f324a7cd909d96d48Lennart Poettering const char *lvalue,
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt int ltype,
74df0fca09b3c31ed19e14ba80f996fdff772417Lennart Poettering const char *rvalue,
b5884878a2874447b2a9f07f324a7cd909d96d48Lennart Poettering void *data,
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen void *userdata) {
a2a5291b3f5ab6ed4c92f51d0fd10a03047380d8Zbigniew Jędrzejewski-Szmek
a2a5291b3f5ab6ed4c92f51d0fd10a03047380d8Zbigniew Jędrzejewski-Szmek sd_id128_t t, *result = data;
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen int r;
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen assert(filename);
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen assert(lvalue);
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen assert(rvalue);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen r = sd_id128_from_string(rvalue, &t);
edf029b7fd9a5853a87d3ca99aac2922bb8a277eTom Gundersen if (r < 0) {
edf029b7fd9a5853a87d3ca99aac2922bb8a277eTom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse 128bit ID/UUID, ignoring: %s", rvalue);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen return 0;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen }
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen *result = t;
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen return 0;
3f85ef0f05ffc51e19f86fb83a1c51e8e3cd6817Harald Hoyer}
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersenint config_parse_bind(
97f2d76d4f4dfab8b0629c09926a05a1e5621125Tom Gundersen const char *unit,
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek const char *filename,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen unsigned line,
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek const char *section,
f647962d64e844689f3e2acfce6102fc47e76df2Michal Schmidt unsigned section_line,
f647962d64e844689f3e2acfce6102fc47e76df2Michal Schmidt const char *lvalue,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen int ltype,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen const char *rvalue,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen void *data,
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen void *userdata) {
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen Settings *settings = data;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen int r;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen assert(filename);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen assert(lvalue);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen assert(rvalue);
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen r = bind_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue, ltype);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen if (r < 0) {
464cf22f17e0cf2d8bfa6d72b5e7a662d634f149Tom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Invalid bind mount specification %s: %m", rvalue);
464cf22f17e0cf2d8bfa6d72b5e7a662d634f149Tom Gundersen return 0;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen }
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen return 0;
7eb08da4b388b920c8a894b1500c9cc7dc1f31efTom Gundersen}
7eb08da4b388b920c8a894b1500c9cc7dc1f31efTom Gundersen
7eb08da4b388b920c8a894b1500c9cc7dc1f31efTom Gundersenint config_parse_tmpfs(
b3e013148603aa670bc2c060ac63d48e54d76fc2Tom Gundersen const char *unit,
edbb03e95a3c31bf719d5c6c46eec14d0bcb9c8fTom Gundersen const char *filename,
7eb08da4b388b920c8a894b1500c9cc7dc1f31efTom Gundersen unsigned line,
edbb03e95a3c31bf719d5c6c46eec14d0bcb9c8fTom Gundersen const char *section,
eb7040ec50fbfe5aad9eaf305bd442a4a235abaaTom Gundersen unsigned section_line,
b3e013148603aa670bc2c060ac63d48e54d76fc2Tom Gundersen const char *lvalue,
9b1c2626cef16722603bded9bb52033aba34dd74Tom Gundersen int ltype,
bf175aafd20c9ef974709ef12c5acf836121af33Tom Gundersen const char *rvalue,
b3e013148603aa670bc2c060ac63d48e54d76fc2Tom Gundersen void *data,
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen void *userdata) {
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen Settings *settings = data;
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen int r;
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen assert(filename);
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen assert(lvalue);
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen assert(rvalue);
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen
ca6038b89645c0c1bd547d6a420bf95eb3d6f4ccTom Gundersen r = tmpfs_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue);
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen if (r < 0) {
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Invalid temporary file system specification %s: %m", rvalue);
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen return 0;
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen }
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen if (settings->network_bridge)
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen settings->network_veth = true;
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen
ca6038b89645c0c1bd547d6a420bf95eb3d6f4ccTom Gundersen if (settings->network_interfaces ||
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen settings->network_macvlan ||
ca6038b89645c0c1bd547d6a420bf95eb3d6f4ccTom Gundersen settings->network_ipvlan ||
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen settings->network_bridge ||
ca6038b89645c0c1bd547d6a420bf95eb3d6f4ccTom Gundersen settings->network_veth)
ca6038b89645c0c1bd547d6a420bf95eb3d6f4ccTom Gundersen settings->private_network = true;
32bc8adcd836baff68e4d0f53b9a382f358cccf8Tom Gundersen
ca6038b89645c0c1bd547d6a420bf95eb3d6f4ccTom Gundersen return 0;
ca6038b89645c0c1bd547d6a420bf95eb3d6f4ccTom Gundersen}
ca6038b89645c0c1bd547d6a420bf95eb3d6f4ccTom Gundersen