only set user or image setting non-empty HOME
Signed-off-by: haozi007 <liuhao27@huawei.com>
This commit is contained in:
parent
8301bb9d1b
commit
a04767369f
64
0012-only-set-user-or-image-set-non-empty-HOME.patch
Normal file
64
0012-only-set-user-or-image-set-non-empty-HOME.patch
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
From 9752afbac49f7f67a68a247aa1bc17baa5fdb761 Mon Sep 17 00:00:00 2001
|
||||||
|
From: haozi007 <liuhao27@huawei.com>
|
||||||
|
Date: Tue, 9 Aug 2022 17:30:59 +0800
|
||||||
|
Subject: [PATCH] only set user or image set non-empty HOME
|
||||||
|
|
||||||
|
Signed-off-by: haozi007 <liuhao27@huawei.com>
|
||||||
|
---
|
||||||
|
src/lxc/isulad_utils.c | 14 +++++++++++---
|
||||||
|
src/lxc/utils.c | 2 --
|
||||||
|
2 files changed, 11 insertions(+), 5 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
|
||||||
|
+}
|
||||||
|
diff --git a/src/lxc/utils.c b/src/lxc/utils.c
|
||||||
|
index ab351d8..1adeefa 100644
|
||||||
|
--- a/src/lxc/utils.c
|
||||||
|
+++ b/src/lxc/utils.c
|
||||||
|
@@ -19,8 +19,6 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
-/* Needs to be after sys/mount.h header */
|
||||||
|
-#include <linux/fs.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
||||||
@ -33,4 +33,8 @@ do
|
|||||||
patch -p1 -F1 -s < $cwd/$line
|
patch -p1 -F1 -s < $cwd/$line
|
||||||
done
|
done
|
||||||
|
|
||||||
|
git init .
|
||||||
|
git add .
|
||||||
|
git commit -m "init repo"
|
||||||
|
|
||||||
cd $cwd
|
cd $cwd
|
||||||
|
|||||||
9
lxc.spec
9
lxc.spec
@ -1,4 +1,4 @@
|
|||||||
%global _release 2022072601
|
%global _release 2022080901
|
||||||
|
|
||||||
Name: lxc
|
Name: lxc
|
||||||
Version: 4.0.3
|
Version: 4.0.3
|
||||||
@ -19,6 +19,7 @@ Patch0008: 0008-refactor-patch-code-of-json.patch
|
|||||||
Patch0009: 0009-fix-HOME-env-of-container-unset-error.patch
|
Patch0009: 0009-fix-HOME-env-of-container-unset-error.patch
|
||||||
Patch0010: 0010-check-yajl-only-when-have-isulad.patch
|
Patch0010: 0010-check-yajl-only-when-have-isulad.patch
|
||||||
Patch0011: 0011-drop-security_context_t.patch
|
Patch0011: 0011-drop-security_context_t.patch
|
||||||
|
Patch0012: 0012-only-set-user-or-image-set-non-empty-HOME.patch
|
||||||
|
|
||||||
BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath
|
BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath
|
||||||
BuildRequires: pkgconfig(libseccomp)
|
BuildRequires: pkgconfig(libseccomp)
|
||||||
@ -190,6 +191,12 @@ make check
|
|||||||
%{_mandir}/*/man7/%{name}*
|
%{_mandir}/*/man7/%{name}*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Aug 9 2022 haozi007<liuhao27@huawei.com> - 4.0.3-2022080901
|
||||||
|
- Type:bugfix
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC: only set user or image set non empty HOME
|
||||||
|
|
||||||
* Tue Jul 26 2022 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 4.0.3-2022072601
|
* Tue Jul 26 2022 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 4.0.3-2022072601
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
@ -9,3 +9,4 @@
|
|||||||
0009-fix-HOME-env-of-container-unset-error.patch
|
0009-fix-HOME-env-of-container-unset-error.patch
|
||||||
0010-check-yajl-only-when-have-isulad.patch
|
0010-check-yajl-only-when-have-isulad.patch
|
||||||
0011-drop-security_context_t.patch
|
0011-drop-security_context_t.patch
|
||||||
|
0012-only-set-user-or-image-set-non-empty-HOME.patch
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user