View Single Post
Old 8th September 2012, 18:41
phry phry is offline
Junior Member
Join Date: Sep 2012
Posts: 5
Thanks: 0
Thanked 4 Times in 2 Posts
Default Writing a simple plugin (fail2ban integration)

I wanted to log wrong logins into syslog so that fail2ban can parse it and ban the attacker's IP.
- Yes, I know, ISPConfig has a similar feature but I want to do this nonetheless.
- Yes, I know, ISPConfig logs wrong logins too, but only on DEBUG Level and I don't want the clutter. Neither do I want to change ispconfig files.

So I wrote a quick plugin:
PHP Code:

class login_fail2ban_plugin {

$plugin_name 'login_fail2ban_plugin';
$class_name  'login_fail2ban_plugin';

//* This function is called during ispconfig installation to determine
        //  if a symlink shall be created for this plugin.
function onInstall() {



                This function is called when the plugin is loaded

function onLoad() {

                Register for the events

log_failed($event_name,$data) {
openlog("ispconfig"LOG_PID LOG_PERRORLOG_LOCAL0);
syslog(LOG_WARNING"Login failed for user $_POST['username'] on IP $_SERVER['REMOTE_ADDR']");

// end class

and then I created a symlink in /usr/local/ispconfig/server/plugins-enabled
lrwxrwxrwx 1 ispconfig ispconfig 75 Sep 8 17:39 -> /usr/local/ispconfig/server/plugins-available/*

But here's the catch: it doesn't load. I tried writing stuff into the onLoad function, too - is doesn't execute.
Permissions and owner are set correctly, too:
-rwxr-x--- 1 ispconfig ispconfig 766 Sep 8 17:29 plugins-available/

Did I miss anything?
Reply With Quote
Sponsored Links