Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip tainting tests if perl was built without taint support #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

neilb
Copy link

@neilb neilb commented Apr 20, 2022

From Perl 5.35.11 onwards, Configure lets you build a perl without taint support.

These changes skip tests that rely on taint support, so that this distribution can be installed under such a perl.

@jkeenan
Copy link
Collaborator

jkeenan commented Apr 21, 2022

@neilb, problem!

When I finally manage to correctly configure and build a no-taint perl on my principal FreeBSD-12 machine, I get test failures ... and then one test file stops abruptly, necessitating a Ctrl-C.

$ pwd
/usr/home/jkeenan/gitwork/ipc-system-simple

$ bleadperl -v | head -2 | tail -1
This is perl 5, version 35, subversion 12 (v5.35.12 (v5.35.11-9-g99db5f9692)) built for amd64-freebsd-thread-multi

$ bleadperl -V:config_args
config_args='-des -Dusedevel -Uversiononly -Dprefix=/home/jkeenan/testing/blead -Dman1dir=none -Dman3dir=none -Duseithreads -Doptimize=-O2 -pipe -fstack-protector -fno-strict-aliasing -Utaint_support';

$ bleadperl -MConfig -E \
> 'say "taint: ", !exists($Config{taint_support}) || $Config{taint_support} ? "yes" : "no";'
taint: no

$ bleadperl Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for IPC::System::Simple
Writing MYMETA.yml and MYMETA.json

$ make
cp lib/IPC/System/Simple.pm blib/lib/IPC/System/Simple.pm

$ make test
PERL_DL_NONLAZY=1 "/usr/home/jkeenan/testing/blead/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01_load.t ........... ok   
t/02_exit.t ........... ok     
t/03_signal.t ......... ok   
t/04_capture.t ........ ok     
t/05_multi_capture.t .. ok     
t/06_fail.t ........... ok   
t/07_taint.t .......... 1/13 
#   Failed test 'Sanity - executable name is tainted'
#   at t/07_taint.t line 21.

#   Failed test 'Sanity - Evil zero is tainted'
#   at t/07_taint.t line 25.

#   Failed test 'Single-arg, tainted data'
#   at t/07_taint.t line 41.
#                   ''
#     doesn't match '(?^:called with tainted argument)'

#   Failed test 'multi-arg, tainted data'
#   at t/07_taint.t line 44.
#                   ''
#     doesn't match '(?^:called with tainted argument)'

#   Failed test 'Returns of multi-arg capture should be tainted'
#   at t/07_taint.t line 53.

#   Failed test 'Returns of single-arg capture should be tainted'
#   at t/07_taint.t line 56.
# Looks like you failed 6 tests of 13.
t/07_taint.t .......... Dubious, test returned 6 (wstat 1536, 0x600)
Failed 6/13 subtests 
	(less 2 skipped subtests: 5 okay)
t/08_core.t ........... ok   
t/09_system.t ......... ok     
t/10_formatting.t ..... 1/5 ^C*** Signal 2

I believe there has been a segfault.

$ gitst
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	t/perl.core

nothing added to commit but untracked files present (use "git add" to track)

Attempting the remaining tests with a prove built on this perl:

$ bleadprove -b t/11_newlines.t t/12_systemx.t t/13_exports.t t/14_uninitialised.t t/args.t t/internal.t t/win32.t
t/11_newlines.t ....... ok   
t/12_systemx.t ........ ok   
t/13_exports.t ........ ok   
t/14_uninitialised.t .. ok   
t/args.t .............. ok     
t/internal.t .......... ok   
t/win32.t ............. skipped: Win32 only tests
All tests successful.
Files=7, Tests=75,  1 wallclock secs ( 0.06 usr  0.02 sys +  0.58 cusr  0.15 csys =  0.80 CPU)
Result: PASS

@jkeenan
Copy link
Collaborator

jkeenan commented Apr 21, 2022

Double-checking now; I think I was working in master.

@jkeenan
Copy link
Collaborator

jkeenan commented Apr 21, 2022

When I switch to your branch, all tests PASS -- but there's a segfault!

