From e35f3ad3dba97992b16c3299053699d7f90410f6 Mon Sep 17 00:00:00 2001 From: haozi007 Date: Sat, 13 Aug 2022 16:17:20 +0800 Subject: [PATCH] only set user or image setting non-empty HOME Signed-off-by: haozi007 --- ...set-user-or-image-set-non-empty-HOME.patch | 41 +++++++++++++++++++ lxc.spec | 9 +++- series.conf | 1 + 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 0045-only-set-user-or-image-set-non-empty-HOME.patch diff --git a/0045-only-set-user-or-image-set-non-empty-HOME.patch b/0045-only-set-user-or-image-set-non-empty-HOME.patch new file mode 100644 index 0000000..0e16192 --- /dev/null +++ b/0045-only-set-user-or-image-set-non-empty-HOME.patch @@ -0,0 +1,41 @@ +From 813af4193dd4d2d998c040d020879ea3b5c46100 Mon Sep 17 00:00:00 2001 +From: haozi007 +Date: Sat, 13 Aug 2022 18:34:04 +0800 +Subject: [PATCH] only set user or image set non-empty HOME + +Signed-off-by: haozi007 +--- + 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 + diff --git a/lxc.spec b/lxc.spec index 4f62f3b..03492b5 100644 --- a/lxc.spec +++ b/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 - 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 - 4.0.3-2022072501 - Type:bugfix - ID:NA diff --git a/series.conf b/series.conf index e1db9bb..13aca86 100644 --- a/series.conf +++ b/series.conf @@ -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 -- Gitee