setuid03.c: using TST_EXP_FAIL() and SAFE_SETUID() macros
PATCH v2 1/1 setuid03.c: using TST_EXP_FAIL() and SAFE_SETUID() macros
use TST_EXP_FAIL() with expected errno code, use SAFE_SETUID() in setup and turn comment into docparse
Signed-off-by Avinesh Kumar <[email protected]>
--- testcases/kernel/syscalls/setuid/setuid03.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
testcases/kernel/syscalls/setuid/setuid03.c +6 -15
@@ -1,9 +1,12 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) International Business Machines Corp., 2001 +* Copyright (c) Linux Test Project, 2009-2022 */ -/* DESCRIPTION +/*\ +* [Description] +* * This test will switch to nobody user for correct error code collection. * Verify setuid returns errno EPERM when it switches to root_user. */
@@ -19,16 +22,7 @@static void verify_setuid (void ) { -TEST (SETUID (ROOT_USER )); -if (TST_RET !=-1 ) { -tst_res (TFAIL |TTERRNO ,"setuid() succeeded unexpectedly" ); -return ; - } - -if (TST_ERR ==EPERM ) -tst_res (TPASS ,"setuid() returned errno EPERM" ); -else -tst_res (TFAIL |TTERRNO ,"setuid() returned unexpected errno" ); +TST_EXP_FAIL (SETUID (ROOT_USER ),EPERM ); }static void setup (void )
@@ -39,10 +33,7 @@ static void setup(void) pw =SAFE_GETPWNAM ("nobody" ); uid = pw->pw_uid; -if (SETUID (uid) ==-1 ) { -tst_brk (TBROK , -"setuid() failed to set the effective uid to %d" , uid); - } +SAFE_SETUID (uid);umask (0 ); }
Signature · 5 lines
2.36.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hello,
Merged! thanks
Quoted 58 lines · Avinesh Kumar
use
TST_EXP_FAIL()with expected errno code, useSAFE_SETUID()in setup and turn comment into docparseSigned-off-by Avinesh Kumar <[email protected]>--- testcases/kernel/syscalls/setuid/setuid03.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)testcases/kernel/syscalls/setuid/setuid03.c +6
-15@@ -1,9 +1,12 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) International Business Machines Corp., 2001 +* Copyright (c) Linux Test Project, 2009-2022 */ -/* DESCRIPTION +/*\ +* [Description] +* * This test will switch to nobody user for correct error code collection. * Verify setuid returns errno EPERM when it switches to root_user. */ @@ -19,16 +22,7 @@static void verify_setuid (void ) { -TEST (SETUID (ROOT_USER )); -if (TST_RET !=-1 ) { -tst_res (TFAIL |TTERRNO ,"setuid() succeeded unexpectedly" ); -return ; - } - -if (TST_ERR ==EPERM ) -tst_res (TPASS ,"setuid() returned errno EPERM" ); -else -tst_res (TFAIL |TTERRNO ,"setuid() returned unexpected errno" ); +TST_EXP_FAIL (SETUID (ROOT_USER ),EPERM ); }static void setup (void )@@ -39,10 +33,7 @@ static void setup(void) pw =SAFE_GETPWNAM ("nobody" ); uid = pw->pw_uid; -if (SETUID (uid) ==-1 ) { -tst_brk (TBROK , -"setuid() failed to set the effective uid to %d" , uid); - } +SAFE_SETUID (uid);umask (0 ); }Signature · 1 line
2.36.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp