ltp icon indicating copy to clipboard operation
ltp copied to clipboard

Better handling required user and group

Open pevik opened this issue 6 years ago • 5 comments

LTP requires special user and group to be presented (check IDcheck.sh script). Instead of hard-wired them in tests it'd be great to have tst_user() and tst_group() which would allow via environment variables to use alternative ones.

+ adding test flag .needs_user = 1 (C API) and TST_NEEDS_USER (shell API) which would:

  1. check for $TST_USER and use it if exist (this should have default "nobody")
  2. create temporary user if $TST_USER does not exist, which would be deleted after test (see code in testcases/kernel/syscalls/add_key/add_key05.c). Not sure if sharing user between tests is ok (probably is). Allowing default helps embedded distros, which might not have useradd binary (adding C code for adding new user would be error prone and IMHO not work for embedded and android distros).

C API may also add SAFE_USERADD() and SAFE_USERDEL() for tests which needs more users (at least testcases/kernel/syscalls/add_key/add_key05.c), maybe shell API need that as well.

There are many tests which would benefit from it, e.g. (incomplete list): testcases/kernel/syscalls/add_key/add_key05.c testcases/kernel/syscalls/chmod/chmod05.c testcases/kernel/syscalls/chdir/chdir03.c testcases/kernel/syscalls/ipc/shmget/shmget04.c testcases/kernel/fs/read_all/read_all.c testcases/kernel/security/dirtyc0w/dirtyc0w.c

UPDATE: most of tests now just use user 'nobody' and group 'nogroup', but AOSP requires to use GID 'daemon' instead of 'nogroup', see https://lore.kernel.org/ltp/YVtBt+WeskISn5+9@pevik/T/#t

This should be handled in the library + allowing to redefine required users would be enough.

pevik avatar Jan 17 '19 11:01 pevik

Working on it, ideally both C & Shell API

dzedro avatar May 19 '20 08:05 dzedro