Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Developers' Forum

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 8th September 2012, 17: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)

Heyo,
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:
/usr/local/ispconfig/server/plugins-available/login_fail2ban_plugin.inc.php
PHP Code:
<?php

class login_fail2ban_plugin {

        var 
$plugin_name 'login_fail2ban_plugin';
        var 
$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() {

                return 
true;

        }


        
/*
                This function is called when the plugin is loaded
        */

        
function onLoad() {
                global 
$app;

                
/*
                Register for the events
                */
                
$app->plugins->registerEvent('login_failed',$this->plugin_name,'log_fail');
        }

        function 
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 login_fail2ban_plugin.inc.php -> /usr/local/ispconfig/server/plugins-available/login_fail2ban_plugin.inc.php*

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/login_fail2ban_plugin.inc.php

Did I miss anything?
Reply With Quote
Sponsored Links
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Spamassasin markasjunk2 roundcube plugin HyperAtom General 1 17th November 2012 20:19
ISPConfig 3.0.4.1 and bind9 pjanzen General 8 13th March 2012 09:34
fail2ban is doing nothing? rlischer Server Operation 16 29th June 2010 07:29
Need help writing new plugin apoana Tips/Tricks/Mods 0 13th February 2010 22:36
Spamassassin not working hairydog2 General 7 12th July 2008 21:15


All times are GMT +2. The time now is 11:39.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.