[perlmonger: ipc-system-simple] $ bleadperl Makefile.PL && make
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for IPC::System::Simple
Writing MYMETA.yml and MYMETA.json
cp lib/IPC/System/Simple.pm blib/lib/IPC/System/Simple.pm
[perlmonger: ipc-system-simple] $ make test
PERL_DL_NONLAZY=1 "/usr/home/jkeenan/testing/blead/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01_load.t ........... ok   
t/02_exit.t ........... ok     
t/03_signal.t ......... ok   
t/04_capture.t ........ ok     
t/05_multi_capture.t .. ok     
t/06_fail.t ........... ok   
t/07_taint.t .......... skipped: your perl was built without taint support
t/08_core.t ........... ok   
t/09_system.t ......... ok     
t/10_formatting.t ..... ok   
t/11_newlines.t ....... ok   
t/12_systemx.t ........ ok   
t/13_exports.t ........ ok   
t/14_uninitialised.t .. ok   
t/args.t .............. ok     
t/internal.t .......... ok   
t/win32.t ............. skipped: Win32 only tests
All tests successful.
Files=17, Tests=173,  2 wallclock secs ( 0.05 usr  0.04 sys +  1.48 cusr  0.34 csys =  1.91 CPU)
Result: PASS
[perlmonger: ipc-system-simple] $ gitst
On branch no-taint
Your branch is up to date with 'neilb/no-taint'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	t/perl.core

nothing added to commit but untracked files present (use "git add" to track)

The segfault appears to be occuring when running t/08_core.t:

[perlmonger: ipc-system-simple] $ bleadperl -MBSD::Resource -E 'say qq|hello world|;'
hello world
[perlmonger: ipc-system-simple] $ bleadprove -vb t/08_core.t 
t/08_core.t .. 
1..3
ok 1 - use IPC::System::Simple;
ok 2 - Signal caught,   $? = 134
ok 3 - Coredump caught, $? = 134
ok
All tests successful.
Files=1, Tests=3,  0 wallclock secs ( 0.02 usr  0.02 sys +  0.09 cusr  0.03 csys =  0.16 CPU)
Result: PASS
[perlmonger: ipc-system-simple] $ gitst
On branch no-taint
Your branch is up to date with 'neilb/no-taint'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	t/perl.core

nothing added to commit but untracked files present (use "git add" to track)

@jkeenan
Copy link
Collaborator

jkeenan commented Apr 21, 2022

When I switch to your branch, all tests PASS -- but there's a segfault!

Upon further investigation, this appears to be IPC-System-Simple's problem, not the problem of -Utaint_support in Perl 5 blead.

On my FreeBSD machine, the BSD::Resource module had never been installed against the "system" perl, which is perl-5.32.1. So whenever I previously tested IPC::System::Simple, t/08_core.t was (correctly) being skipped. So the core dump (apparently generated for testing purposes) was never generated. Once I have installed BSD::Resource against any perl, the test is executed and a core dump is generated -- but the test program doesn't clean up after itself.

@jkeenan
Copy link
Collaborator

jkeenan commented Apr 21, 2022

And just to be self-aggravating ... it appears the core dump is not generated on Linux, with or without taint support. Inside t/08_core.t I see the following:

# Core dumps on OS X are complicated. See GH #5.

BEGIN {
    if ($^O eq 'darwin') {
        plan skip_all => "Coredump tests skipped under OS X/Darwin";
    }
}

So maybe @pjf encountered this problem on OS X, which is a descendant of FreeBSD.

@jkeenan
Copy link
Collaborator

jkeenan commented Apr 22, 2022

@neilb, I'm inclined to accept your pull request, but am going to hold off a bit, given that some problems with support for no-taint perls have been raised in Perl/perl5#19657.

@neilb
Copy link
Author

neilb commented Apr 22, 2022

@neilb, I'm inclined to accept your pull request, but am going to hold off a bit, given that some problems with support for no-taint perls have been raised in Perl/perl5#19657.

I agree that it's best to hold off until we resolve that issue. I'll close this if it comes to that.

@neilb
Copy link
Author

neilb commented Apr 23, 2022

Closing this, as the current implementation of the Configure question is going to be reverted.
I'll be back ;-)

@jkeenan
Copy link
Collaborator

jkeenan commented Apr 22, 2023

Closing this, as the current implementation of the Configure question is going to be reverted. I'll be back ;-)

@neilb, please see #43, wherein @DrHyde encountered what looks to be the same problem you did last year at this time. Thoughts?

@jkeenan jkeenan reopened this Apr 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants