netdev->ipv4_gateway = NULL;
netdev->ipv4_gateway_auto = true;
} else {
+ int ret;
struct in_addr *gw;
gw = malloc(sizeof(*gw));
- if (!gw) {
- SYSERROR("failed to allocate ipv4 gateway address");
+ if (!gw)
return -1;
- }
- if (!inet_pton(AF_INET, value, gw)) {
- SYSERROR("invalid ipv4 gateway address: %s", value);
+ ret = inet_pton(AF_INET, value, gw);
+ if (!ret || ret < 0) {
+ SYSERROR("Invalid ipv4 gateway address \"%s\"", value);
free(gw);
return -1;
}
static int set_config_net_ipv6_address(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
+ int ret;
struct lxc_netdev *netdev;
struct lxc_inet6dev *inet6dev;
struct lxc_list *list;
return -1;
inet6dev = malloc(sizeof(*inet6dev));
- if (!inet6dev) {
- SYSERROR("failed to allocate ipv6 address");
+ if (!inet6dev)
return -1;
- }
+
memset(inet6dev, 0, sizeof(*inet6dev));
list = malloc(sizeof(*list));
if (!list) {
- SYSERROR("failed to allocate memory");
free(inet6dev);
return -1;
}
valdup = strdup(value);
if (!valdup) {
- ERROR("no address specified");
free(list);
free(inet6dev);
return -1;
return -1;
}
- if (!inet_pton(AF_INET6, valdup, &inet6dev->addr)) {
- SYSERROR("invalid ipv6 address: %s", valdup);
+ ret = inet_pton(AF_INET6, valdup, &inet6dev->addr);
+ if (!ret || ret < 0) {
+ SYSERROR("Invalid ipv6 address \"%s\"", valdup);
free(list);
free(inet6dev);
free(valdup);
netdev->ipv6_gateway = NULL;
netdev->ipv6_gateway_auto = true;
} else {
+ int ret;
struct in6_addr *gw;
gw = malloc(sizeof(*gw));
- if (!gw) {
- SYSERROR("failed to allocate ipv6 gateway address");
+ if (!gw)
return -1;
- }
- if (!inet_pton(AF_INET6, value, gw)) {
- SYSERROR("invalid ipv6 gateway address: %s", value);
+ ret = inet_pton(AF_INET6, value, gw);
+ if (!ret || ret < 0) {
+ SYSERROR("Invalid ipv6 gateway address \"%s\"", value);
free(gw);
return -1;
}
{
unsigned int init_uid;
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
lxc_conf->init_uid = 0;
return 0;
}
- /* Parse new config value. */
if (lxc_safe_uint(value, &init_uid) < 0)
return -1;
+
lxc_conf->init_uid = init_uid;
return 0;
{
unsigned int init_gid;
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
lxc_conf->init_gid = 0;
return 0;
}
- /* Parse new config value. */
if (lxc_safe_uint(value, &init_gid) < 0)
return -1;
+
lxc_conf->init_gid = init_gid;
return 0;
return lxc_clear_hooks(lxc_conf, key);
if (strcmp(key + 4, "hook") == 0) {
- ERROR("lxc.hook cannot take a value");
+ ERROR("lxc.hook must not have a value");
return -1;
}
+
copy = strdup(value);
- if (!copy) {
- SYSERROR("failed to dup string '%s'", value);
+ if (!copy)
return -1;
- }
if (strcmp(key + 9, "pre-start") == 0)
return add_hook(lxc_conf, LXCHOOK_PRESTART, copy);
else if (strcmp(key + 9, "destroy") == 0)
return add_hook(lxc_conf, LXCHOOK_DESTROY, copy);
- SYSERROR("Unknown key: %s", key);
free(copy);
return -1;
}
if (personality >= 0)
lxc_conf->personality = personality;
else
- WARN("unsupported personality '%s'", value);
+ WARN("Unsupported personality \"%s\"", value);
return 0;
}
static int set_config_pty_max(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
lxc_conf->pts = 0;
return 0;
}
- /* Parse new config value. */
if (lxc_safe_uint(value, &lxc_conf->pts) < 0)
return -1;
is_empty = lxc_config_value_empty(value);
if (*(key + 10) == 'a') { /* lxc.start.auto */
- /* Set config value to default. */
if (is_empty) {
lxc_conf->start_auto = 0;
return 0;
}
- /* Parse new config value. */
if (lxc_safe_uint(value, &lxc_conf->start_auto) < 0)
return -1;
return 0;
} else if (*(key + 10) == 'd') { /* lxc.start.delay */
- /* Set config value to default. */
if (is_empty) {
lxc_conf->start_delay = 0;
return 0;
}
- /* Parse new config value. */
return lxc_safe_uint(value, &lxc_conf->start_delay);
} else if (*(key + 10) == 'o') { /* lxc.start.order */
- /* Set config value to default. */
if (is_empty) {
lxc_conf->start_order = 0;
return 0;
}
- /* Parse new config value. */
return lxc_safe_int(value, &lxc_conf->start_order);
}
- SYSERROR("Unknown key: %s", key);
return -1;
}
static int set_config_monitor(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
lxc_conf->monitor_unshare = 0;
return 0;
}
- /* Parse new config value. */
if (strcmp(key + 12, "unshare") == 0)
return lxc_safe_uint(value, &lxc_conf->monitor_unshare);
- SYSERROR("Unknown key: %s", key);
return -1;
}
return lxc_clear_groups(lxc_conf);
groups = strdup(value);
- if (!groups) {
- SYSERROR("failed to dup '%s'", value);
+ if (!groups)
return -1;
- }
- /* In case several groups are specified in a single line
- * split these groups in a single element for the list.
+ /* In case several groups are specified in a single line split these
+ * groups in a single element for the list.
*/
for (groupptr = groups;; groupptr = NULL) {
token = strtok_r(groupptr, " \t", &sptr);
}
grouplist = malloc(sizeof(*grouplist));
- if (!grouplist) {
- SYSERROR("failed to allocate groups list");
+ if (!grouplist)
break;
- }
grouplist->elem = strdup(token);
if (!grouplist->elem) {
- SYSERROR("failed to dup '%s'", token);
free(grouplist);
break;
}
static int set_config_tty_max(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
lxc_conf->tty = 0;
return 0;
}
- /* Parse new config value. */
return lxc_safe_uint(value, &lxc_conf->tty);
}
struct lxc_conf *lxc_conf,
void *data)
{
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
lxc_conf->lsm_aa_allow_incomplete = 0;
return 0;
}
- /* Parse new config value. */
if (lxc_safe_uint(value, &lxc_conf->lsm_aa_allow_incomplete) < 0)
return -1;
- if (lxc_conf->lsm_aa_allow_incomplete > 1) {
- ERROR("Wrong value for lxc.apparmor.allow_incomplete. Can only "
- "be set to 0 or 1");
+ if (lxc_conf->lsm_aa_allow_incomplete > 1)
return -1;
- }
return 0;
}
ret = set_config_path_item(&c->logfile, value);
if (ret == 0)
ret = lxc_log_set_file(&c->logfd, c->logfile);
+
return ret;
}
{
int newlevel;
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
lxc_conf->loglevel = LXC_LOG_LEVEL_NOTSET;
return 0;
}
- /* Parse new config value. */
if (value[0] >= '0' && value[0] <= '9') {
if (lxc_safe_int(value, &newlevel) < 0)
return -1;
static int set_config_autodev(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
lxc_conf->autodev = 0;
return 0;
}
- /* Parse new config value. */
if (lxc_safe_uint(value, &lxc_conf->autodev) < 0)
return -1;
- if (lxc_conf->autodev > 1) {
- ERROR("Wrong value for lxc.autodev. Can only be set to 0 or 1");
+ if (lxc_conf->autodev > 1)
return -1;
- }
return 0;
}
{
int sig_n;
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
lxc_conf->haltsignal = 0;
return 0;
}
- /* Parse new config value. */
sig_n = sig_parse(value);
-
if (sig_n < 0)
return -1;
+
lxc_conf->haltsignal = sig_n;
return 0;
{
int sig_n;
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
lxc_conf->rebootsignal = 0;
return 0;
}
- /* Parse new config value. */
sig_n = sig_parse(value);
if (sig_n < 0)
return -1;
+
lxc_conf->rebootsignal = sig_n;
return 0;
{
int sig_n;
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
lxc_conf->stopsignal = 0;
return 0;
}
- /* Parse new config value. */
sig_n = sig_parse(value);
if (sig_n < 0)
return -1;
+
lxc_conf->stopsignal = sig_n;
return 0;
out:
free(cglist);
-
if (cgelem) {
free(cgelem->subsystem);
-
free(cgelem->value);
-
free(cgelem);
}
if (ret < 0)
goto on_error;
- INFO("read uid map: type %c nsid %lu hostid %lu range %lu", type, nsid, hostid, range);
+ INFO("Read uid map: type %c nsid %lu hostid %lu range %lu", type, nsid, hostid, range);
if (type == 'u')
idmap->idtype = ID_TYPE_UID;
else if (type == 'g')
{ "cgroup-full:mixed", LXC_AUTO_CGROUP_MASK, LXC_AUTO_CGROUP_FULL_MIXED },
{ "cgroup-full:ro", LXC_AUTO_CGROUP_MASK, LXC_AUTO_CGROUP_FULL_RO },
{ "cgroup-full:rw", LXC_AUTO_CGROUP_MASK, LXC_AUTO_CGROUP_FULL_RW },
- /* NB: For adding anything that is just a single on/off, but has
- * no options: keep mask and flag identical and just define the
- * enum value as an unused bit so far
+ /* For adding anything that is just a single on/off, but has no
+ * options: keep mask and flag identical and just define the enum
+ * value as an unused bit so far
*/
{ NULL, 0, 0 }
};
}
autos = strdup(value);
- if (!autos) {
- SYSERROR("failed to dup '%s'", value);
+ if (!autos)
return -1;
- }
for (autoptr = autos;; autoptr = NULL) {
token = strtok_r(autoptr, " \t", &sptr);
}
if (!allowed_auto_mounts[i].token) {
- ERROR("Invalid filesystem to automount: %s", token);
+ ERROR("Invalid filesystem to automount \"%s\"", token);
break;
}
return lxc_clear_config_keepcaps(lxc_conf);
keepcaps = strdup(value);
- if (!keepcaps) {
- SYSERROR("failed to dup '%s'", value);
+ if (!keepcaps)
return -1;
- }
/* In case several capability keep is specified in a single line
* split these caps in a single element for the list.
lxc_clear_config_keepcaps(lxc_conf);
keeplist = malloc(sizeof(*keeplist));
- if (!keeplist) {
- SYSERROR("failed to allocate keepcap list");
+ if (!keeplist)
break;
- }
keeplist->elem = strdup(token);
if (!keeplist->elem) {
- SYSERROR("failed to dup '%s'", token);
free(keeplist);
break;
}
return lxc_clear_config_caps(lxc_conf);
dropcaps = strdup(value);
- if (!dropcaps) {
- SYSERROR("failed to dup '%s'", value);
+ if (!dropcaps)
return -1;
- }
/* In case several capability drop is specified in a single line
* split these caps in a single element for the list.
}
droplist = malloc(sizeof(*droplist));
- if (!droplist) {
- SYSERROR("failed to allocate drop list");
+ if (!droplist)
break;
- }
droplist->elem = strdup(token);
if (!droplist->elem) {
- SYSERROR("failed to dup '%s'", token);
free(droplist);
break;
}
strcat(conf->unexpanded_config, "\n");
conf->unexpanded_len++;
}
+
return 0;
}
int ret = -1;
dir = opendir(dirp);
- if (!dir) {
- SYSERROR("failed to open '%s'", dirp);
+ if (!dir)
return -1;
- }
while ((direntp = readdir(dir))) {
const char *fnam;
len = strlen(fnam);
if (len < 6 || strncmp(fnam + len - 5, ".conf", 5) != 0)
continue;
+
len = snprintf(path, MAXPATHLEN, "%s/%s", dirp, fnam);
if (len < 0 || len >= MAXPATHLEN) {
- ERROR("lxc.include filename too long under '%s'", dirp);
ret = -1;
goto out;
}
ret = 0;
out:
- if (closedir(dir))
- WARN("lxc.include dir: failed to close directory");
+ closedir(dir);
return ret;
}
static int set_config_includefiles(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
clr_config_includefiles(key, lxc_conf, NULL);
return 0;
}
- /* Parse new config value. */
if (is_dir(value))
return do_includedir(value, lxc_conf);
}
utsname = malloc(sizeof(*utsname));
- if (!utsname) {
- SYSERROR("failed to allocate memory");
+ if (!utsname)
return -1;
- }
if (strlen(value) >= sizeof(utsname->nodename)) {
- ERROR("node name '%s' is too long", value);
free(utsname);
return -1;
}
if (lxc_is_line_empty(buffer))
return 0;
- /* we have to dup the buffer otherwise, at the re-exec for
- * reboot we modified the original string on the stack by
- * replacing '=' by '\0' below
+ /* We have to dup the buffer otherwise, at the re-exec for reboot we
+ * modified the original string on the stack by replacing '=' by '\0'
+ * below.
*/
linep = line = strdup(buffer);
- if (!line) {
- SYSERROR("failed to allocate memory for '%s'", buffer);
+ if (!line)
return -1;
- }
if (!plc->from_include)
if ((ret = append_unexp_config_line(line, plc->conf)))
value[lxc_char_right_gc(value, strlen(value))] = '\0';
if (*value == '\'' || *value == '\"') {
- size_t len = strlen(value);
+ size_t len;
+
+ len = strlen(value);
if (len > 1 && value[len - 1] == *value) {
value[len - 1] = '\0';
value++;
config = lxc_get_config(key);
if (!config) {
- ERROR("unknown key %s", key);
+ ERROR("Unknown configuration key \"%s\"", key);
goto out;
}
int lxc_config_read(const char *file, struct lxc_conf *conf, bool from_include)
{
+ int ret;
struct parse_line_conf c;
c.conf = conf;
c.from_include = from_include;
- if (access(file, R_OK) == -1) {
+ ret = access(file, R_OK);
+ if (ret < 0)
return -1;
- }
- /* Catch only the top level config file name in the structure */
+ /* Catch only the top level config file name in the structure. */
if (!conf->rcfile)
conf->rcfile = strdup(file);
if (!flaglist) {
/* For the sake of backward compatibility, drop all privileges
- * if none is specified.
+ * if none is specified.
*/
- for (i = 0; all_privs[i].token; i++) {
+ for (i = 0; all_privs[i].token; i++)
*flags |= all_privs[i].flag;
- }
+
return 0;
}
token = strtok_r(flaglist, "|", &saveptr);
while (token) {
aflag = -1;
- for (i = 0; all_privs[i].token; i++) {
+ for (i = 0; all_privs[i].token; i++)
if (!strcmp(all_privs[i].token, token))
aflag = all_privs[i].flag;
- }
if (aflag < 0)
return -1;
ret = fwrite(c->unexpanded_config, 1, len, fout);
if (ret != len)
- SYSERROR("Error writing configuration file");
+ SYSERROR("Failed to write configuration file");
}
bool do_append_unexp_config_line(struct lxc_conf *conf, const char *key,
olddir = alloca(olddirlen + 1);
ret = snprintf(olddir, olddirlen + 1, "%s=%s/%s", ovldir, oldpath,
oldname);
- if (ret < 0 || ret >= olddirlen + 1) {
- ERROR("failed to create string");
+ if (ret < 0 || ret >= olddirlen + 1)
return false;
- }
newdirlen = strlen(ovldir) + strlen(newpath) + strlen(newname) + 2;
newdir = alloca(newdirlen + 1);
ret = snprintf(newdir, newdirlen + 1, "%s=%s/%s", ovldir, newpath,
newname);
- if (ret < 0 || ret >= newdirlen + 1) {
- ERROR("failed to create string");
+ if (ret < 0 || ret >= newdirlen + 1)
return false;
- }
if (!conf->unexpanded_config)
return true;
size_t poffset = q - conf->unexpanded_config;
new = realloc(conf->unexpanded_config, newlen + 1);
- if (!new) {
- ERROR("Out of memory");
+ if (!new)
return false;
- }
+
conf->unexpanded_len = newlen;
conf->unexpanded_alloced = newlen + 1;
new[newlen - 1] = '\0';
lend = new + (lend - conf->unexpanded_config);
- /* move over the remainder to make room for the newdir
+ /* Move over the remainder to make room for the newdir.
*/
memmove(new + poffset + newdirlen,
new + poffset + olddirlen,
olddirlen = strlen(oldpath) + strlen(oldname) + 1;
olddir = alloca(olddirlen + 1);
ret = snprintf(olddir, olddirlen + 1, "%s/%s", oldpath, oldname);
- if (ret < 0 || ret >= olddirlen + 1) {
- ERROR("failed to create string");
+ if (ret < 0 || ret >= olddirlen + 1)
return false;
- }
newdirlen = strlen(newpath) + strlen(newname) + 1;
newdir = alloca(newdirlen + 1);
ret = snprintf(newdir, newdirlen + 1, "%s/%s", newpath, newname);
- if (ret < 0 || ret >= newdirlen + 1) {
- ERROR("failed to create string");
+ if (ret < 0 || ret >= newdirlen + 1)
return false;
- }
+
if (!conf->unexpanded_config)
return true;
+
while (*lstart) {
lend = strchr(lstart, '\n');
if (!lend)
size_t poffset = p - conf->unexpanded_config;
new = realloc(conf->unexpanded_config, newlen + 1);
- if (!new) {
- ERROR("failed to allocate memory");
+ if (!new)
return false;
- }
+
conf->unexpanded_len = newlen;
conf->unexpanded_alloced = newlen + 1;
new[newlen - 1] = '\0';
lend = new + (lend - conf->unexpanded_config);
- /* move over the remainder to make room for the newdir
+ /* Move over the remainder to make room for the newdir.
*/
memmove(new + poffset + newdirlen,
new + poffset + olddirlen,
} \
}
-/*
- * This is called only from clone. We wish to update all hwaddrs in the
- * unexpanded config file. We can't/don't want to update any which come from
+/* This is called only from clone. We wish to update all hwaddrs in the
+ * unexpanded config file. We can't/don't want to update any which come from
* lxc.includes (there shouldn't be any).
* We can't just walk the c->lxc-conf->network list because that includes netifs
* from the include files. So we update the ones which we find in the unexp
return false;
memcpy(p, newhwaddr, 17);
- lxc_list_for_each(it, &conf->network)
- {
+ lxc_list_for_each(it, &conf->network) {
struct lxc_netdev *n = it->elem;
+
if (n->hwaddr && memcmp(oldhwaddr, n->hwaddr, 17) == 0)
memcpy(n->hwaddr, newhwaddr, 17);
}
static int set_config_ephemeral(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
lxc_conf->ephemeral = 0;
return 0;
}
- /* Parse new config value. */
if (lxc_safe_uint(value, &lxc_conf->ephemeral) < 0)
return -1;
- if (lxc_conf->ephemeral > 1) {
- ERROR(
- "Wrong value for lxc.ephemeral. Can only be set to 0 or 1");
+ if (lxc_conf->ephemeral > 1)
return -1;
- }
return 0;
}
{
int facility;
- /* Clear any previously set value. */
if (lxc_conf->syslog) {
free(lxc_conf->syslog);
lxc_conf->syslog = NULL;
}
- /* Check if value is empty. */
if (lxc_config_value_empty(value))
return 0;
- /* Parse value. */
facility = lxc_syslog_priority_to_int(value);
- if (facility == -EINVAL) {
- ERROR("Wrong value for lxc.log.syslog.");
+ if (facility == -EINVAL)
return -1;
- }
lxc_log_syslog(facility);
return set_config_string_item(&lxc_conf->syslog, value);
{
unsigned int v;
- /* Set config value to default. */
if (lxc_config_value_empty(value)) {
lxc_conf->no_new_privs = false;
return 0;
}
- /* Parse new config value. */
if (lxc_safe_uint(value, &v) < 0)
return -1;
- if (v > 1) {
- ERROR("Wrong value for lxc.no_new_privs. Can only be set to 0 "
- "or 1");
+ if (v > 1)
return -1;
- }
lxc_conf->no_new_privs = v ? true : false;
return lxc_get_conf_str(retv, inlen, c->lsm_se_context);
}
-/*
- * If you ask for a specific cgroup value, i.e. lxc.cgroup.devices.list,
- * then just the value(s) will be printed. Since there still could be
- * more than one, it is newline-separated.
- * (Maybe that's ambigous, since some values, i.e. devices.list, will
- * already have newlines?)
- * If you ask for 'lxc.cgroup", then all cgroup entries will be printed,
- * in 'lxc.cgroup.subsystem.key = value' format.
+/* If you ask for a specific cgroup value, i.e. lxc.cgroup.devices.list, then
+ * just the value(s) will be printed. Since there still could be more than one,
+ * it is newline-separated.
+ * (Maybe that's ambigous, since some values, i.e. devices.list, will already
+ * have newlines?)
+ * If you ask for 'lxc.cgroup", then all cgroup entries will be printed, in
+ * 'lxc.cgroup.subsystem.key = value' format.
*/
static int get_config_cgroup(const char *key, char *retv, int inlen,
struct lxc_conf *c, void *data)
lxc_list_for_each(it, &c->cgroup) {
struct lxc_cgroup *cg = it->elem;
+
if (get_all) {
- strprint(retv, inlen, "lxc.cgroup.%s = %s\n", cg->subsystem, cg->value);
+ strprint(retv, inlen, "lxc.cgroup.%s = %s\n",
+ cg->subsystem, cg->value);
} else if (!strcmp(cg->subsystem, key)) {
strprint(retv, inlen, "%s\n", cg->value);
}
else
memset(retv, 0, inlen);
- lxc_list_for_each(it, &c->mount_list)
- {
+ lxc_list_for_each(it, &c->mount_list) {
strprint(retv, inlen, "%s\n", (char *)it->elem);
}
struct lxc_list *it;
int i;
- /* "lxc.hook.mount" */
subkey = strchr(key, '.');
if (subkey)
subkey = strchr(subkey + 1, '.');
lxc_list_for_each(it, &c->caps) {
strprint(retv, inlen, "%s\n", (char *)it->elem);
}
+
return fulllen;
}
lxc_list_for_each(it, &c->keepcaps) {
strprint(retv, inlen, "%s\n", (char *)it->elem);
}
+
return fulllen;
}
}
static int get_config_signal_halt(const char *key, char *retv, int inlen,
- struct lxc_conf *c, void *data)
+ struct lxc_conf *c, void *data)
{
return lxc_get_conf_int(c, retv, inlen, c->haltsignal);
}
static int get_config_signal_reboot(const char *key, char *retv, int inlen,
- struct lxc_conf *c, void *data)
+ struct lxc_conf *c, void *data)
{
return lxc_get_conf_int(c, retv, inlen, c->rebootsignal);
}
static int get_config_signal_stop(const char *key, char *retv, int inlen,
- struct lxc_conf *c, void *data)
+ struct lxc_conf *c, void *data)
{
return lxc_get_conf_int(c, retv, inlen, c->stopsignal);
}
}
static int get_config_log_syslog(const char *key, char *retv, int inlen,
- struct lxc_conf *c, void *data)
+ struct lxc_conf *c, void *data)
{
return lxc_get_conf_str(retv, inlen, c->syslog);
}
lxc_list_for_each(it, &c->groups) {
strprint(retv, inlen, "%s\n", (char *)it->elem);
}
+
return fulllen;
}
lxc_list_for_each(it, &c->environment) {
strprint(retv, inlen, "%s\n", (char *)it->elem);
}
+
return fulllen;
}
return lxc_get_conf_int(c, retv, inlen, c->no_new_privs);
}
-/*
- * If you ask for a specific value, i.e. lxc.prlimit.nofile, then just the value
+/* If you ask for a specific value, i.e. lxc.prlimit.nofile, then just the value
* will be printed. If you ask for 'lxc.prlimit', then all limit entries will be
* printed, in 'lxc.prlimit.resource = value' format.
*/
(uint64_t)lim->limit.rlim_cur);
}
if (lim->limit.rlim_cur != lim->limit.rlim_max) {
- if (lim->limit.rlim_max == RLIM_INFINITY) {
+ if (lim->limit.rlim_max == RLIM_INFINITY)
memcpy(buf + partlen, ":unlimited",
sizeof(":unlimited"));
- } else {
+ else
sprintf(buf + partlen, ":%" PRIu64,
(uint64_t)lim->limit.rlim_max);
- }
}
if (get_all) {
strprint(retv, inlen, "lxc.prlimit.%s = %s\n",
lim->resource, buf);
- } else if (strcmp(lim->resource, key) == 0) {
+ } else if (!strcmp(lim->resource, key)) {
strprint(retv, inlen, "%s", buf);
}
}
* (Checking for INT_MAX here is intentional.)
*/
if (tmpidx == INT_MAX) {
- SYSERROR("number of configured networks would overflow the "
- "counter... what are you doing?");
+ SYSERROR("Number of configured networks would overflow the "
+ "counter");
goto on_error;
}
*idx = tmpidx;
config = lxc_get_config(copy);
if (!config) {
- ERROR("unknown network configuration key %s", key);
+ ERROR("Unknown network configuration key \"%s\"", key);
goto on_error;
}
}
return NULL;
}
-/*
- * Config entry is something like "lxc.net.0.ipv4" the key 'lxc.net.'
- * was found. So we make sure next comes an integer, find the right callback
- * (by rewriting the key), and call it.
+/* Config entry is something like "lxc.net.0.ipv4" the key 'lxc.net.' was
+ * found. So we make sure next comes an integer, find the right callback (by
+ * rewriting the key), and call it.
*/
static int set_config_net_nic(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
return ret;
}
-/*
- * Config entry is something like "lxc.net.0.ipv4" the key 'lxc.net.'
- * was found. So we make sure next comes an integer, find the right callback
- * (by rewriting the key), and call it.
- */
static int clr_config_net_nic(const char *key, struct lxc_conf *lxc_conf,
void *data)
{