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

Don't set Allow from all by default for apache::vhost::directories #416

Merged
merged 1 commit into from
Nov 21, 2013

Conversation

RPDiep
Copy link
Contributor

@RPDiep RPDiep commented Oct 24, 2013

Do not to set Allow from all when either Deny from all is set or allow is set empty or false in apache::vhost::directories

@@ -28,8 +28,11 @@
<%- if directory['deny'] and directory['deny'] != '' -%>
Deny <%= directory['deny'] %>
<%- end -%>
<%- if directory['allow'] and directory['allow'] != '' -%>
<%- if directory['allow'] and ! [ false, 'false', '' ].include? directory['allow'] -%>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably nitpicking but can we reverse these to be:

and ! directory['allow'].include?([ false, 'false', '' ])

Mostly just as I find it confusing to read in reverse. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I understand, directory['allow'].include?([ false, 'false', '' ]) is not correct in ruby.
As directory['allow'] is likely to be a string, the include? method only accepts a string as parameter. (Please correct me if I'm wrong here.)
I will however put parentheses around directory['allow'] for clarity's sake.

Copy link
Contributor

Choose a reason for hiding this comment

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

Another way to express this differently in ruby would be to check for an intersection:

<%- f = [ false, :false, 'false', ''] -%
<%- if ( [directory['allow']] & f ) == [directory['allow']] -%>

We create an array f with all valid values for false. This way we can now short-circuit the check whether directory['allow'] is set or not, since nil is not part of f. Witness:

irb(main):001:0> f = [ false, :false, 'false', '' ]
=> [false, :false, "false", ""]
irb(main):002:0> ( f & [directory['allow']]) == [directory['allow']]
NameError: undefined local variable or method `directory' for main:Object
        from (irb):2
        from /usr/bin/irb:12:in `<main>'
irb(main):004:0> directory = {}
=> {}
irb(main):005:0> ( f & [directory['allow']]) == [directory['allow']]
=> false
irb(main):008:0> directory = { 'allow' => false }
=> {"allow"=>false}
irb(main):009:0> ( f & [directory['allow']]) == [directory['allow']]
=> true
irb(main):010:0>

This other way to express the same intent may not necessarily be a better way ;)

@igalic
Copy link
Contributor

igalic commented Nov 8, 2013

could you please amend your commit message to be a little more descriptive than "fix for link to $issue-tracker-link'

i.e.: What does this change do? (and if it is interesting enough, how does it do that?)

@igalic
Copy link
Contributor

igalic commented Nov 18, 2013

Hey, @RPDiep,

could you please rebase, squash these commits and make the commit message a bit easier to understand. Please see our CONTRIBUTING

@RPDiep
Copy link
Contributor Author

RPDiep commented Nov 18, 2013

Yes, I will do that. Expect it tomorrow.

@RPDiep
Copy link
Contributor Author

RPDiep commented Nov 19, 2013

Rebased and squashed as requested.

igalic added a commit that referenced this pull request Nov 21, 2013
Don't set `Allow from all` by default for apache::vhost::directories
@igalic igalic merged commit 7351991 into puppetlabs:master Nov 21, 2013
traylenator pushed a commit to traylenator/puppetlabs-apache that referenced this pull request Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants