[OE-core] [PATCH 3/3] bash: run bash ptest as non-root user

Randy MacLeod randy.macleod at windriver.com
Mon Jun 3 18:53:27 UTC 2019


On 5/31/19 4:25 PM, Sakib Sajal wrote:
> new-exp ptest fails as it expects non-root user.
> 
>>From the failed ptest log:
>     < new-exp.tests: the test suite should not be run as root
>     628c627
>     < argv[1] = <host(2)[5.0]# >
>     ---
>     > argv[1] = <host(2)[5.0]$ >
>     FAIL: run-new-exp
> 
> Many of the ptests declare that they should not be run as root
> and a few fail since the expected result strings are for a
> user shell.
> 
> When ptests are run as bash_user (non-root) the glob test
> fails with error:
>      run-glob-test
>      59,60d58
>      < touch: cannot touch 'a?': Permission denied
>      < touch: cannot touch 'aa': Permission denied
> 
> So ensure that the bash/ptest/tests directory is owned by the
> bash_user while the tests are being run and return it to root
> owner afterwards.
> 
> Signed-off-by: Sakib Sajal <sakib.sajal at windriver.com>
> Signed-off-by: Randy Macleod <randy.macleod at windriver.com>
> ---
>   meta/recipes-extended/bash/bash/run-ptest | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)


Ugh, there are some problems here.

1. We somehow dropped the change to add 'useradd' to
    the inherit line in bash.inc
2. We didn't confirm that there weren't any regressions
    when running as a user to fix glob-test.
    run-execscript [1] and perhaps other tests are now broken.

Sorry about that.

Fixes will be sent once local testing is done so perhaps
today and if not certainly tomorrow.

../Randy

[1] I should have noticed that Hongxu made some changes
to run some of the tests as non-root 4 years ago.
We'll need to revert/fix those changes now.

commit 1096140cb1d2532ecb38ac5fbbbe13d40fdaf6af
Author: Hongxu Jia <hongxu.jia at windriver.com>
Date:   Sat Nov 28 14:53:40 2015 +0800

     bash: fix testcase run-coproc/run-execscript/run-test/run-heredoc 
failed

> 
> diff --git a/meta/recipes-extended/bash/bash/run-ptest b/meta/recipes-extended/bash/bash/run-ptest
> index c61fabd020..c0cf27b6c2 100644
> --- a/meta/recipes-extended/bash/bash/run-ptest
> +++ b/meta/recipes-extended/bash/bash/run-ptest
> @@ -19,4 +19,8 @@ then
>           echo "Warning: The de_DE* locales is needed to run the intl.tests, please add it."
>   fi
>   
> -make -k THIS_SH=/bin/bash BUILD_DIR=`pwd` srcdir=`pwd`  runtest
> +useradd bash_user
> +chown -R bash_user:bash_user ./tests
> +su bash_user -c "make -k THIS_SH=/bin/bash BUILD_DIR=`pwd` srcdir=`pwd` runtest"
> +chown -R root:root ./tests
> +userdel bash_user
> 


-- 
# Randy MacLeod
# Wind River Linux


More information about the Openembedded-core mailing list