[LTP] [PATCH v5 3/8] syscalls/mknod03: Convert to new API
Petr Vorel
pvorel@suse.cz
Fri Jun 6 12:34:12 CEST 2025
Hi Ricardo, all,
...
> - /*
> - * Set the effective group id and user id of the test process
> - * to that of guest user (nobody)
> - */
> - SAFE_SETGID(cleanup, group1_gid);
> - if (setreuid(-1, user1_uid) < 0) {
> - tst_brkm(TBROK, cleanup,
> - "Unable to set process uid to that of ltp user");
> - }
> -
> - /* Save the real group ID of the current process */
> - mygid = getgid();
> -
> - /* Change directory to DIR_TEMP */
> - SAFE_CHDIR(cleanup, DIR_TEMP);
> + SAFE_SETGID(nobody_gid);
> + SAFE_SETREUID(-1, nobody_uid);
> }
> -/*
> - * cleanup() - Performs all ONE TIME cleanup for this test at
> - * completion or premature exit.
> - * Print test timing stats and errno log if test executed with options.
> - * Restore the real/effective user id of the process changed during
> - * setup().
> - * Remove temporary directory and sub-directories/files under it
> - * created during setup().
> - * Exit the test program with normal exit code.
> - */
> -void cleanup(void)
> -{
> -
> - /*
> - * Restore the effective uid of the process changed in the
> - * setup().
> - */
> - if (setreuid(-1, save_myuid) < 0) {
> - tst_brkm(TBROK, NULL,
> - "resetting process real/effective uid failed");
> - }
+1 for avoiding restoring UID in cleanup (I also think that while setreuid(-1,
nobody_uid) in setup is a subject of testing thus needed, restoring UID is
indeed *not* needed. IMHO this is often done i real programs which gain root
in setuid, but that's not the case).
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
More information about the ltp
mailing list