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

Update the check_fail2ban script #157

Merged
merged 3 commits into from Apr 9, 2013
Merged

Conversation

labynocle
Copy link
Contributor

Replace the check_fail2ban script by a new one which respects the Nagios specs (like status, output, perfdata, help...).

Also add a README which includes the content of f2ban.txt (which is now removed)

(PR according to a previous discussion)

…ios specs (like status, output, perfdata, help...).

Also add a README which includes the content of f2ban.txt (which is now removed)
# ####################################################################

# ####################################################################
# GPL v3
Copy link
Member

Choose a reason for hiding this comment

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

minor: fail2ban is still under GPL >= 2, so it would be better if this piece also allows GPL v2, or do you have specific reservations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!
Actually I left the copyright of my previous script (some kind of legacy :) ), but I have no reservation to change it in GPL v2.

At this point, I don't know the best practice: do I have to resend a new PR with the previous commits + a new one where I change the license?

Copy link
Member

Choose a reason for hiding this comment

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

just commit to the same branch and push -- usually that commit automagically gets added to the PR. If not -- let us know

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(I just pushed the version with a GPLv2 licence, hope it will be ok for you :) )

@coveralls
Copy link

Changes Unknown when pulling 4473603 on labynocle:master into * on fail2ban:master*.

View Details

@yarikoptic
Copy link
Member

BTW is there a native nagios way to configure invocation of this script (eg env variables?)

I thought to ask myself and then Fabian Wenk also brought up similar ideas on the list: it is possible to run fail2ban in non-root mode, and we have such mode of operation available. So for ideal situation, it would be nice to disable sudo invocation... or may be provide the user to sudo to?

@labynocle
Copy link
Contributor Author

sudo is not mandatory actually.
I just note in the README file a way to run it if the nagios user has no permission to run fail2ban-client command.

So it's not necessary but usually the nagios user have only very restricted permission.

If you want I can update the README file to explain why you could have to use a sudo configuration, just let me know. :)

@yarikoptic
Copy link
Member

I think I just misunderstood originally where I saw "sudo" ;) so it all looks good to me. I just hope that I (or someone else) gives it a try with a working nagios setup before we merge it

You might be interested to look at (or may be even refer in README?) one of the ways how fail2ban could be used for banning without root access: https://github.com/fail2ban/fail2ban/blob/HEAD/doc/run-rootless.txt
Debian distribution's init scripts even provide convenient settings/instructions on how to enable that:
http://github.com/fail2ban/fail2ban/blob/HEAD/debian/fail2ban.default

exit $ERRORS{"UNKNOWN"};
}

if(! -x $fail2ban_client_path) {
Copy link
Member

Choose a reason for hiding this comment

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

I will merge in a sec (if do not find anything else) but would be kind to extend check for if fail2ban-client is present there at all ;) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!
I can add it and it will become more easier for user to debug :)

@yarikoptic yarikoptic merged commit 4473603 into fail2ban:master Apr 9, 2013
@yarikoptic
Copy link
Member

yes -- if you could unify print statements appearance/functionality -- that would be great

Also -- I think it would be even better if you could craft a unittest which would basically just

  • probably derive from Transmitter test class in servertestcase.py which already starts a server
  • similar to other tests add some jail
  • invoke your script providing it with correct paths to the client and socket and testing all basic commands it provides.

if we had such a unittest -- we could have some assurance that things work as they should!

we might need to have perl installed for tests, but well -- that shouldn't be difficult ;)

@labynocle
Copy link
Contributor Author

Ok let me see what can I do with it! :)

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

3 participants