提交 41963eb8 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!78 iSulad: fix some bugs for syscontainer

Merge pull request !78 from zhangsong234/master
...@@ -527,9 +527,23 @@ static int mount_dev_tmpfs_for_system_container(const container_t *cont) ...@@ -527,9 +527,23 @@ static int mount_dev_tmpfs_for_system_container(const container_t *cont)
return -1; return -1;
} }
} }
if (mount("tmpfs", rootfs_dev_path, "tmpfs", 0, "size=500000,mode=755")) { /* set /dev mount size to half of container memory limit */
ERROR("Failed to mount dev tmpfs on '%s'", rootfs_dev_path); if (cont->hostconfig->memory > 0) {
return -1; char mnt_opt[MOUNT_PROPERTIES_SIZE] = { 0 };
nret = snprintf(mnt_opt, sizeof(mnt_opt), "size=%lld,mode=755", (long long int)(cont->hostconfig->memory / 2));
if (nret < 0 || (size_t)nret >= sizeof(mnt_opt)) {
ERROR("Out of memory");
return -1;
}
if (mount("tmpfs", rootfs_dev_path, "tmpfs", 0, mnt_opt) != 0) {
ERROR("Failed to mount dev tmpfs on '%s'", rootfs_dev_path);
return -1;
}
} else {
if (mount("tmpfs", rootfs_dev_path, "tmpfs", 0, "mode=755") != 0) {
ERROR("Failed to mount dev tmpfs on '%s'", rootfs_dev_path);
return -1;
}
} }
if (cont->hostconfig->user_remap != NULL) { if (cont->hostconfig->user_remap != NULL) {
unsigned int host_uid = 0; unsigned int host_uid = 0;
......
...@@ -1691,7 +1691,7 @@ out: ...@@ -1691,7 +1691,7 @@ out:
return ret; return ret;
} }
static int parse_security_opt(const host_config *host_spec, bool *no_new_privileges, int parse_security_opt(const host_config *host_spec, bool *no_new_privileges,
char ***label_opts, size_t *label_opts_len, char ***label_opts, size_t *label_opts_len,
char **seccomp_profile) char **seccomp_profile)
{ {
......
...@@ -37,6 +37,9 @@ oci_runtime_spec *default_spec(bool system_container); ...@@ -37,6 +37,9 @@ oci_runtime_spec *default_spec(bool system_container);
int merge_conf_cgroup(oci_runtime_spec *oci_spec, const host_config *host_spec); int merge_conf_cgroup(oci_runtime_spec *oci_spec, const host_config *host_spec);
int save_oci_config(const char *id, const char *rootpath, const oci_runtime_spec *oci_spec); int save_oci_config(const char *id, const char *rootpath, const oci_runtime_spec *oci_spec);
int parse_security_opt(const host_config *host_spec, bool *no_new_privileges,
char ***label_opts, size_t *label_opts_len,
char **seccomp_profile);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "libisulad.h" #include "libisulad.h"
#include "specs_extend.h" #include "specs_extend.h"
#include "selinux_label.h" #include "selinux_label.h"
#include "specs.h"
#define MAX_CAP_LEN 32 #define MAX_CAP_LEN 32
...@@ -984,6 +985,10 @@ int adapt_settings_for_system_container(oci_runtime_spec *oci_spec, const host_c ...@@ -984,6 +985,10 @@ int adapt_settings_for_system_container(oci_runtime_spec *oci_spec, const host_c
}; };
char **adds = NULL; char **adds = NULL;
size_t adds_len = 0; size_t adds_len = 0;
bool no_new_privileges = false;
char **label_opts = NULL;
size_t label_opts_len = 0;
char *seccomp_profile = NULL;
ret = get_adds_cap_for_system_container(host_spec, &adds, &adds_len); ret = get_adds_cap_for_system_container(host_spec, &adds, &adds_len);
if (ret != 0) { if (ret != 0) {
...@@ -1009,6 +1014,16 @@ int adapt_settings_for_system_container(oci_runtime_spec *oci_spec, const host_c ...@@ -1009,6 +1014,16 @@ int adapt_settings_for_system_container(oci_runtime_spec *oci_spec, const host_c
goto out; goto out;
} }
ret = parse_security_opt(host_spec, &no_new_privileges, &label_opts,
&label_opts_len, &seccomp_profile);
if (ret != 0) {
ERROR("Failed to parse security opt");
goto out;
}
/* do not append to seccomp if seccomp profile is NULL or unconfined */
if (seccomp_profile == NULL || strcmp(seccomp_profile, "unconfined") == 0) {
goto out;
}
ret = append_systemcall_to_seccomp( ret = append_systemcall_to_seccomp(
oci_spec->linux->seccomp, oci_spec->linux->seccomp,
make_seccomp_syscalls_element((const char **)unblocked_systemcall_for_system_container, make_seccomp_syscalls_element((const char **)unblocked_systemcall_for_system_container,
...@@ -1021,6 +1036,8 @@ int adapt_settings_for_system_container(oci_runtime_spec *oci_spec, const host_c ...@@ -1021,6 +1036,8 @@ int adapt_settings_for_system_container(oci_runtime_spec *oci_spec, const host_c
goto out; goto out;
} }
out: out:
util_free_array(label_opts);
free(seccomp_profile);
free_adds_cap_for_system_container(adds, adds_len); free_adds_cap_for_system_container(adds, adds_len);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册