nspawn-settings.c revision 7b3e062cb6872e28ef5a2e069810070e28bbe0cd
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen/***
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen This file is part of systemd.
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen Copyright 2015 Lennart Poettering
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen systemd is free software; you can redistribute it and/or modify it
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen under the terms of the GNU Lesser General Public License as published by
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen (at your option) any later version.
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen systemd is distributed in the hope that it will be useful, but
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen Lesser General Public License for more details.
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen You should have received a copy of the GNU Lesser General Public License
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen***/
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen#include "alloc-util.h"
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen#include "cap-list.h"
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen#include "conf-parser.h"
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen#include "nspawn-settings.h"
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen#include "process-util.h"
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen#include "strv.h"
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen#include "util.h"
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersenint settings_load(FILE *f, const char *path, Settings **ret) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen _cleanup_(settings_freep) Settings *s = NULL;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen int r;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(path);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(ret);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s = new0(Settings, 1);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen if (!s)
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return -ENOMEM;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->boot = -1;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->personality = PERSONALITY_INVALID;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->read_only = -1;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->volatile_mode = _VOLATILE_MODE_INVALID;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->private_network = -1;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->network_veth = -1;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen r = config_parse(NULL, path, f,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen "Exec\0"
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen "Network\0"
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen "Files\0",
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen config_item_perf_lookup, nspawn_gperf_lookup,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen false,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen false,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen true,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen if (r < 0)
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return r;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen *ret = s;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s = NULL;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return 0;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen}
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom GundersenSettings* settings_free(Settings *s) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen if (!s)
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return NULL;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen strv_free(s->parameters);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen strv_free(s->environment);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen free(s->user);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen strv_free(s->network_interfaces);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen strv_free(s->network_macvlan);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen strv_free(s->network_ipvlan);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen free(s->network_bridge);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen expose_port_free_all(s->expose_ports);
52efd56a6369e19c2400a42981a197cd2eef924aLennart Poettering
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen custom_mount_free_all(s->custom_mounts, s->n_custom_mounts);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen free(s);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return NULL;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen}
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersenbool settings_private_network(Settings *s) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(s);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->private_network > 0 ||
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->network_veth > 0 ||
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->network_bridge ||
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->network_interfaces ||
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->network_macvlan ||
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->network_ipvlan;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen}
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersenbool settings_network_veth(Settings *s) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(s);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->network_veth > 0 ||
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen s->network_bridge;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen}
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom GundersenDEFINE_CONFIG_PARSE_ENUM(config_parse_volatile_mode, volatile_mode, VolatileMode, "Failed to parse volatile mode");
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersenint config_parse_expose_port(
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *unit,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *filename,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen unsigned line,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *section,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen unsigned section_line,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *lvalue,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen int ltype,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *rvalue,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen void *data,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen void *userdata) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen Settings *s = data;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen int r;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(filename);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(lvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(rvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen r = expose_port_parse(&s->expose_ports, rvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen if (r == -EEXIST) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Duplicate port specification, ignoring: %s", rvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return 0;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen }
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen if (r < 0) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse host port %s: %m", rvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return 0;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen }
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return 0;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen}
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersenint config_parse_capability(
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *unit,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *filename,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen unsigned line,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *section,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen unsigned section_line,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *lvalue,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen int ltype,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *rvalue,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen void *data,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen void *userdata) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen uint64_t u = 0, *result = data;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen int r;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(filename);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(lvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(rvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen for (;;) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen _cleanup_free_ char *word = NULL;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen int cap;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen r = extract_first_word(&rvalue, &word, NULL, 0);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen if (r < 0) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Failed to extract capability string, ignoring: %s", rvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return 0;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen }
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen if (r == 0)
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen break;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen cap = capability_from_name(word);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen if (cap < 0) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse capability, ignoring: %s", word);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen continue;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen }
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen u |= 1 << ((uint64_t) cap);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen }
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen if (u == 0)
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return 0;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen *result |= u;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return 0;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen}
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersenint config_parse_id128(
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *unit,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *filename,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen unsigned line,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *section,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen unsigned section_line,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *lvalue,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen int ltype,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *rvalue,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen void *data,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen void *userdata) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen sd_id128_t t, *result = data;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen int r;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(filename);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(lvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(rvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen r = sd_id128_from_string(rvalue, &t);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen if (r < 0) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse 128bit ID/UUID, ignoring: %s", rvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return 0;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen }
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen *result = t;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return 0;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen}
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersenint config_parse_bind(
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *unit,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *filename,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen unsigned line,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *section,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen unsigned section_line,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *lvalue,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen int ltype,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *rvalue,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen void *data,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen void *userdata) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen Settings *settings = data;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen int r;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(filename);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(lvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(rvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen r = bind_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue, ltype);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen if (r < 0) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Invalid bind mount specification %s: %m", rvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return 0;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen }
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return 0;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen}
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersenint config_parse_tmpfs(
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *unit,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *filename,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen unsigned line,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *section,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen unsigned section_line,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *lvalue,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen int ltype,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen const char *rvalue,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen void *data,
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen void *userdata) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen Settings *settings = data;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen int r;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(filename);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(lvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen assert(rvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen r = tmpfs_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen if (r < 0) {
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen log_syntax(unit, LOG_ERR, filename, line, r, "Invalid temporary file system specification %s: %m", rvalue);
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return 0;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen }
52efd56a6369e19c2400a42981a197cd2eef924aLennart Poettering
52efd56a6369e19c2400a42981a197cd2eef924aLennart Poettering if (settings->network_bridge)
52efd56a6369e19c2400a42981a197cd2eef924aLennart Poettering settings->network_veth = true;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
52efd56a6369e19c2400a42981a197cd2eef924aLennart Poettering if (settings->network_interfaces ||
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen settings->network_macvlan ||
52efd56a6369e19c2400a42981a197cd2eef924aLennart Poettering settings->network_ipvlan ||
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen settings->network_bridge ||
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen settings->network_veth)
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen settings->private_network = true;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen return 0;
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen}
23fbe14f503c1e98292efc4ba1238adb7dc38d80Tom Gundersen