Some people build software and run the regression tests as root. (Possibly in some restricted environment.) <packager hat>I've been asked to make sure this works.</> Unfortunately, the FLAC tests currently error out in two places if run as root: ===> test_libFLAC ++++++ testing level 1 interface simple iterator on read-only file generating FLAC file for test testing 'metadata.flac'... 0... 1... 2... content... PASSED is writable = 1 ERROR: iterator claims file is writable when tester thinks it should not be; are you running as root? ===> test_libFLAC++ ++++++ testing level 1 interface simple iterator on read-only file generating FLAC file for test testing 'metadata.flac'... 0... 1... 2... content... PASSED is writable = 1 ERROR: iterator claims file is writable when tester thinks it should not be; are you running as root? Can we skip that test when root? Something along the lines of the following...? --- src/test_libFLAC++/metadata_manip.cpp.orig 2022-09-27 20:22:19 UTC +++ src/test_libFLAC++/metadata_manip.cpp @@ -818,13 +818,16 @@ static bool test_level_1_() printf("\n\n++++++ testing level 1 interface\n"); + if(!generate_file_(/*include_extras=*/false, /*is_ogg=*/false)) + return false; + + if (getuid() == 0) + goto next; + /************************************************************/ { printf("simple iterator on read-only file\n"); - if(!generate_file_(/*include_extras=*/false, /*is_ogg=*/false)) - return false; - if(!change_stats_(flacfilename(/*is_ogg=*/false), /*read_only=*/true)) return false; @@ -912,6 +915,7 @@ static bool test_level_1_() } /************************************************************/ +next: { printf("simple iterator on writable file\n"); --- src/test_libFLAC/metadata_manip.c.orig 2022-09-27 20:17:48 UTC +++ src/test_libFLAC/metadata_manip.c @@ -786,11 +786,14 @@ static FLAC__bool test_level_1_(void) /************************************************************/ - printf("simple iterator on read-only file\n"); - if(!generate_file_(/*include_extras=*/false, /*is_ogg=*/false)) return false; + if (getuid() == 0) + goto next; + + printf("simple iterator on read-only file\n"); + if(!change_stats_(flacfilename(/*is_ogg=*/false), /*read_only=*/true)) return false; @@ -874,7 +877,7 @@ static FLAC__bool test_level_1_(void) FLAC__metadata_simple_iterator_delete(iterator); /************************************************************/ - +next: printf("simple iterator on writable file\n"); if(!change_stats_(flacfilename(/*is_ogg=*/false), /*read-only=*/false)) -- Christian "naddy" Weisgerber naddy at mips.inka.de
I think it's a really bad idea to run anything as root, unless absolutely necessary. Isn't this why sudo has become standard? It seems that modern systems do not even have a root account, and expect users to execute most commands with reduced privileges. Skipping a valid test because someone is running as root, when there is no good reason to run as root, is an even worse idea. Tests should always be complete. If the user is using a non-recommended scenario for testing, then the user should be instructed to change the conditions and run the full tests again. The most common situation should be that someone used sudo for the tests, inadvertently, and they could just repeat the same command without sudo to complete the tests. Brian p.s. For security reasons, I always build and test as a normal user without wheel group access. I even run the "make install" process once as a non-root account to verify the list of files that will be written into protected directories. Only after I'm convinced that things will be installed in the correct locations do I use sudo to install with elevated privileges. On Sep 27, 2022, at 1:38 PM, Christian Weisgerber <naddy at mips.inka.de> wrote:> Some people build software and run the regression tests as root. > (Possibly in some restricted environment.) > > <packager hat>I've been asked to make sure this works.</> > > Unfortunately, the FLAC tests currently error out in two places if > run as root: > > ===> test_libFLAC > ++++++ testing level 1 interface > simple iterator on read-only file > generating FLAC file for test > testing 'metadata.flac'... 0... 1... 2... content... PASSED > is writable = 1 > ERROR: iterator claims file is writable when tester thinks it should not be; are you running as root? > > ===> test_libFLAC++ > ++++++ testing level 1 interface > simple iterator on read-only file > generating FLAC file for test > testing 'metadata.flac'... 0... 1... 2... content... PASSED > is writable = 1 > ERROR: iterator claims file is writable when tester thinks it should not be; are you running as root? > > > Can we skip that test when root?
Op di 27 sep. 2022 om 23:27 schreef Christian Weisgerber <naddy at mips.inka.de>:> Some people build software and run the regression tests as root. > (Possibly in some restricted environment.) > > <packager hat>I've been asked to make sure this works.</> >Please provide a rationale. As Brian points out, this is generally frowned upon. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/flac-dev/attachments/20220928/f9806a31/attachment.htm>