commit
22c63686b9
@ -1,11 +1,11 @@
|
|||||||
cmake_minimum_required (VERSION 3.12.1)
|
cmake_minimum_required (VERSION 2.8)
|
||||||
project (lcr)
|
project (lcr)
|
||||||
|
|
||||||
include(cmake/set_build_flags.cmake)
|
include(cmake/set_build_flags.cmake)
|
||||||
|
|
||||||
option(VERSION "set lcr version" ON)
|
option(VERSION "set lcr version" ON)
|
||||||
if (VERSION STREQUAL "ON")
|
if (VERSION STREQUAL "ON")
|
||||||
set(LCR_VERSION "1.0.17")
|
set(LCR_VERSION "1.0.18")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(DEBUG "set lcr gcc option" ON)
|
option(DEBUG "set lcr gcc option" ON)
|
||||||
|
|||||||
4
lcr.spec
4
lcr.spec
@ -1,5 +1,5 @@
|
|||||||
%global _version 1.0.17
|
%global _version 1.0.18
|
||||||
%global _release 20191222.223702.gita44996d6
|
%global _release 20200105.223545.git6259bd3e
|
||||||
Name: lcr
|
Name: lcr
|
||||||
Version: %{_version}
|
Version: %{_version}
|
||||||
Release: %{_release}
|
Release: %{_release}
|
||||||
|
|||||||
@ -1592,6 +1592,106 @@ out:
|
|||||||
return bret;
|
return bret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lcr_resize(const char *name, const char *lcrpath, unsigned int height, unsigned int width)
|
||||||
|
{
|
||||||
|
struct lxc_container *c = NULL;
|
||||||
|
const char *tmp_path = lcrpath ? lcrpath : LCRPATH;
|
||||||
|
bool bret = true;
|
||||||
|
|
||||||
|
clear_error_message(&g_lcr_error);
|
||||||
|
|
||||||
|
if (name == NULL) {
|
||||||
|
ERROR("Missing container name");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
engine_set_log_prefix(name);
|
||||||
|
c = lxc_container_new(name, tmp_path);
|
||||||
|
if (c == NULL) {
|
||||||
|
ERROR("Failed to pause container");
|
||||||
|
engine_free_log_prefix();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_container_exists(c)) {
|
||||||
|
ERROR("No such container");
|
||||||
|
bret = false;
|
||||||
|
goto out_put;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_container_can_control(c)) {
|
||||||
|
ERROR("Insufficent privleges to contol");
|
||||||
|
bret = false;
|
||||||
|
goto out_put;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lcr_check_container_running(c, name)) {
|
||||||
|
bret = false;
|
||||||
|
goto out_put;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!c->set_terminal_winch(c, height, width)) {
|
||||||
|
ERROR("Failed to pause");
|
||||||
|
bret = false;
|
||||||
|
goto out_put;
|
||||||
|
}
|
||||||
|
|
||||||
|
out_put:
|
||||||
|
lxc_container_put(c);
|
||||||
|
engine_free_log_prefix();
|
||||||
|
return bret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool lcr_exec_resize(const char *name, const char *lcrpath, const char *suffix, unsigned int height, unsigned int width)
|
||||||
|
{
|
||||||
|
struct lxc_container *c = NULL;
|
||||||
|
const char *tmp_path = lcrpath ? lcrpath : LCRPATH;
|
||||||
|
bool bret = true;
|
||||||
|
|
||||||
|
clear_error_message(&g_lcr_error);
|
||||||
|
|
||||||
|
if (name == NULL) {
|
||||||
|
ERROR("Missing container name");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
engine_set_log_prefix(name);
|
||||||
|
c = lxc_container_new(name, tmp_path);
|
||||||
|
if (c == NULL) {
|
||||||
|
ERROR("Failed to pause container");
|
||||||
|
engine_free_log_prefix();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_container_exists(c)) {
|
||||||
|
ERROR("No such container");
|
||||||
|
bret = false;
|
||||||
|
goto out_put;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_container_can_control(c)) {
|
||||||
|
ERROR("Insufficent privleges to contol");
|
||||||
|
bret = false;
|
||||||
|
goto out_put;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lcr_check_container_running(c, name)) {
|
||||||
|
bret = false;
|
||||||
|
goto out_put;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!c->set_exec_terminal_winch(c, suffix, height, width)) {
|
||||||
|
ERROR("Failed to resize exec terminal");
|
||||||
|
bret = false;
|
||||||
|
goto out_put;
|
||||||
|
}
|
||||||
|
|
||||||
|
out_put:
|
||||||
|
lxc_container_put(c);
|
||||||
|
engine_free_log_prefix();
|
||||||
|
return bret;
|
||||||
|
}
|
||||||
|
|
||||||
bool lcr_console(const char *name, const char *lcrpath, const char *in_fifo, const char *out_fifo, const char *err_fifo)
|
bool lcr_console(const char *name, const char *lcrpath, const char *in_fifo, const char *out_fifo, const char *err_fifo)
|
||||||
{
|
{
|
||||||
struct lxc_container *c = NULL;
|
struct lxc_container *c = NULL;
|
||||||
|
|||||||
@ -274,6 +274,8 @@ struct lcr_exec_request {
|
|||||||
size_t args_len;
|
size_t args_len;
|
||||||
|
|
||||||
int64_t timeout;
|
int64_t timeout;
|
||||||
|
|
||||||
|
const char *suffix;
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
* Execute process inside a container
|
* Execute process inside a container
|
||||||
@ -289,7 +291,9 @@ void lcr_free_errmsg();
|
|||||||
bool lcr_get_container_pids(const char *name, const char *lcrpath, pid_t **pids, size_t *pids_len);
|
bool lcr_get_container_pids(const char *name, const char *lcrpath, pid_t **pids, size_t *pids_len);
|
||||||
|
|
||||||
bool translate_spec(const struct lxc_container *c, const char *oci_json_data, const char *container_rootfs);
|
bool translate_spec(const struct lxc_container *c, const char *oci_json_data, const char *container_rootfs);
|
||||||
|
bool lcr_resize(const char *name, const char *lcrpath, unsigned int height, unsigned int width);
|
||||||
|
bool lcr_exec_resize(const char *name, const char *lcrpath, const char *suffix, unsigned int height,
|
||||||
|
unsigned int width);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -943,6 +943,8 @@ static void execute_lxc_attach(const char *name, const char *path, const struct
|
|||||||
add_array_elem(params, args_len, &i, request->user);
|
add_array_elem(params, args_len, &i, request->user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_array_kv(params, args_len, &i, "--suffix", request->suffix);
|
||||||
|
|
||||||
add_array_elem(params, args_len, &i, "--");
|
add_array_elem(params, args_len, &i, "--");
|
||||||
for (j = 0; j < request->args_len; j++) {
|
for (j = 0; j < request->args_len; j++) {
|
||||||
add_array_elem(params, args_len, &i, request->args[j]);
|
add_array_elem(params, args_len, &i, request->args[j]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user