diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 544772c61..e7948b25b 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -1284,7 +1284,6 @@ static inline bool cgfsng_create(struct cgroup_ops *ops, char *container_cgroup, *offset, *tmp; int idx = 0; struct lxc_conf *conf = handler->conf; - const char *join_args[] = {conf->cgroup_meta.dir, handler->name, NULL}; if (ops->container_cgroup) { WARN("cgfsng_create called a second time: %s", ops->container_cgroup); @@ -1295,7 +1294,7 @@ static inline bool cgfsng_create(struct cgroup_ops *ops, return false; if (conf->cgroup_meta.dir) - tmp = lxc_string_join("/", join_args, false); + tmp = lxc_string_join("/", (const char *[]){conf->cgroup_meta.dir, handler->name, NULL}, false); else tmp = lxc_string_replace("%n", handler->name, ops->cgroup_pattern); if (!tmp) { diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 2a8066767..828ebb8e5 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -1971,11 +1971,8 @@ static bool do_lxcapi_reboot2(struct lxc_container *c, int timeout) } TRACE("Sent signal %d to pid %d", rebootsignal, pid); - if (timeout == 0) { - if (state_client_fd >= 0) - close(state_client_fd); + if (timeout == 0) return true; - } ret = lxc_cmd_sock_rcv_state(state_client_fd, timeout); close(state_client_fd); @@ -2044,11 +2041,8 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout) } TRACE("Sent signal %d to pid %d", haltsignal, pid); - if (timeout == 0) { - if (state_client_fd >= 0) - close(state_client_fd); + if (timeout == 0) return true; - } ret = lxc_cmd_sock_rcv_state(state_client_fd, timeout); close(state_client_fd); diff --git a/src/lxc/start.c b/src/lxc/start.c index 638e195d6..94abff377 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -861,11 +861,11 @@ int lxc_init(const char *name, struct lxc_handler *handler) return 0; out_restore_sigmask: - pthread_sigmask(SIG_SETMASK, &handler->oldmask, NULL); + (void)pthread_sigmask(SIG_SETMASK, &handler->oldmask, NULL); out_delete_tty: lxc_delete_tty(&conf->ttys); out_aborting: - lxc_set_state(name, handler, ABORTING); + (void)lxc_set_state(name, handler, ABORTING); out_close_maincmd_fd: close(conf->maincmd_fd); conf->maincmd_fd = -1; diff --git a/src/lxc/tools/lxc_create.c b/src/lxc/tools/lxc_create.c index dba252112..3dd2e01b8 100644 --- a/src/lxc/tools/lxc_create.c +++ b/src/lxc/tools/lxc_create.c @@ -267,24 +267,19 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - if (geteuid()) { - if (!my_args.lxcpath[0]) - my_args.lxcpath[0] = lxc_get_global_config_item("lxc.lxcpath"); - if (mkdir_p(my_args.lxcpath[0], 0755)) - exit(EXIT_FAILURE); + if (!my_args.lxcpath[0]) + my_args.lxcpath[0] = lxc_get_global_config_item("lxc.lxcpath"); + if (mkdir_p(my_args.lxcpath[0], 0755)) + exit(EXIT_FAILURE); + + if (geteuid()) if (access(my_args.lxcpath[0], O_RDONLY) < 0) { - fprintf(stderr, "You lack access to %s\n", my_args.lxcpath[0]); + fprintf(stderr, "You lack access to %s\n", + my_args.lxcpath[0]); exit(EXIT_FAILURE); } - if (strcmp(my_args.bdevtype, "dir") && strcmp(my_args.bdevtype, "_unset") && - strcmp(my_args.bdevtype, "btrfs")) { - fprintf(stderr, "Unprivileged users cannot create %s containers.\n", my_args.bdevtype); - exit(EXIT_FAILURE); - } - } - c = lxc_container_new(my_args.name, my_args.lxcpath[0]); if (!c) {