[LTP] [PATCH v3 09/12] syscalls/mount03: Copy setuid_test to execute instead of 'TEST FILE'

Punit Agrawal punit.agrawal@arm.com
Fri Dec 8 11:58:11 CET 2017


Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> >>  	case 5:
>> >>  		/* Validate MS_NOSUID flag of mount call */
>> >>  
>> >> -		snprintf(file, PATH_MAX, "%ssetuid_test", path_name);
>> >> -		SAFE_FILE_PRINTF(cleanup, file, "TEST FILE");
>> >> +		TST_RESOURCE_COPY(cleanup, "mount03_setuid_test", path_name);
>> >> +		snprintf(file, PATH_MAX, "%smount03_setuid_test", path_name);
>> >>  
>> >>  		SAFE_STAT(cleanup, file, &file_stat);
>> >>  
>> >> @@ -291,9 +291,8 @@ int test_rwflag(int i, int cnt)
>> >>  				/* reset the setup_uid */
>> >>  				if (status)
>> >>  					return 0;
>> >> -				else
>> >> -					return 1;
>> >>  			}
>> >> +			return 1;
>> >>  		}
>> >>  	case 6:
>> >>  		/* Validate MS_NOATIME flag of mount call */
>> >> @@ -373,6 +372,10 @@ static void setup(void)
>> >>  	strncpy(path, path_name, PATH_MAX);
>> >>  	snprintf(path_name, PATH_MAX, "%s/%s/", path, mntpoint);
>> >>  
>> >> +	SAFE_MOUNT(cleanup, device, mntpoint, fs_type, 0, NULL);
>> >> +	TST_RESOURCE_COPY(cleanup, "mount03_setuid_test", path_name);
>> >> +	SAFE_UMOUNT(cleanup, mntpoint);
>> >
>> > I'm, a bit confused now, do we copy the file here in the setup or in the
>> > actual test above? Surely we don't have to do both.
>> 
>> In an earlier email you said -
>> 
>> "... secondly you are supposed to use the TST_RESOURCE_COPY() macro
>> instead of the function itself and it should be done once in the test
>> setup as well as the code that sets the actual setuid bit."
>> 
>> And now I'm confused as I updated the patch as per your request (or so I
>> thought). Where's the disconnect?
>
> As far as I can see, we do TST_RESOURCE_COPY() twice in this patch, once
> in the test setup and once in the actual test, which is what confuses
> me.

Apologies for not being more specific. We do it twice because in the
quoted text you say (emphasis mine) -

"it should be done _once_ in the test setup _as well as_ the code that
sets the actual setuid bit."

I took that to mean that you're asking for the file to be copied in
setup() as well as in the code before it gets used. Obviously I've
misunderstood your statement. What are you actually suggesting there?

If you aren't actually asking for the file to be copied twice, I am
happy for the superfluous instance to be dropped. :)


More information about the ltp mailing list