From dcd14ae6b4027be26acfc1d5c7701e3a8bcc54a5 Mon Sep 17 00:00:00 2001 From: lifeng Date: Fri, 24 Apr 2020 15:41:00 +0800 Subject: [PATCH] 4.24: sync with upstream stable-2.0.0 Signed-off-by: lifeng --- lcr.spec | 2 +- src/conf.c | 19 ------------------- src/lcrcontainer.h | 3 +++ src/lcrcontainer_execute.c | 9 +++++++++ 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/lcr.spec b/lcr.spec index d11c58b..976dd8f 100644 --- a/lcr.spec +++ b/lcr.spec @@ -1,5 +1,5 @@ %global _version 2.0.0 -%global _release 20200318.003237.gitcdd4f8ab +%global _release 20200418.180709.gitaabdb4e4 Name: lcr Version: %{_version} Release: %{_release} diff --git a/src/conf.c b/src/conf.c index 28e63f5..cbfba1b 100644 --- a/src/conf.c +++ b/src/conf.c @@ -2550,22 +2550,6 @@ static int add_needed_pty_conf(struct lcr_list *conf) return 0; } -static int add_needed_tty_conf(struct lcr_list *conf) -{ - struct lcr_list *node = create_lcr_list_node("lxc.tty.max", "4"); - if (node == NULL) { - return -1; - } - lcr_list_add_tail(conf, node); - - node = create_lcr_list_node("lxc.tty.dir", "lxc"); - if (node == NULL) { - return -1; - } - lcr_list_add_tail(conf, node); - return 0; -} - static int add_needed_net_conf(struct lcr_list *conf) { struct lcr_list *node = create_lcr_list_node("lxc.net.0.type", "empty"); @@ -2591,9 +2575,6 @@ struct lcr_list *get_needed_lxc_conf() } lcr_list_init(conf); - if (add_needed_tty_conf(conf) < 0) { - goto out_free; - } if (add_needed_pty_conf(conf) < 0) { goto out_free; } diff --git a/src/lcrcontainer.h b/src/lcrcontainer.h index f747339..fba0761 100644 --- a/src/lcrcontainer.h +++ b/src/lcrcontainer.h @@ -271,6 +271,9 @@ struct lcr_exec_request { int64_t timeout; const char *suffix; + + bool tty; + bool open_stdin; }; /* * Execute process inside a container diff --git a/src/lcrcontainer_execute.c b/src/lcrcontainer_execute.c index ac808e4..cf00008 100644 --- a/src/lcrcontainer_execute.c +++ b/src/lcrcontainer_execute.c @@ -571,10 +571,12 @@ static void execute_lxc_attach(const char *name, const char *path, const struct add_array_elem(params, args_len, &i, "-P"); add_array_elem(params, args_len, &i, path); add_array_elem(params, args_len, &i, "--clear-env"); + add_array_elem(params, args_len, &i, "--quiet"); add_array_kv(params, args_len, &i, "--logfile", request->logpath); add_array_kv(params, args_len, &i, "-l", request->loglevel); add_array_kv(params, args_len, &i, "--in-fifo", request->console_fifos[0]); add_array_kv(params, args_len, &i, "--out-fifo", request->console_fifos[1]); + add_array_kv(params, args_len, &i, "--err-fifo", request->console_fifos[2]); for (j = 0; j < request->env_len; j++) { add_array_elem(params, args_len, &i, "-v"); add_array_elem(params, args_len, &i, request->env[j]); @@ -599,6 +601,13 @@ static void execute_lxc_attach(const char *name, const char *path, const struct add_array_kv(params, args_len, &i, "--suffix", request->suffix); + if (!request->tty) { + add_array_elem(params, args_len, &i, "--disable-pty"); + } + if (request->open_stdin) { + add_array_elem(params, args_len, &i, "--open-stdin"); + } + add_array_elem(params, args_len, &i, "--"); for (j = 0; j < request->args_len; j++) { add_array_elem(params, args_len, &i, request->args[j]);