diff --git a/0012-only-set-user-or-image-set-non-empty-HOME.patch b/0012-only-set-user-or-image-set-non-empty-HOME.patch new file mode 100644 index 0000000000000000000000000000000000000000..9fa3def2ce8b358fe329987bfb86289c2445caed --- /dev/null +++ b/0012-only-set-user-or-image-set-non-empty-HOME.patch @@ -0,0 +1,64 @@ +From 9752afbac49f7f67a68a247aa1bc17baa5fdb761 Mon Sep 17 00:00:00 2001 +From: haozi007 +Date: Tue, 9 Aug 2022 17:30:59 +0800 +Subject: [PATCH] only set user or image set non-empty HOME + +Signed-off-by: haozi007 +--- + 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 + #include + #include +-/* Needs to be after sys/mount.h header */ +-#include + #include + #include + #include +-- +2.25.1 + diff --git a/apply-patches b/apply-patches index 8ba065e1c62b651b4be4c3cbaf6315e3dc41c498..26b3d045520a9340f7f7dc36814656db8112b940 100755 --- a/apply-patches +++ b/apply-patches @@ -33,4 +33,8 @@ do patch -p1 -F1 -s < $cwd/$line done +git init . +git add . +git commit -m "init repo" + cd $cwd diff --git a/lxc.spec b/lxc.spec index 311d3482efe1bf04e1849cb644a439ff29f4f08e..52b691dbaf5b64bbbd20d70049c429644a013b42 100644 --- a/lxc.spec +++ b/lxc.spec @@ -1,4 +1,4 @@ -%global _release 2022072601 +%global _release 2022080901 Name: lxc 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 Patch0010: 0010-check-yajl-only-when-have-isulad.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: pkgconfig(libseccomp) @@ -190,6 +191,12 @@ make check %{_mandir}/*/man7/%{name}* %changelog +* Tue Aug 9 2022 haozi007 - 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 - 4.0.3-2022072601 - Type:bugfix - ID:NA diff --git a/series.conf b/series.conf index aec8fff14b768997296f7b6e0c62cab6232591a3..4c1cbc3c2d5480e1aba90880cdaba6bcef2183ea 100644 --- a/series.conf +++ b/series.conf @@ -9,3 +9,4 @@ 0009-fix-HOME-env-of-container-unset-error.patch 0010-check-yajl-only-when-have-isulad.patch 0011-drop-security_context_t.patch +0012-only-set-user-or-image-set-non-empty-HOME.patch