Marius Burkard
2016-07-10 e1ceb050e19c7574bca146a8da7047ee4ff456b5
server/plugins-available/firewall_plugin.inc.php
@@ -38,7 +38,7 @@
   public function onInstall() {
      global $conf;
      if($conf['bastille']['installed'] = true && $conf['services']['firewall'] == true) {
      if($conf['bastille']['installed'] == true && $conf['services']['firewall'] == true) {
         return true;
      } else {
         return false;
@@ -76,29 +76,31 @@
      global $app, $conf;
      //* load the server configuration options
      $app->uses('getconf');
      $server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
      if($server_config['firewall'] == 'ufw') {
         $this->ufw_update($event_name, $data);
      } else {
         $this->bastille_update($event_name, $data);
      if(!$data['mirrored']) {
         $app->uses('getconf');
         $server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
         if($server_config['firewall'] == 'ufw') {
            $this->ufw_update($event_name, $data);
         } else {
            $this->bastille_update($event_name, $data);
         }
      }
   }
   public function delete($event_name, $data) {
      global $app, $conf;
      //* load the server configuration options
      $app->uses('getconf');
      $server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
      if(!$data['mirrored']) {
         $app->uses('getconf');
         $server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
      if($server_config['firewall'] == 'ufw') {
         $this->ufw_delete($event_name, $data);
      } else {
         $this->bastille_delete($event_name, $data);
         if($server_config['firewall'] == 'ufw') {
            $this->ufw_delete($event_name, $data);
         } else {
            $this->bastille_delete($event_name, $data);
         }
      }
   }
   private function ufw_update($event_name, $data) {
@@ -257,10 +259,12 @@
         }
         exec($conf['init_scripts'] . '/' . 'bastille-firewall restart 2>/dev/null');
         if(@is_file('/etc/debian_version')) exec('update-rc.d bastille-firewall defaults');
         if(@is_file('/sbin/insserv')) exec('insserv -d bastille-firewall');
         $app->log('Restarting the firewall', LOGLEVEL_DEBUG);
      } else {
         exec($conf['init_scripts'] . '/' . 'bastille-firewall stop 2>/dev/null');
         if(@is_file('/etc/debian_version')) exec('update-rc.d -f bastille-firewall remove');
         if(@is_file('/sbin/insserv')) exec('insserv -r -f bastille-firewall');
         $app->log('Stopping the firewall', LOGLEVEL_DEBUG);
      }
@@ -272,6 +276,7 @@
      exec($conf['init_scripts'] . '/' . 'bastille-firewall stop 2>/dev/null');
      if(@is_file('/etc/debian_version')) exec('update-rc.d -f bastille-firewall remove');
      if(@is_file('/sbin/insserv')) exec('insserv -r -f bastille-firewall');
      $app->log('Stopping the firewall', LOGLEVEL_DEBUG);
   }