mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-14 01:39:59 +00:00
Merge pull request #2353 from brauner/2018-05-25/fix_lxc_create
tools: fix lxc-create with global config value II
This commit is contained in:
commit
85f839ccb1
@ -1284,7 +1284,6 @@ static inline bool cgfsng_create(struct cgroup_ops *ops,
|
|||||||
char *container_cgroup, *offset, *tmp;
|
char *container_cgroup, *offset, *tmp;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
struct lxc_conf *conf = handler->conf;
|
struct lxc_conf *conf = handler->conf;
|
||||||
const char *join_args[] = {conf->cgroup_meta.dir, handler->name, NULL};
|
|
||||||
|
|
||||||
if (ops->container_cgroup) {
|
if (ops->container_cgroup) {
|
||||||
WARN("cgfsng_create called a second time: %s", 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;
|
return false;
|
||||||
|
|
||||||
if (conf->cgroup_meta.dir)
|
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
|
else
|
||||||
tmp = lxc_string_replace("%n", handler->name, ops->cgroup_pattern);
|
tmp = lxc_string_replace("%n", handler->name, ops->cgroup_pattern);
|
||||||
if (!tmp) {
|
if (!tmp) {
|
||||||
|
@ -1971,11 +1971,8 @@ static bool do_lxcapi_reboot2(struct lxc_container *c, int timeout)
|
|||||||
}
|
}
|
||||||
TRACE("Sent signal %d to pid %d", rebootsignal, pid);
|
TRACE("Sent signal %d to pid %d", rebootsignal, pid);
|
||||||
|
|
||||||
if (timeout == 0) {
|
if (timeout == 0)
|
||||||
if (state_client_fd >= 0)
|
|
||||||
close(state_client_fd);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
ret = lxc_cmd_sock_rcv_state(state_client_fd, timeout);
|
ret = lxc_cmd_sock_rcv_state(state_client_fd, timeout);
|
||||||
close(state_client_fd);
|
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);
|
TRACE("Sent signal %d to pid %d", haltsignal, pid);
|
||||||
|
|
||||||
if (timeout == 0) {
|
if (timeout == 0)
|
||||||
if (state_client_fd >= 0)
|
|
||||||
close(state_client_fd);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
ret = lxc_cmd_sock_rcv_state(state_client_fd, timeout);
|
ret = lxc_cmd_sock_rcv_state(state_client_fd, timeout);
|
||||||
close(state_client_fd);
|
close(state_client_fd);
|
||||||
|
@ -861,11 +861,11 @@ int lxc_init(const char *name, struct lxc_handler *handler)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_restore_sigmask:
|
out_restore_sigmask:
|
||||||
pthread_sigmask(SIG_SETMASK, &handler->oldmask, NULL);
|
(void)pthread_sigmask(SIG_SETMASK, &handler->oldmask, NULL);
|
||||||
out_delete_tty:
|
out_delete_tty:
|
||||||
lxc_delete_tty(&conf->ttys);
|
lxc_delete_tty(&conf->ttys);
|
||||||
out_aborting:
|
out_aborting:
|
||||||
lxc_set_state(name, handler, ABORTING);
|
(void)lxc_set_state(name, handler, ABORTING);
|
||||||
out_close_maincmd_fd:
|
out_close_maincmd_fd:
|
||||||
close(conf->maincmd_fd);
|
close(conf->maincmd_fd);
|
||||||
conf->maincmd_fd = -1;
|
conf->maincmd_fd = -1;
|
||||||
|
@ -267,24 +267,19 @@ int main(int argc, char *argv[])
|
|||||||
exit(EXIT_FAILURE);
|
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))
|
if (!my_args.lxcpath[0])
|
||||||
exit(EXIT_FAILURE);
|
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) {
|
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);
|
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]);
|
c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
|
||||||
if (!c) {
|
if (!c) {
|
||||||
|
Loading…
Reference in New Issue
Block a user