[LTP] [PATCH] setfsgid01: Rewrite using new LTP API

Avinesh Kumar akumar@suse.de
Tue Oct 25 08:37:29 CEST 2022


Hi Petr,

On Saturday, October 22, 2022 4:28:39 AM IST Petr Vorel wrote:
> Hi Avinesh,
> 
> > Rewrite using new API and add test setfsgid(-1) which will always
> > fail but will determine if the preceding setfsgid() call changed
> > the filesystem group ID as expected.
> +1
> 
> Thanks, merged with fix below.
> 
> > -		gid = getegid();
> > -		GID16_CHECK(gid, setfsgid, cleanup);
> > -
> > -		TEST(SETFSGID(cleanup, gid));
> > -
> > -		if (TEST_RETURN == -1) {
> > -			tst_resm(TFAIL | TTERRNO,
> > -				"setfsgid() failed unexpectedly");
> > -			continue;
> > -		}
> > -
> > -		if (TEST_RETURN != gid) {
> > -			tst_resm(TFAIL, "setfsgid() returned %ld, expected %d",
> > -				 TEST_RETURN, gid);
> > -		} else {
> > -			tst_resm(TPASS,
> > -				"setfsgid() returned expected value : %ld",
> > -				TEST_RETURN);
> > -		}
> > -	}
> ...
> > +	gid = getegid();
> > +	GID16_CHECK(gid, setfsgid);
> 
> > -static void cleanup(void)
> > -{
> > +	SAFE_SETEUID(0);
> > +	TST_EXP_VAL(setfsgid(nobody_gid), gid);
> > +	TST_EXP_VAL(setfsgid(-1), nobody_gid);
> > +	TST_EXP_VAL_SILENT(setfsgid(gid), nobody_gid);
> 
> NOTE: all of these needed to be SETFSGID(), otherwise setfsgid01_16 would
> happily test 32-bit version instead of 16-bit version.
Thank you for this correction, will keep 16-bit thing in mind.

> 
> Kind regards,
> Petr
> 

Regards,
Avinesh





More information about the ltp mailing list