confile.c revision a16f71a1d10ba626eb87297b0391b03b54de76e9
892bd61e0fcc788390abfadd32b1897943290879dlezcano * lxc: linux Container library
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano * (C) Copyright IBM Corp. 2007, 2008
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano * Daniel Lezcano <daniel.lezcano at free.fr>
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano * This library is free software; you can redistribute it and/or
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano * modify it under the terms of the GNU Lesser General Public
b0a33c1eb65d2c87e886c740a0dadd8ad5f8d87ddlezcano * License as published by the Free Software Foundation; either
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano * version 2.1 of the License, or (at your option) any later version.
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano * This library is distributed in the hope that it will be useful,
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano * but WITHOUT ANY WARRANTY; without even the implied warranty of
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b0e505c974ff7b018350f99f32199a52e18ed55bdlezcano * Lesser General Public License for more details.
8a67a2b2eaf28033962a432c214bd3303c29c54cdlezcano * You should have received a copy of the GNU Lesser General Public
8b8b04f80adf21480c25deb1aae263049ddd6754dlezcano * License along with this library; if not, write to the Free Software
8b8b04f80adf21480c25deb1aae263049ddd6754dlezcano * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <time.h>
#include <dirent.h>
#include "parse.h"
#include "config.h"
#include "confile.h"
#include "utils.h"
#include "log.h"
#include "conf.h"
#include "network.h"
#include "lxcseccomp.h"
struct signame {
int num;
const char *name;
for (i = 0; i < config_size; i++)
return &config[i];
return NULL;
if (inlen > 0) { \
if (!retv)
inlen = 0;
for (i = 0; i < config_size; i++) {
return fulllen;
char *new_value;
if (!new_value) {
if (!copy) {
goto out;
goto out;
if (!config) {
goto out;
out:
return ret;
if (!netdev) {
if (!list) {
return idx;
return NULL;
if (idx == i++) {
return netdev;
if (!netdev)
if (!retv)
inlen = 0;
case LXC_NET_VETH:
case LXC_NET_MACVLAN:
case LXC_NET_VLAN:
case LXC_NET_PHYS:
return fulllen;
return NULL;
if (!netdev) {
return NULL;
return netdev;
#ifndef MACVLAN_MODE_PRIVATE
#ifndef MACVLAN_MODE_VEPA
#ifndef MACVLAN_MODE_BRIDGE
struct mc_mode {
char *name;
int mode;
#ifndef HAVE_RAND_R
randseed(true);
#ifdef HAVE_RAND_R
curs++;
if (!netdev)
if (!netdev)
if (!netdev)
if (!netdev)
if (!netdev)
if (!new_value) {
if (!netdev) {
if (!netdev)
if (!netdev)
if (!netdev)
if (!inetdev) {
if (!list) {
if (!addr) {
if (cursor) {
if (slash) {
if (!bcast) {
if (!netdev)
if (!gw) {
char *netmask;
if (!netdev)
if (!inet6dev) {
if (!list) {
if (!valdup) {
if (slash) {
if (!netdev)
if (!gw) {
if (!netdev)
if (!netdev)
if (!hooklist) {
char *copy;
if (!copy) {
if (personality >= 0)
if (!groups) {
if (!token) {
ret = 0;
if (!grouplist) {
return ret;
if (!list_item)
goto freak_out;
goto freak_out;
int ret;
if (ret == 0)
return ret;
int newlevel;
errno = 0;
int sig_n = 0;
int rtmax = 0;
return sig_n;
if (sig_n < 0)
if (sig_n < 0)
if (sig_n < 0)
char *subkey;
if (!subkey)
if (!cglist)
goto out;
if (!cgelem)
goto out;
goto out;
out:
if (cgelem) {
char *subkey;
char type;
int ret;
if (!subkey)
if (!idmaplist)
goto out;
if (!idmap)
goto out;
goto out;
goto out;
out:
if (idmap) {
{ NULL, 0 }
if (!autos) {
if (!token) {
ret = 0;
return ret;
char *subkey;
char *mntelem;
if (!subkey) {
if (!subkey) {
if (!subkey)
if (!mntlist)
if (!mntelem) {
if (!keepcaps) {
if (!token) {
ret = 0;
if (!keeplist) {
return ret;
if (!dropcaps) {
if (!token) {
ret = 0;
if (!droplist) {
return ret;
* If we find a lxc.network.hwaddr in the original config file,
while (isblank(*p))
if (!tmp)
if (!dir) {
const char *fnam;
if (!direntp)
goto out;
if (ret < 0)
goto out;
ret = 0;
out:
return ret;
if (!utsname) {
value);
struct parse_line_conf {
bool from_include;
char *dot;
char *key;
char *value;
int ret = 0;
if (!line) {
goto out;
goto out;
goto out;
if (!dot) {
goto out;
if (!config) {
goto out;
out:
return ret;
struct parse_line_conf c;
c.from_include = false;
struct parse_line_conf c;
if (!dent)
int ret = 0;
if (ret)
return ret;
struct per_name {
char *name;
unsigned long per;
} pername[] = {
for (i = 0; i < len; i++) {
int i, aflag;
{ NULL, 0 }
if (!flaglist) {
while (token) {
if (aflag < 0)
if (!retv)
inlen = 0;
int fulllen = 0;
if (!retv)
inlen = 0;
int len = 0;
switch(c->personality) {
return fulllen;
* If you ask for a specific cgroup value, i.e. lxc.cgroup.devices.list,
* If you ask for 'lxc.cgroup", then all cgroup entries will be printed,
* in 'lxc.cgroup.subsystem.key = value' format.
const char *key)
int all = 0;
if (!retv)
inlen = 0;
if (all) {
return fulllen;
const char *key)
char *subkey;
/* "lxc.hook.mount" */
if (!subkey)
subkey++;
if (!*subkey)
for (i=0; i<NUM_LXC_HOOKS; i++) {
found=i;
if (!retv)
inlen = 0;
return fulllen;
if (!retv)
inlen = 0;
return fulllen;
if (!retv)
inlen = 0;
return fulllen;
if (!retv)
inlen = 0;
return fulllen;
if (!retv)
inlen = 0;
return fulllen;
if (!retv)
inlen = 0;
return fulllen;
if (!retv)
inlen = 0;
case LXC_AUTO_CGROUP_FULL_MIXED: strprint(retv, inlen, "%scgroup-full:mixed", sep); sep = " "; break;
return fulllen;
const char *key)
char *p1;
if (!retv)
inlen = 0;
p1++;
if (!netdev)
const char *mode;
return fulllen;
if (!retv)
inlen = 0;
return fulllen;
int inlen)
const char *v = NULL;
v = c->fstab;
v = c->ttydir;
v = c->lsm_aa_profile;
v = c->lsm_se_context;
v = lxc_log_get_file();
v = c->seccomp;
v = c->init_cmd;
return strlen(v);
return lxc_clear_config_network(c);
return lxc_clear_config_caps(c);
return lxc_clear_config_keepcaps(c);
return lxc_clear_mount_entries(c);
return lxc_clear_automounts(c);
return lxc_clear_groups(c);
return lxc_clear_environment(c);
return lxc_clear_idmaps(c);
int ret;
if (!len)
int ret;
while (*lstart) {
if (!lend)
lend++;
if (!rm_subkeys) {
int ret;
while (*lstart) {
if (!lend)
lend++;
while (isblank(*p))
char *new;
if (!new) {
if (!(cmd)) { \
FILE *f;
unsigned int seed;
fclose(f);
while (*lstart) {
if (!lend)
lend++;
while (isblank(*p))
p2 = p;
p2++;