lxccontainer: do_create_container_dir()

parent 9f52e331
...@@ -1159,26 +1159,32 @@ WRAP_API(bool, lxcapi_stop) ...@@ -1159,26 +1159,32 @@ WRAP_API(bool, lxcapi_stop)
static int do_create_container_dir(const char *path, struct lxc_conf *conf) static int do_create_container_dir(const char *path, struct lxc_conf *conf)
{ {
int ret = -1, lasterr; int lasterr;
char *p = alloca(strlen(path)+1); size_t len;
char *p;
int ret = -1;
mode_t mask = umask(0002); mode_t mask = umask(0002);
ret = mkdir(path, 0770); ret = mkdir(path, 0770);
lasterr = errno; lasterr = errno;
umask(mask); umask(mask);
errno = lasterr; errno = lasterr;
if (ret) { if (ret) {
if (errno == EEXIST) if (errno != EEXIST)
ret = 0;
else {
SYSERROR("failed to create container path %s", path);
return -1; return -1;
ret = 0;
} }
}
len = strlen(path);
p = alloca(len + 1);
strcpy(p, path); strcpy(p, path);
if (!lxc_list_empty(&conf->id_map) && chown_mapped_root(p, conf) != 0) { if (!lxc_list_empty(&conf->id_map)) {
ERROR("Failed to chown container dir"); ret = chown_mapped_root(p, conf);
if (ret < 0)
ret = -1; ret = -1;
} }
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment