Add verbose setup to creat08, creat09 and open10
PATCH 1/2 Add verbose setup to creat08, creat09 and open10
These tests are sensitive to proper UID/GID configuration so print the detected values for debugging purposes in case of test failure.
Signed-off-by Martin Doucha <[email protected]>
--- lib/tst_uid.c | 5 ++++- testcases/kernel/syscalls/creat/creat08.c | 2 ++ testcases/kernel/syscalls/creat/creat09.c | 2 ++ testcases/kernel/syscalls/open/open10.c | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-)
lib/tst_uid.c +4 -1
@@ -23,8 +23,11 @@ gid_t tst_get_free_gid_(const char *file, const int lineno, gid_t skip)if (ret == skip ||getgrgid (ret))continue ; -if (errno ==0 || errno ==ENOENT || errno ==ESRCH ) +if (errno ==0 || errno ==ENOENT || errno ==ESRCH ) { +tst_res_ (file, lineno,TINFO |TERRNO , +"Found unused GID %d" , (int )ret);return ret; + }tst_brk_ (file, lineno,TBROK |TERRNO ,"Group ID lookup failed" );return (gid_t)-1 ;
testcases/kernel/syscalls/creat/creat08.c +2 -0
@@ -41,6 +41,8 @@ static void setup(void) orig_uid =getuid (); nobody_uid = ltpuser->pw_uid; nobody_gid = ltpuser->pw_gid; +tst_res (TINFO ,"User nobody: uid = %d, gid = %d" , (int )nobody_uid, + (int )nobody_gid); free_gid =tst_get_free_gid (nobody_gid); tmpdir =tst_get_tmpdir (); }
testcases/kernel/syscalls/creat/creat09.c +2 -0
@@ -41,6 +41,8 @@ static void setup(void)struct stat buf;struct passwd *ltpuser =SAFE_GETPWNAM ("nobody" ); +tst_res (TINFO ,"User nobody: uid = %d, gid = %d" , (int )ltpuser->pw_uid, + (int )ltpuser->pw_gid); free_gid =tst_get_free_gid (ltpuser->pw_gid);/* Create directories and set permissions */
testcases/kernel/syscalls/open/open10.c +2 -0
@@ -39,6 +39,8 @@ static void setup(void) orig_uid =getuid (); nobody_uid = ltpuser->pw_uid; nobody_gid = ltpuser->pw_gid; +tst_res (TINFO ,"User nobody: uid = %d, gid = %d" , (int )nobody_uid, + (int )nobody_gid); free_gid =tst_get_free_gid (nobody_gid); tmpdir =tst_get_tmpdir (); }
Signature · 1 line
2.32.0
PATCH 2/2 tst_get_free_gid(): Skip GID 0
tst_get_free_gid() may return GID 0 on systems where /etc/group (or another database of user groups) does not exist. But GID 0 exists implicitly and it may stay after setgid() as a supplemental group of the test process if it was executed with root privileges. Skip GID 0 to avoid unexpected test failures.
Signed-off-by Martin Doucha <[email protected]>
--- lib/tst_uid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tst_uid.c +1 -1
@@ -19,7 +19,7 @@ gid_t tst_get_free_gid_(const char *file, const int lineno, gid_t skip) errno =0 ; -for (ret =0 ; ret <MAX_GID ; ret++) { +for (ret =1 ; ret <MAX_GID ; ret++) {if (ret == skip ||getgrgid (ret))continue ;
Signature · 1 line
2.32.0
PATCH 2/2 tst_get_free_gid(): Skip GID 0
Hi!
Good catch, both patches pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]