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

Adds a Configure question for selecting whether you want taint supported #19541

Merged
merged 5 commits into from
Apr 20, 2022
Merged

Adds a Configure question for selecting whether you want taint supported #19541

merged 5 commits into from
Apr 20, 2022

Conversation

neilb
Copy link
Contributor

@neilb neilb commented Mar 17, 2022

This adds a Configure question for whether you want to build perl with or without taint support.
It defaults to "yes", but you can build a perl without taint support by running:

$ ./Configure -Dusedevel -des -Utaint_support

This results in perl being compiled with the previously added SILENT_NO_TAINT_SUPPORT symbol, which means that taint features silently do nothing.

Previously though, if you compiled with that option, a bunch of tests would fail, and there was no easy way to tell from Perl land whether your perl supports taint. Now there's a Configure variable taint_support, which you can query in %Config.

This PR fixes all relevant test suites so that relevant tests are skipped under a taint-free perl. I've included commits for the CPAN-upstream dual-life modules, but they shouldn't be merged. I've submitted pull requests on the four affected distributions (Encode, Scalar-List-Utils, Text-ParseWords, and Test-Harness), so the changes should make it to blead via CPAN releases on those.

The change to Configure came from changes to metaconfig, which I've submitted a separate pull request on.

neilb added 4 commits March 16, 2022 23:56
This adds a Configure question for whether you want taint support.
It defaults to "yes", so that ./Configure -des will build a perl
which supports taint in the usual way.
If you say "no", then perl is compiled with -DSILENT_NO_TAINT_SUPPORT
so that taint features silently do nothing.

I've submitted a separate pull request on perl/metaconfig,
which adds the underlying metaconfig unit for this question,
which was used to build this Configure script.
The central doc change is in perlsec.pod. This not only explains
that you can build a perl that doesn't support taint,
but shows how you can check whether your perl supports taint or not.
The other doc changes are mainly to note that taint might not
be supported, and to refer the reader to perlsec for more details.
@@ -34,6 +35,9 @@ use warnings;
my $is_ebcdic = ord("A") == 193;
my $os = lc $^O;

# Configure now lets you build a perl that silently ignores taint features
my $NoTaintSupport = exists($Config{taint_support}) && !$Config{taint_support};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exists check shouldn't be necessary, as this test is core-only

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While not necessary in core, I think it's worth leaving as-is, in case people look in core files to see how to check for taint support in their modules. I've documented it in perlsec, and will blog about it, but I reckon some people will just just look for examples in the perl dist.

@demerphq
Copy link
Collaborator

It feels to me that instead of having a configure key 'taint_support' that it should have been 'taint_disabled', which would be a much simpler check to implement and wouldn't need the exists check. Not saying this is a show stopper, but it feels backwards to introduce a new variable that you have to test for with exists to see if its defined. Is there a reason you did it this way?

@neilb
Copy link
Contributor Author

neilb commented Apr 14, 2022

It feels to me that instead of having a configure key 'taint_support' that it should have been 'taint_disabled', which would be a much simpler check to implement and wouldn't need the exists check. [...] Is there a reason you did it this way?

That is what I initially created, but on reviewing with @Tux, he asked me to switch the sense, saying it fit better with Configure precedent, and was less likely to confuse people. I bought his argument.

@neilb
Copy link
Contributor Author

neilb commented Apr 18, 2022

The four CPAN upstream distributions (Encode, Scalar-List-Utils, Text-ParseWords, and Test-Harness) have now all had their PRs merged, so this can now be merged, ignoring the four commits marked "DO NOT MERGE".

I'd like to make the case for this to be merged in time for 5.35.11 so it can be included in 5.36.0:

  • It's a Configure change, so not user visible
  • The default is to build a perl with taint support, so the default is "no change".

@Tux
Copy link
Contributor

Tux commented Apr 19, 2022

I just looked at the Configure related changes, and those LGTM.

@rjbs
Copy link
Member

rjbs commented Apr 19, 2022

I think this is probably ready to go in now.

@neilb
Copy link
Contributor Author

neilb commented Apr 19, 2022

With Rik's help I just dropped the commits for the four CPAN-upstream dual-life modules, so this can now be merged as-is.

Copy link
Contributor

@leonerd leonerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@demerphq
Copy link
Collaborator

demerphq commented Oct 11, 2022 via email

@Leont
Copy link
Contributor

Leont commented Oct 11, 2022

I think it is very much the opposite. This is disabling something that
used to always be on. Adding a new property that says it is on just means
you have the complexity of telling apart two falses, key exists and it is
false and key doesn't exist (which is also a false) which actually means it
is true. It will make everyone /else/ have to deal with the complexity,
instead of dealing with it in one place neatly.

Yeah, the current solution optimizes for Configure at the cost of modules authors.

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.

6 participants