Skip to content

Commit

Permalink
lxccontainer: do_create_container_dir()
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Aug 23, 2018
1 parent 9a007b4 commit f9bd234
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/lxc/lxccontainer.c
Expand Up @@ -1128,26 +1128,32 @@ WRAP_API(bool, lxcapi_stop)

static int do_create_container_dir(const char *path, struct lxc_conf *conf)
{
int ret = -1, lasterr;
char *p = alloca(strlen(path)+1);
int lasterr;
size_t len;
char *p;
int ret = -1;

mode_t mask = umask(0002);
ret = mkdir(path, 0770);
lasterr = errno;
umask(mask);
errno = lasterr;
if (ret) {
if (errno == EEXIST)
ret = 0;
else {
SYSERROR("failed to create container path %s", path);
if (errno != EEXIST)
return -1;
}

ret = 0;
}

len = strlen(path);
p = alloca(len + 1);
strcpy(p, path);
if (!lxc_list_empty(&conf->id_map) && chown_mapped_root(p, conf) != 0) {
ERROR("Failed to chown container dir");
ret = -1;
if (!lxc_list_empty(&conf->id_map)) {
ret = chown_mapped_root(p, conf);
if (ret < 0)
ret = -1;
}

return ret;
}

Expand Down

0 comments on commit f9bd234

Please sign in to comment.