Skip to content

Commit

Permalink
Merge pull request #3595 from brauner/2020-12-08/fixes
Browse files Browse the repository at this point in the history
tree-wide: fixes
  • Loading branch information
stgraber committed Dec 10, 2020
2 parents 0c9621b + c3e4896 commit 3aa3407
Show file tree
Hide file tree
Showing 15 changed files with 806 additions and 1,059 deletions.
3 changes: 0 additions & 3 deletions src/lxc/cgroups/cgfsng.c
Expand Up @@ -2749,9 +2749,6 @@ static int device_cgroup_rule_parse_devpath(struct device_item *device,
if (device_cgroup_parse_access(device, mode) < 0)
return -1;

if (n_parts == 1)
return ret_set_errno(-1, EINVAL);

ret = stat(path, &sb);
if (ret < 0)
return ret_set_errno(-1, errno);
Expand Down
2 changes: 1 addition & 1 deletion src/lxc/cmd/lxc_init.c
Expand Up @@ -479,7 +479,7 @@ int main(int argc, char *argv[])
break;
}
default:
ret = kill(pid, was_interrupted);
kill(pid, was_interrupted);
break;
}
ret = EXIT_SUCCESS;
Expand Down
4 changes: 3 additions & 1 deletion src/lxc/conf.c
Expand Up @@ -1201,7 +1201,9 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
}

/* Fallback to bind-mounting the device from the host. */
snprintf(hostpath, sizeof(hostpath), "/dev/%s", device->name);
ret = snprintf(hostpath, sizeof(hostpath), "/dev/%s", device->name);
if (ret < 0 || (size_t)ret >= sizeof(hostpath))
return ret_errno(EIO);

ret = safe_mount_beneath_at(dev_dir_fd, hostpath, device->name, NULL, MS_BIND, NULL);
if (ret < 0) {
Expand Down
40 changes: 40 additions & 0 deletions src/lxc/conf.h
Expand Up @@ -19,6 +19,7 @@
#include "config.h"
#include "list.h"
#include "lxcseccomp.h"
#include "memory_utils.h"
#include "ringbuf.h"
#include "start.h"
#include "terminal.h"
Expand Down Expand Up @@ -69,6 +70,16 @@ struct lxc_cgroup {
};
};

static void free_lxc_cgroup(struct lxc_cgroup *ptr)
{
if (ptr) {
free(ptr->subsystem);
free(ptr->value);
free_disarm(ptr);
}
}
define_cleanup_function(struct lxc_cgroup *, free_lxc_cgroup);

#if !HAVE_SYS_RESOURCE_H
#define RLIM_INFINITY ((unsigned long)-1)
struct rlimit {
Expand All @@ -87,6 +98,15 @@ struct lxc_limit {
struct rlimit limit;
};

static void free_lxc_limit(struct lxc_limit *ptr)
{
if (ptr) {
free(ptr->resource);
free_disarm(ptr);
}
}
define_cleanup_function(struct lxc_limit *, free_lxc_limit);

enum idtype {
ID_TYPE_UID,
ID_TYPE_GID
Expand All @@ -102,6 +122,16 @@ struct lxc_sysctl {
char *value;
};

static void free_lxc_sysctl(struct lxc_sysctl *ptr)
{
if (ptr) {
free(ptr->key);
free(ptr->value);
free_disarm(ptr);
}
}
define_cleanup_function(struct lxc_sysctl *, free_lxc_sysctl);

/*
* Defines a structure to configure proc filesystem at runtime.
* @filename : the proc filesystem will be configured without the "lxc.proc" prefix
Expand All @@ -112,6 +142,16 @@ struct lxc_proc {
char *value;
};

static void free_lxc_proc(struct lxc_proc *ptr)
{
if (ptr) {
free(ptr->filename);
free(ptr->value);
free_disarm(ptr);
}
}
define_cleanup_function(struct lxc_proc *, free_lxc_proc);

/*
* id_map is an id map entry. Form in confile is:
* lxc.idmap = u 0 9800 100
Expand Down

0 comments on commit 3aa3407

Please sign in to comment.