1 Star 0 Fork 44

firstadream/lxc

forked from src-openEuler/lxc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0012-only-set-user-or-image-set-non-empty-HOME.patch 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
haozi007 提交于 2022-08-15 14:55 . replace invalid patch
From 7273c6631f692872384cce83cc04b4084ee98f73 Mon Sep 17 00:00:00 2001
From: haozi007 <[email protected]>
Date: Tue, 9 Aug 2022 17:30:59 +0800
Subject: [PATCH] only set user or image set non-empty HOME
Signed-off-by: haozi007 <[email protected]>
---
src/lxc/isulad_utils.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/lxc/isulad_utils.c b/src/lxc/isulad_utils.c
index cd7fca8..067e1c9 100644
--- a/src/lxc/isulad_utils.c
+++ b/src/lxc/isulad_utils.c
@@ -257,6 +257,13 @@ int lxc_setup_env_home(uid_t uid)
FILE *stream = NULL;
struct passwd pw, *pwbufp = NULL;
char buf[BUFSIZ];
+ const char *curr_home = NULL;
+
+ curr_home = getenv("HOME");
+ // if user set or image set, just use it.
+ if (curr_home != NULL && strcmp(curr_home, "") != 0) {
+ return 0;
+ }
stream = fopen_cloexec(__PASSWD_FILE__, "r");
if (stream == NULL) {
@@ -280,8 +287,9 @@ set_env:
if (stream)
fclose(stream);
- // if we didn't configure HOME, set it based on uid
- if (setenv("HOME", homedir, 0) < 0) {
+ // if we didn't configure HOME, set it based on uid;
+ // override it if reach here.
+ if (setenv("HOME", homedir, 1) < 0) {
SYSERROR("Unable to set env 'HOME'");
return -1;
}
@@ -518,4 +526,4 @@ int util_getpwent_r(FILE *stream, struct passwd *resbuf, char *buffer, size_t bu
out:
funlockfile(stream);
return ret;
-}
\ No newline at end of file
+}
--
2.25.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/firstadream/lxc.git
[email protected]:firstadream/lxc.git
firstadream
lxc
lxc
master

搜索帮助