Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
ecc976fa
I
iSulad
项目概览
openeuler
/
iSulad
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ecc976fa
编写于
2月 14, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
2月 14, 2020
浏览文件
操作
浏览文件
下载
差异文件
!48 iSulad: add necessary envs for exec process
Merge pull request !48 from lifeng_isula/fix_exec_env
上级
2396cee6
fb98a8ec
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
115 addition
and
3 deletion
+115
-3
src/image/oci/oci_config_merge.c
src/image/oci/oci_config_merge.c
+0
-2
src/services/execution/execute/execution_stream.c
src/services/execution/execute/execution_stream.c
+115
-1
未找到文件。
src/image/oci/oci_config_merge.c
浏览文件 @
ecc976fa
...
...
@@ -97,8 +97,6 @@ static int oci_image_merge_env(const oci_image_spec_config *config, container_co
}
out:
return
ret
;
return
0
;
}
static
int
do_duplicate_commands
(
const
oci_image_spec_config
*
config
,
container_config
*
container_spec
)
...
...
src/services/execution/execute/execution_stream.c
浏览文件 @
ecc976fa
...
...
@@ -248,7 +248,115 @@ out:
return
ret
;
}
int
merge_exec_process_env
(
defs_process
*
spec
,
const
container_config
*
container_spec
,
const
char
**
env
,
size_t
env_len
)
static
int
do_append_process_exec_env
(
const
char
**
default_env
,
defs_process
*
spec
)
{
int
ret
=
0
;
size_t
new_size
=
0
;
size_t
old_size
=
0
;
size_t
i
=
0
;
size_t
j
=
0
;
char
**
temp
=
NULL
;
char
**
default_kv
=
NULL
;
char
**
custom_kv
=
NULL
;
size_t
default_env_len
=
util_array_len
(
default_env
);
if
(
default_env_len
==
0
)
{
return
0
;
}
if
(
default_env_len
>
LIST_ENV_SIZE_MAX
-
spec
->
env_len
)
{
ERROR
(
"The length of envionment variables is too long, the limit is %d"
,
LIST_ENV_SIZE_MAX
);
isulad_set_error_message
(
"The length of envionment variables is too long, the limit is %d"
,
LIST_ENV_SIZE_MAX
);
ret
=
-
1
;
goto
out
;
}
new_size
=
(
spec
->
env_len
+
default_env_len
)
*
sizeof
(
char
*
);
old_size
=
spec
->
env_len
*
sizeof
(
char
*
);
ret
=
mem_realloc
((
void
**
)
&
temp
,
new_size
,
spec
->
env
,
old_size
);
if
(
ret
!=
0
)
{
ERROR
(
"Failed to realloc memory for envionment variables"
);
ret
=
-
1
;
goto
out
;
}
spec
->
env
=
temp
;
for
(
i
=
0
;
i
<
default_env_len
;
i
++
)
{
bool
found
=
false
;
default_kv
=
util_string_split
(
default_env
[
i
],
'='
);
if
(
default_kv
==
NULL
)
{
continue
;
}
for
(
j
=
0
;
j
<
spec
->
env_len
;
j
++
)
{
custom_kv
=
util_string_split
(
spec
->
env
[
i
],
'='
);
if
(
custom_kv
==
NULL
)
{
continue
;
}
if
(
strcmp
(
default_kv
[
0
],
custom_kv
[
0
])
==
0
)
{
found
=
true
;
}
util_free_array
(
custom_kv
);
custom_kv
=
NULL
;
if
(
found
)
{
break
;
}
}
if
(
!
found
)
{
spec
->
env
[
spec
->
env_len
]
=
util_strdup_s
(
default_env
[
i
]);
spec
->
env_len
++
;
}
util_free_array
(
default_kv
);
default_kv
=
NULL
;
}
out:
return
ret
;
}
static
int
append_necessary_process_env
(
bool
tty
,
const
container_config
*
container_spec
,
defs_process
*
spec
)
{
int
ret
=
0
;
int
nret
=
0
;
char
**
default_env
=
NULL
;
char
host_name_str
[
MAX_HOST_NAME_LEN
+
10
]
=
{
0
};
if
(
util_array_append
(
&
default_env
,
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
)
!=
0
)
{
ERROR
(
"Failed to append default exec env"
);
ret
=
-
1
;
goto
out
;
}
if
(
container_spec
->
hostname
!=
NULL
)
{
nret
=
snprintf
(
host_name_str
,
sizeof
(
host_name_str
),
"HOSTNAME=%s"
,
container_spec
->
hostname
);
if
(
nret
<
0
||
(
size_t
)
nret
>=
sizeof
(
host_name_str
))
{
ERROR
(
"hostname is too long"
);
ret
=
-
1
;
goto
out
;
}
if
(
util_array_append
(
&
default_env
,
host_name_str
)
!=
0
)
{
ERROR
(
"Failed to append default exec env"
);
ret
=
-
1
;
goto
out
;
}
}
if
(
tty
)
{
if
(
util_array_append
(
&
default_env
,
"TERM=xterm"
)
!=
0
)
{
ERROR
(
"Failed to append default exec env"
);
ret
=
-
1
;
goto
out
;
}
}
ret
=
do_append_process_exec_env
((
const
char
**
)
default_env
,
spec
);
out:
util_free_array
(
default_env
);
return
ret
;
}
static
int
merge_exec_process_env
(
defs_process
*
spec
,
const
container_config
*
container_spec
,
const
char
**
env
,
size_t
env_len
)
{
int
ret
=
0
;
size_t
env_count
=
0
;
...
...
@@ -340,6 +448,12 @@ static defs_process *make_exec_process_spec(const container_config *container_sp
goto
err_out
;
}
ret
=
append_necessary_process_env
(
request
->
tty
,
container_spec
,
spec
);
if
(
ret
!=
0
)
{
ERROR
(
"Failed to append necessary for exec process spec"
);
goto
err_out
;
}
ret
=
dup_array_of_strings
((
const
char
**
)
request
->
argv
,
request
->
argv_len
,
&
(
spec
->
args
),
&
(
spec
->
args_len
));
if
(
ret
!=
0
)
{
ERROR
(
"Failed to dup envs for exec process spec"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录