[PATCH v3 2/4] tst_test.sh: Add TST_USR_{G,U}ID variables

Petr Vorel
2025-11-27T08:26:53Z

Add TST_USR_{G,U}ID variables with the default values from tst_sudo.c.

These can be used as a default values for tests which use tst_sudo and
need to know UID/GID for other commands.

It will be used in LTP IMA tests.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/lib/tst_sudo.c | 1 +
testcases/lib/tst_test.sh | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/testcases/lib/tst_sudo.c b/testcases/lib/tst_sudo.c
index e8d5d8dd9d..e937828273 100644
--- a/testcases/lib/tst_sudo.c
+++ b/testcases/lib/tst_sudo.c
@@ -3,6 +3,7 @@
* Copyright (c) 2025 Petr Vorel <pvorel@suse.cz>
*/

+/* update also tst_test.sh */
#define LTP_USR_UID 65534
#define LTP_USR_GID 65534

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 4be10a4f94..49f282d7c8 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -17,6 +17,10 @@ export TST_ITERATIONS=1
export TST_TMPDIR_RHOST=0
export TST_LIB_LOADED=1

+# see testcases/lib/tst_sudo.c
+export TST_USR_UID="${LTP_USR_UID:-65534}"
+export TST_USR_GID="${LTP_USR_GID:-65534}"
+
. tst_ansi_color.sh
. tst_security.sh

@@ -689,7 +693,7 @@ tst_run()
CHECKPOINT_WAKE2|CHECKPOINT_WAKE_AND_WAIT);;
DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE|MOUNT_DEVICE);;
SKIP_FILESYSTEMS|SKIP_IN_LOCKDOWN|SKIP_IN_SECUREBOOT);;
- DEVICE_SIZE);;
+ DEVICE_SIZE|USR_UID|USR_GID);;
*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
esac
done
--
2.51.0