Skip to content

Support overriding configuration for default jails - #145

Open
deric wants to merge 2 commits into
voxpupuli:masterfrom
deric:custom_ports
Open

Support overriding configuration for default jails#145
deric wants to merge 2 commits into
voxpupuli:masterfrom
deric:custom_ports

Conversation

@deric

@deric deric commented Apr 29, 2020

Copy link
Copy Markdown
Contributor

The PR addresses the same issue as #48 but with a bit more generic approach.

Using 2 level Hash might be possible to override basically any attribute in the template.

fail2ban::jails:
  - ssh
  - ssh-ddos
fail2ban::jails_config:
  ssh:
    port: 'ssh,2200'
  ssh-ddos:
    port: 'ssh,2200'

Using lookup() in templates might not be the best approach, but I can't think of better alternative. Passing explicitly each variable explicitly to the template would generate loads of code. Another option is to write a custom function for checking key existence in the configuration hash (but it doesn't add much to code readability).

Let me know if you're ok with this, so that I'm able to proceed with modifying rest of jails.

@vox-pupuli-tasks

Copy link
Copy Markdown

Dear @deric, thanks for the PR!

This is pccibot, your friendly Vox Pupuli GitHub Bot. I noticed that your pull request contains merge conflict. Can you please rebase?

You can find my sourcecode at voxpupuli/vox-pupuli-tasks

1 similar comment
@vox-pupuli-tasks

Copy link
Copy Markdown

Dear @deric, thanks for the PR!

This is pccibot, your friendly Vox Pupuli GitHub Bot. I noticed that your pull request contains merge conflict. Can you please rebase?

You can find my sourcecode at voxpupuli/vox-pupuli-tasks

@vox-pupuli-tasks

Copy link
Copy Markdown

Dear @deric, thanks for the PR!

This is pccibot, your friendly Vox Pupuli GitHub Bot. I noticed that your pull request contains merge conflict. Can you please rebase?

You can find my sourcecode at voxpupuli/vox-pupuli-tasks

@r3pek

r3pek commented Apr 29, 2020

Copy link
Copy Markdown

This.... I was just looking for a way to do this :) Hope it get's merged.

@deric

deric commented Apr 30, 2020

Copy link
Copy Markdown
Contributor Author

@bastelfreak There's slight inconsistency in naming. The sshd jail is enabled using ssh:

fail2ban::jails:
  - ssh

while for all other jails it seems to match the jail name. I guess this should be kept for backward compatibility?

@bastelfreak

bastelfreak commented Apr 30, 2020

Copy link
Copy Markdown
Member

mmh good question. I guess we should stay backwards compatible. There are no other breaking changes at the moment (sometimes they are needed, but we try to always release a bunch of them).

@r3pek

r3pek commented Apr 30, 2020

Copy link
Copy Markdown

@deric since you're at it, there's no ssh-ddos on centos 7 either.... (at least none of my installs has it)

@deric

deric commented Apr 30, 2020

Copy link
Copy Markdown
Contributor Author

@r3pek Yeah, I've noticed. It looks like Debian 8 it the only anomaly with ssh and ssh-ddos jails (probably with much older fail2ban version than in other distributions).

It will avoid confusion in the future if we will support both names and documentation should probably mention just sshd and sshd-ddos.

@r3pek

r3pek commented Jul 17, 2020

Copy link
Copy Markdown

any status update on this?

@r3pek

r3pek commented Aug 24, 2020

Copy link
Copy Markdown

hello? sorry the ping ;)

@bastelfreak

Copy link
Copy Markdown
Member

@deric is this still WIP?

@deric

deric commented Aug 26, 2020

Copy link
Copy Markdown
Contributor Author

Yes, sorry. I'll try to finish this soon.

Comment thread spec/acceptance/class_spec.rb Outdated

@igalic igalic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👀

Comment thread templates/CentOS/6/etc/fail2ban/jail.conf.epp Outdated
Comment thread templates/CentOS/7/etc/fail2ban/jail.conf.epp Outdated
@r3pek

r3pek commented Jan 6, 2021

Copy link
Copy Markdown

sorry the ping guys, any news about this?

@deric deric changed the title [WIP] Support overriding configuration for default jails Support overriding configuration for default jails Jun 7, 2022
@deric

deric commented Jun 7, 2022

Copy link
Copy Markdown
Contributor Author

Debian 8

  • is running on very old version 0.8.13
  • config file is very different from other distributions
  • many jail might be supported, just missing config section (vsftpd, squid, ...). But probably doesn't matter since Debian 8 is long after EOL.

Ubuntu 18.04 and 20.04

  • exim was missing enabled line:
enabled = <%= 'exim' in $fail2ban::jails %>

Ubuntu 16.04

  • courier-auth was searching for courierauth key (missing dash) in $fail2ban::jails (Debian 8 uses the same but there's consistent name of the jail).
  • In postfix-sasl jail config key is called sasl

CentOS 6, 7, RedHat 8, 8, OpenSuse 15

  • enabled looked for squierrelmail (typo) config key instead of squirrelmail

CentOS 6, 7

  • is missing mongodb-auth jail config (should be supported, haven't tested yet)

@deric

deric commented Jun 7, 2022

Copy link
Copy Markdown
Contributor Author

The config hash jails_config currently supports mixture of Strings and Integers:

fail2ban::jails_config:
  ssh:
    port: ssh,2200
  dropbear:
    port:
      - ssh
      - 2201
  selinux-ssh:
    port:
      - 'ssh'
      - '2202'

with little extra effort it might be possible to convert current Array config:

fail2ban::jails:
  - ssh
  - ssh-ddos

to Hash:

fail2ban::jails:
   ssh:
     port: 22
   nginx-botsearch:

while supporting the old syntax (in order to change ports converting to Hash would be necessary).

@bastelfreak , @igalic Let me know, what you think. Making this change later might be complicated.

For most jails it should be possible to change the port, the remaining ones might be modified in separate PRs. Please squash the commits before merging.

@deric
deric force-pushed the custom_ports branch 3 times, most recently from e8d6588 to 35299b6 Compare June 14, 2023 09:33
@deric
deric force-pushed the custom_ports branch 2 times, most recently from db5582a to c295954 Compare June 14, 2023 10:23
@deric
deric requested review from bastelfreak and igalic June 14, 2023 11:58
@deric
deric force-pushed the custom_ports branch 4 times, most recently from a94d546 to 919fe92 Compare September 26, 2024 11:14
@deric

deric commented Sep 26, 2024

Copy link
Copy Markdown
Contributor Author

@Dan33l All conflicts have been resolved, could you have a look at it?

@deric

deric commented Aug 13, 2025

Copy link
Copy Markdown
Contributor Author

@bastelfreak Could you please have a look at this?

Comment thread functions/port.pp Outdated
Comment thread manifests/init.pp Outdated
deric added 2 commits August 13, 2025 15:07
 - `fail2ban::port` function to simplify syntax
 - Include param tags
 - Update reference
@deric

deric commented Aug 13, 2025

Copy link
Copy Markdown
Contributor Author

@bastelfreak Also Debian 13 config has been updated, common jails should be covered by tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants