[LTP] [PATCH 1/2] lib: Add checking of needs_root
Zhao Gongyi
zhaogongyi@huawei.com
Wed Oct 12 11:15:25 CEST 2022
We need to check needs_root is set when tst_test->needs_device or
tst_test->mount_device is set since access the /dev/* need a
privilege.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
lib/tst_test.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 8ccde1629..728a1d921 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1196,6 +1196,11 @@ static void do_setup(int argc, char *argv[])
tst_brk(TBROK, "tst_test->mntpoint must be set!");
}
+ if ((tst_test->needs_device || tst_test->mount_device) &&
+ !tst_test->needs_root) {
+ tst_brk(TBROK, "tst_test->needs_root must be set!");
+ }
+
if (!!tst_test->needs_rofs + !!tst_test->needs_devfs +
!!tst_test->needs_device > 1) {
tst_brk(TBROK,
--
2.17.1
More information about the ltp
mailing list