!326 [sync] PR-324: only set user or image setting non-empty HOME
From: @openeuler-sync-bot Reviewed-by: @duguhaotian Signed-off-by: @duguhaotian
This commit is contained in:
commit
76ffd3ecfd
41
0045-only-set-user-or-image-set-non-empty-HOME.patch
Normal file
41
0045-only-set-user-or-image-set-non-empty-HOME.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From 813af4193dd4d2d998c040d020879ea3b5c46100 Mon Sep 17 00:00:00 2001
|
||||
From: haozi007 <liuhao27@huawei.com>
|
||||
Date: Sat, 13 Aug 2022 18:34:04 +0800
|
||||
Subject: [PATCH] only set user or image set non-empty HOME
|
||||
|
||||
Signed-off-by: haozi007 <liuhao27@huawei.com>
|
||||
---
|
||||
src/lxc/utils.c | 10 +++++++++-
|
||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/lxc/utils.c b/src/lxc/utils.c
|
||||
index 20ca181..ed66935 100644
|
||||
--- a/src/lxc/utils.c
|
||||
+++ b/src/lxc/utils.c
|
||||
@@ -2218,6 +2218,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) {
|
||||
@@ -2242,7 +2249,8 @@ set_env:
|
||||
fclose(stream);
|
||||
|
||||
// if we didn't configure HOME, set it based on uid
|
||||
- if (setenv("HOME", homedir, 0) < 0) {
|
||||
+ // override it if reach here.
|
||||
+ if (setenv("HOME", homedir, 1) < 0) {
|
||||
SYSERROR("Unable to set env 'HOME'");
|
||||
return -1;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
9
lxc.spec
9
lxc.spec
@ -1,4 +1,4 @@
|
||||
%global _release 2022072501
|
||||
%global _release 2022081201
|
||||
|
||||
Name: lxc
|
||||
Version: 4.0.3
|
||||
@ -52,6 +52,7 @@ Patch0041: 0041-do-not-free-the-pointer-returned-by-dirname.patch
|
||||
Patch0042: 0042-add-x-permission-when-create-directory.patch
|
||||
Patch0043: 0043-do-not-operate-playload-and-attach-cgroup-if-no-cont.patch
|
||||
Patch0044: 0044-fix-HOME-env-unset-error.patch
|
||||
Patch0045: 0045-only-set-user-or-image-set-non-empty-HOME.patch
|
||||
|
||||
BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath
|
||||
BuildRequires: pkgconfig(libseccomp)
|
||||
@ -223,6 +224,12 @@ make check
|
||||
%{_mandir}/*/man7/%{name}*
|
||||
|
||||
%changelog
|
||||
* Fri Aug 12 2022 haozi007<liuhao27@huawei.com> - 4.0.3-2022081201
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC: only set user or image set non empty HOME
|
||||
|
||||
* Mon Jul 25 2022 haozi007<liuhao27@huawei.com> - 4.0.3-2022072501
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
|
||||
@ -42,3 +42,4 @@
|
||||
0042-add-x-permission-when-create-directory.patch
|
||||
0043-do-not-operate-playload-and-attach-cgroup-if-no-cont.patch
|
||||
0044-fix-HOME-env-unset-error.patch
|
||||
0045-only-set-user-or-image-set-non-empty-HOME.patch
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user