From 7a778b2393dce330ba5b4828a1a02b66a3629648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Hees?= Date: Fri, 18 Nov 2016 09:28:34 +0100 Subject: [PATCH] :bug: :racehorse: fix concurrency in init code, fixes #163 caches and prefers existing .junest/etc/passwd and group files before this fix it was possible that concurrent startup (as in multiple junest processes) lead to partial files for some of the junest processes. --- lib/core.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/core.sh b/lib/core.sh index dc29c34..d901b45 100644 --- a/lib/core.sh +++ b/lib/core.sh @@ -420,15 +420,19 @@ function _provide_bindings_as_user(){ # None ####################################### function _build_passwd_and_group(){ - if ! getent_cmd passwd > ${JUNEST_HOME}/etc/junest/passwd - then - warn "getent command failed or does not exist. Binding directly from /etc/passwd." - cp_cmd /etc/passwd ${JUNEST_HOME}/etc/junest/passwd + if [ ! -f ${JUNEST_HOME}/etc/junest/passwd ] ; then + if ! getent_cmd passwd > ${JUNEST_HOME}/etc/junest/passwd + then + warn "getent command failed or does not exist. Binding directly from /etc/passwd." + cp_cmd /etc/passwd ${JUNEST_HOME}/etc/junest/passwd + fi fi - if ! getent_cmd group > ${JUNEST_HOME}/etc/junest/group - then - warn "getent command failed or does not exist. Binding directly from /etc/group." - cp_cmd /etc/group ${JUNEST_HOME}/etc/junest/group + if [ ! -f ${JUNEST_HOME}/etc/junest/group ] ; then + if ! getent_cmd group > ${JUNEST_HOME}/etc/junest/group + then + warn "getent command failed or does not exist. Binding directly from /etc/group." + cp_cmd /etc/group ${JUNEST_HOME}/etc/junest/group + fi fi }