Merge pull request #166 from fsquillace/passwd_user

Passwd user
This commit is contained in:
Filippo Squillace 2016-11-27 19:49:24 +00:00 committed by GitHub
commit 46221f26b1
3 changed files with 11 additions and 5 deletions

View file

@ -1 +1 @@
5.6.8
5.6.9

View file

@ -420,11 +420,17 @@ function _provide_bindings_as_user(){
# None
#######################################
function _build_passwd_and_group(){
if ! getent_cmd passwd > ${JUNEST_HOME}/etc/junest/passwd
# Enumeration of users/groups is disabled/limited depending on how nsswitch.conf
# is configured.
# Try to at least get the current user via `getent passwd $USER` since it uses
# a more reliable and faster system call (getpwnam(3)).
if ! getent_cmd passwd > ${JUNEST_HOME}/etc/junest/passwd || \
! getent_cmd passwd ${USER} >> ${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
if ! getent_cmd group > ${JUNEST_HOME}/etc/junest/group
then
warn "getent command failed or does not exist. Binding directly from /etc/group."

View file

@ -265,7 +265,7 @@ function test_build_passwd_and_group(){
echo $@
}
GETENT=getent_cmd_mock assertCommandSuccess _build_passwd_and_group
assertEquals "passwd" "$(cat $JUNEST_HOME/etc/junest/passwd)"
assertEquals "$(echo -e "passwd\npasswd $USER")" "$(cat $JUNEST_HOME/etc/junest/passwd)"
assertEquals "group" "$(cat $JUNEST_HOME/etc/junest/group)"
}
@ -325,11 +325,11 @@ function test_delete_env(){
}
function test_nested_env(){
JUNEST_ENV=1 assertCommandFailOnStatus 106 bash -ic "source $JUNEST_ROOT/lib/utils.sh; source $JUNEST_ROOT/lib/core.sh"
JUNEST_ENV=1 assertCommandFailOnStatus 106 bash -c "source $JUNEST_ROOT/lib/utils.sh; source $JUNEST_ROOT/lib/core.sh"
}
function test_nested_env_not_set_variable(){
JUNEST_ENV=aaa assertCommandFailOnStatus 107 bash -ic "source $JUNEST_ROOT/lib/utils.sh; source $JUNEST_ROOT/lib/core.sh"
JUNEST_ENV=aaa assertCommandFailOnStatus 107 bash -c "source $JUNEST_ROOT/lib/utils.sh; source $JUNEST_ROOT/lib/core.sh"
}
function test_qemu() {