aboutsummaryrefslogtreecommitdiffstats
path: root/config/denyhosts/denyhosts.inc
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2015-02-05 10:02:24 -0200
committerRenato Botelho <garga@FreeBSD.org>2015-02-05 20:10:15 -0200
commit07cf2c4b20230ddedee1bf9dddc1e7cd407385f5 (patch)
tree44d40561519e0018ad586bb1449e107c9ae431f3 /config/denyhosts/denyhosts.inc
parente526e4aa28867b7743b0e76993f5f6bebd15bc1b (diff)
downloadpfsense-packages-07cf2c4b20230ddedee1bf9dddc1e7cd407385f5.tar.gz
pfsense-packages-07cf2c4b20230ddedee1bf9dddc1e7cd407385f5.tar.bz2
pfsense-packages-07cf2c4b20230ddedee1bf9dddc1e7cd407385f5.zip
Packages repo cleanup:
- Drop support for pfSense < 2 - Remove archive/, old files can be reached using git - Remove old and unused packages - Move stale files from config subdir to a package subdir
Diffstat (limited to 'config/denyhosts/denyhosts.inc')
-rw-r--r--config/denyhosts/denyhosts.inc199
1 files changed, 0 insertions, 199 deletions
diff --git a/config/denyhosts/denyhosts.inc b/config/denyhosts/denyhosts.inc
deleted file mode 100644
index 37209715..00000000
--- a/config/denyhosts/denyhosts.inc
+++ /dev/null
@@ -1,199 +0,0 @@
-<?php
-/* $Id$ */
-/*
-/* ========================================================================== */
-/*
- denyhosts.inc
- Copyright (C) 2009 Mark J Crane
- All rights reserved.
- */
-/* ========================================================================== */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-function denyhosts_sync_package()
-{
-
- //global $config;
-
-}
-
-// bounty: https://forum.pfsense.org/index.php/topic,15791.0/topicseen.html
-// pkg_add -r denyhosts
-// python /usr/local/share/denyhosts/denyhosts.py –file=/var/log/auth.log
-// /var/run/denyhosts.pid
-// http://en.wikipedia.org/wiki/DenyHosts
-
-
-function denyhosts_install_command()
-{
-
- global $config;
- conf_mount_rw();
- config_lock();
-
- if (!is_dir('/usr/local/www/packages/')) {
- exec("mkdir /usr/local/www/packages/");
- }
-
- if (!is_dir('/usr/local/www/packages/denyhosts/')) {
- exec("mkdir /usr/local/www/packages/denyhosts/");
- }
-
- exec("pkg_add -r https://files.pfsense.org/packages/security/denyhosts-2.5.tbz");
-
- //misc files
- if (!is_dir('/usr/local/www/edit_area/')) {
- chdir('/tmp/');
- exec("cd /tmp/;fetch ".$download_path."edit_area.tgz");
- chdir('/usr/local/www');
- system('tar xvpfz /tmp/edit_area.tgz edit_area');
- unlink_if_exists("/tmp/edit_area.tgz");
- }
-
- //backup the original hosts.allow file
- exec ("cp /etc/hosts.allow /etc/hosts.allow.bak");
-
- $hosts_allow = "#\n";
- $hosts_allow .= "# hosts.allow access control file for \"tcp wrapped\" applications.\n";
- $hosts_allow .= "#\n";
- $hosts_allow .= "sshd : /etc/hosts.deniedssh : deny\n";
- $hosts_allow .= "sshd : ALL : allow\n";
- $hosts_allow .= "ALL : ALL : allow\n";
- $fout = fopen("/etc/hosts.allow","w");
- fwrite($fout, $hosts_allow);
- unset($hosts_allow);
- fclose($fout);
-
- if(!is_file("/etc/hosts.deniedssh")) {
- exec("touch /etc/hosts.deniedssh");
- exec("chmod 755 /etc/hosts.deniedssh");
- }
-
- if(!is_file("/var/log/denyhosts")) {
- exec ('touch /var/log/denyhosts');
- }
-
- $download_path = 'https://packages.pfsense.org/packages/config/denyhosts/';
-
- //rename PHP files from .tmp to .php
- chdir('/tmp/');
- exec("cd /tmp/;fetch ".$download_path."denyhosts_log.tmp");
- exec("cp /tmp/denyhosts_log.tmp /usr/local/www/packages/denyhosts/denyhosts_log.php");
- unlink_if_exists("/tmp/denyhosts_log.tmp");
-
-
- //$denyhosts_sh = "\n";
- //$denyhosts_sh .= "name=\"denyhosts\"\n";
- //$denyhosts_sh .= "rcvar=\${name}_enable\n";
- //$denyhosts_sh .= "\n";
- //$denyhosts_sh .= "command=\"/usr/local/bin/denyhosts.py\"\n";
- //$denyhosts_sh .= "command_interpreter=\"/usr/local/bin/python2.5\"\n";
- //$denyhosts_sh .= "command_args=\"--config /usr/local/etc/denyhosts.conf --daemon\"\n";
- //$denyhosts_sh .= "pidfile=\"/var/run/\${name}.pid\"\n";
- //$denyhosts_sh .= "\n";
- //$denyhosts_sh .= "load_rc_config \$name\n";
- //$denyhosts_sh .= "\n";
- //$denyhosts_sh .= ": \${denyhosts_enable=\"YES\"}\n";
- //$denyhosts_sh .= "\n";
- //$denyhosts_sh .= "run_rc_command \"\$1\"\n";
- //$fout = fopen("/usr/local/etc/rc.d/denyhosts.sh","w");
- //fwrite($fout, $denyhosts_sh);
- //unset($denyhosts_sh);
- //fclose($fout);
- //exec("chmod 755 /usr/local/etc/rc.d/denyhosts.sh");
-
- $filename = "/usr/local/etc/denyhosts.conf";
- $handle = fopen($filename,"rb");
- $denyhosts_conf = fread($handle, filesize($filename));
- fclose($handle);
- $denyhosts_conf = str_replace("SECURE_LOG = /var/log/auth.log", "SECURE_LOG = /var/log/system.log", $denyhosts_conf);
- $denyhosts_conf = str_replace("#BLOCK_SERVICE = sshd", "BLOCK_SERVICE = sshd", $denyhosts_conf);
- $denyhosts_conf = str_replace("#SYNC_SERVER = http://xmlrpc.denyhosts.net:9911", "SYNC_SERVER = http://xmlrpc.denyhosts.net:9911", $denyhosts_conf);
- $fout = fopen($filename,"w");
- fwrite($fout, $denyhosts_conf);
- unset($filename);
- fclose($fout);
-
- $filename = "/usr/local/etc/denyhosts.conf-dist";
- $fout = fopen($filename,"w");
- fwrite($fout, $denyhosts_conf);
- unset($filename);
- unset($denyhosts_conf);
- fclose($fout);
-
- write_rcfile(array(
- "file" => "denyhosts.sh",
- "start" => "/usr/local/bin/python2.5 /usr/local/bin/denyhosts.py --config /usr/local/etc/denyhosts.conf --daemon",
- "stop" => "rm /var/run/denyhosts.pid"
- )
- );
-
- denyhosts_sync_package();
-
- //start denyhosts
- exec("/usr/local/etc/rc.d/denyhosts.sh start");
-
- //if (pkg_is_service_running('notes')) {
- //documentation purposes
- //}
-
- conf_mount_ro();
- config_unlock();
-
-}
-
-
-function denyhosts_deinstall_command()
-{
-
- conf_mount_rw();
- config_lock();
-
- exec("pkg_delete denyhosts");
- exec("rm -R /usr/local/www/packages/denyhosts/");
-
- //restore original hosts.allow file
- if (file_exists('/usr/local/www/exec.php')) {
- exec ("rm /etc/hosts.allow");
- exec ("cp /etc/hosts.allow.bak /etc/hosts.allow");
- }
-
- //remove the configuration
- exec ("rm /usr/local/etc/denyhosts*");
-
- //create a new hosts.allow file
- //$hosts_allow = "#\n";
- //$hosts_allow .= "# hosts.allow access control file for \"tcp wrapped\" applications.\n";
- //$hosts_allow .= "#\n";
- //$hosts_allow .= "ALL : ALL : allow\n";
- //$fout = fopen("/etc/hosts.allow","w");
- //fwrite($fout, $tmp);
- //unset($tmp);
- //fclose($fout);
-
- conf_mount_ro();
- config_unlock();
-}
-
-?> \ No newline at end of file