[LTP] [PATCH] setresuid04.c: Rewrite the test using new LTP API

Li Wang liwang@redhat.com
Thu Dec 8 04:37:08 CET 2022


Hi Avinesh,

Avinesh Kumar <akumar@suse.de> wrote:

> -               /* Test 2: Check a son process cannot open the file
> -                *         with RDWR permissions.
> -                */
> -               pid = FORK_OR_VFORK();
> -               if (pid < 0)
> -                       tst_brkm(TBROK, NULL, "Fork failed");
> -
> -               if (pid == 0) {
> -                       int tst_fd2;
> +       SAFE_SETRESUID(0, ltpuser->pw_uid, 0);

There is no reason to modify 'real UID' and 'saved set-user-ID'
at this time, we do only care about 'effective UID' made changes
successfully or not.

So I tweaked the patch a tiny and merged it:

--- a/testcases/kernel/syscalls/setresuid/setresuid04.c
+++ b/testcases/kernel/syscalls/setresuid/setresuid04.c
@@ -40,7 +40,7 @@ static void run(void)
        pid_t pid;
        int status;

-       SAFE_SETRESUID(0, ltpuser->pw_uid, 0);
+       SAFE_SETRESUID(-1, ltpuser->pw_uid, -1);
        TST_EXP_FAIL2(open(TEMP_FILE, O_RDWR), EACCES);

        pid = SAFE_FORK();


-- 
Regards,
Li Wang



More information about the ltp mailing list