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

remove '.' from @INC #181

Merged
merged 1 commit into from
Dec 18, 2017
Merged

remove '.' from @INC #181

merged 1 commit into from
Dec 18, 2017

Conversation

ttyS4
Copy link
Contributor

@ttyS4 ttyS4 commented Dec 15, 2017

As described in the link below:
http://search.cpan.org/dist/perl-5.26.0/pod/perldelta.pod#Removal_of_the_current_directory_(%22.%22)_from_@INC

Perls before 5.26 include dot in INC unless taint mode is enabled.
Most script supplied by quattor does have taint enabled except a few.

Here I am using the recommendation to remove dot from @INC. This is safe
invocation as if someone enables taint mode or upgrades perl it still does the
right thing.

As described in the link below:
http://search.cpan.org/dist/perl-5.26.0/pod/perldelta.pod#Removal_of_the_current_directory_(%22.%22)_from_@INC

Perls before 5.26 include dot in INC unless taint mode is enabled.
Most script supplied by quattor does have taint enabled except a few.

Here I am using the recommendation to remove dot from @inc. This is safe
invocation as if someone enables taint mode or upgrades perl it still does the
right thing.
@ned21 ned21 added this to the 17.12 milestone Dec 16, 2017
@ned21
Copy link
Contributor

ned21 commented Dec 16, 2017

@jrha @stdweird It would be good to see this in 17.12 as ncm-ccm calls ccm-fetch with a CWD of /tmp (which should probably also be changed).

@@ -10,6 +10,7 @@ use warnings;
# required for CAF
BEGIN {
unshift(@INC, '/usr/lib/perl');
pop @INC if $INC[-1] eq '.';
Copy link
Member

Choose a reason for hiding this comment

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

title should be changed to "only remove '.' when it's the last element in INC".
or replace the BEGIN block with (untested)

BEGIN {
    @INC = ('/usr/lib/perl', grep {$_ ne '.'} @INC);
}

btw, this should be turned in a template in maven-tools, i made quattor/maven-tools#169

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea comes from here (a respected member of the perl community):
https://www.masteringperl.org/2017/01/perl-v5-26-removes-from-inc-but-dont-think-youre-safe/

dot is always last in INC so it should suffice.

Copy link
Member

Choose a reason for hiding this comment

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

ok, i wasn't sure. can you also open an issue to switch remaining scripts to taint mode, so this isn't forgotten?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@jrha jrha merged commit 147f020 into quattor:master Dec 18, 2017
ttyS4 added a commit to quattor/ncm-query that referenced this pull request Jan 24, 2018
This is the same as in quattor/CCM#181
ttyS4 added a commit to quattor/ncm-query that referenced this pull request Jan 24, 2018
This is the same as in quattor/CCM#181
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants