Mitigate user missing from getent enumeration

Sometimes `getent passwd` does not give the user information.
This change tries to at least get the current user via
`getent passwd $USER` since it uses
a more reliable and faster system call (getpwnam(3)).

Reference:
be748493a3
This commit is contained in:
Filippo Squillace 2016-11-27 12:49:09 +00:00
parent 6d4e5f7404
commit 6568430add
2 changed files with 10 additions and 4 deletions

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() {