mirror of
https://github.com/fsquillace/junest.git
synced 2026-01-23 02:34:30 +00:00
#284 Fix copy command
This commit is contained in:
parent
e6bae0647c
commit
7d8c619ee0
2 changed files with 6 additions and 4 deletions
|
|
@ -276,20 +276,22 @@ function copy_passwd_and_group(){
|
|||
! getent_cmd passwd ${USER} >> ${JUNEST_HOME}/etc/passwd
|
||||
then
|
||||
warn "getent command failed or does not exist. Binding directly from /etc/passwd."
|
||||
copy_file /etc/passwd ${JUNEST_HOME}/etc/passwd
|
||||
copy_file /etc/passwd
|
||||
fi
|
||||
|
||||
if ! getent_cmd group > ${JUNEST_HOME}/etc/group
|
||||
then
|
||||
warn "getent command failed or does not exist. Binding directly from /etc/group."
|
||||
copy_file /etc/group ${JUNEST_HOME}/etc/group
|
||||
copy_file /etc/group
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function copy_file() {
|
||||
local file="${1}"
|
||||
[[ -r "$file" ]] && cp_cmd "$file" "${JUNEST_HOME}/$file"
|
||||
# -f option ensure to remove destination file if it cannot be opened
|
||||
# https://github.com/fsquillace/junest/issues/284
|
||||
[[ -r "$file" ]] && cp_cmd -f "$file" "${JUNEST_HOME}/$file"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ function test_copy_passwd_and_group_fallback(){
|
|||
echo $@
|
||||
}
|
||||
CP=cp_cmd_mock GETENT=false LD_EXEC=false assertCommandSuccess copy_passwd_and_group
|
||||
assertEquals "$(echo -e "/etc/passwd $JUNEST_HOME//etc/passwd\n/etc/group $JUNEST_HOME//etc/group")" "$(cat $STDOUTF)"
|
||||
assertEquals "$(echo -e "-f /etc/passwd $JUNEST_HOME//etc/passwd\n-f /etc/group $JUNEST_HOME//etc/group")" "$(cat $STDOUTF)"
|
||||
}
|
||||
|
||||
function test_copy_passwd_and_group_failure(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue