diff options
author | Renato Botelho <renato@netgate.com> | 2015-08-25 08:08:24 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2015-08-25 14:49:54 -0300 |
commit | 46bc6e545a17e77202aaf01ec0cd8d5a46567525 (patch) | |
tree | 32d18dda436ec739c67c489ceb771e8629cd926f /usr | |
parent | 4d9801c2dbd2b3e54a39578ee62b93af66607227 (diff) | |
download | pfsense-46bc6e545a17e77202aaf01ec0cd8d5a46567525.zip pfsense-46bc6e545a17e77202aaf01ec0cd8d5a46567525.tar.gz |
Move main pfSense content to src/
Diffstat (limited to 'usr')
2636 files changed, 0 insertions, 368413 deletions
diff --git a/usr/local/bin/3gstats.php b/usr/local/bin/3gstats.php deleted file mode 100755 index cc385fc..0000000 --- a/usr/local/bin/3gstats.php +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/local/bin/php-cgi -f -<?php - -ini_set("max_execution_time", "0"); - -if(empty($argv[1])) { - echo "No modem device given \n"; - exit(0); -} - -/* Huawei example */ -$device = "/dev/{$argv[1]}"; -$statfile = "/tmp/3gstats.{$argv[2]}"; -/* mode is a comma separated value, thus submode is born */ -$header = "#seconds,rssi,mode,submode,upstream,downstream,sentbytes,receivedbyts,bwupstream,bwdownstream,simstate,service\n"; - -$i = 0; - -$record = array(); -$handle = fopen($device, "r"); -if(! $handle) { - echo "Can not open modem stats device\n"; - exit(1); -} - -$record['time'] = 0; -$record['rssi'] = 0; -$record['mode'] = "0,0"; -$record['upstream'] = 0; -$record['downstream'] = 0; -$record['sent'] = 0; -$record['received'] = 0; -$record['bwupstream'] = 0; -$record['bwdownstream'] = 0; -$record['simstate'] = 0; -$record['service'] = 0; - -while (true) { - $string = ""; - $string = fgets($handle, 256); - - $elements = array(); - $elements = explode(':', $string); - $elements[0] = trim($elements[0]); - $elements[1] = trim($elements[1]); - - switch ($elements[0]) { - case "^MODE": - $record['mode'] = $elements[1]; - break; - case "^SRVST": - $record['service'] = $elements[1]; - break; - case "^SIMST": - $record['simstate'] = $elements[1]; - break; - case "^RSSI": - $record['rssi'] = $elements[1]; - break; - case "^DSFLOWRPT": - $items = array(); - $items = explode(',', $elements[1]); - $record['time'] = hexdec($items[0]); - $record['upstream'] = round((floatval(hexdec($items[1])) * 8) /1024); - $record['downstream'] = round((floatval(hexdec($items[2])) * 8) /1024); - $record['sent'] = hexdec($items[3]); - $record['received'] = hexdec($items[4]); - $record['bwupstream'] = round((floatval(hexdec($items[5])) * 8) /1024); - $record['bwdownstream'] = round((floatval(hexdec($items[6])) * 8) /1024); - break; - } - - if ($i > 10) { - $csv = $header; - $csv .= implode(",", $record); - $csv .= "\n"; - file_put_contents($statfile, $csv); - $i = 0; - } - $i++; -} -fclose($handle); -?> diff --git a/usr/local/bin/beep.sh b/usr/local/bin/beep.sh deleted file mode 100755 index ed9382d..0000000 --- a/usr/local/bin/beep.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - - -BEEP=`/usr/bin/grep -c disablebeep /conf/config.xml` -if [ $BEEP -gt 0 ]; then - exit; -fi - -# Standard note length -NOTELENGTH="25" - -# this is super annoying in VMware, exit if in VMware -if [ -f /var/log/dmesg.boot ]; then - VMWCOUNT=`/usr/bin/grep -c VMware /var/log/dmesg.boot` - if [ $VMWCOUNT -gt 0 ]; then - exit; - fi -fi - -# Check for different HZ -if [ -f /boot/loader.conf ]; then - HZ=`/usr/bin/grep -c kern.hz /boot/loader.conf` - if [ "$HZ" = "1" ]; then - NOTELENGTH="10" - fi -fi - -if [ -c "/dev/speaker" ]; then - if [ "$1" = "start" ]; then - /usr/local/bin/beep -p 500 $NOTELENGTH - /usr/local/bin/beep -p 400 $NOTELENGTH - /usr/local/bin/beep -p 600 $NOTELENGTH - /usr/local/bin/beep -p 800 $NOTELENGTH - /usr/local/bin/beep -p 800 $NOTELENGTH - fi - if [ "$1" = "stop" ]; then - /usr/local/bin/beep -p 600 $NOTELENGTH - /usr/local/bin/beep -p 800 $NOTELENGTH - /usr/local/bin/beep -p 500 $NOTELENGTH - /usr/local/bin/beep -p 400 $NOTELENGTH - /usr/local/bin/beep -p 400 $NOTELENGTH - fi -fi diff --git a/usr/local/bin/captiveportal_gather_stats.php b/usr/local/bin/captiveportal_gather_stats.php deleted file mode 100644 index 23d6b5d..0000000 --- a/usr/local/bin/captiveportal_gather_stats.php +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/local/bin/php-cgi -q -<?php -/* $Id$ */ -/* - captiveportal_gather_stats.php - Copyright (C) 2011 Warren Baker - Copyright (C) 2013-2015 Electric Sheep Fencing, LP - 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. -*/ - -require_once("functions.inc"); -require_once("captiveportal.inc"); -require_once("util.inc"); - -global $cpzone; - -$cpzone = $argv[1]; -$type = $argv[2]; - -/* read in captive portal db */ -$cpdb = captiveportal_read_db(); - -/* determine number of logged in users */ -$no_users = count($cpdb); -$concurrent_users = $no_users; - -/* set initial user count to zero */ -$current_user_count = 0; - -/* tmp file to use to store old data (per interface)*/ -$tmpfile = "{$g['vardb_path']}/captiveportal_online_users"; - -if (empty($type)) { - exit; -} - -/* echo the rrd required syntax */ -echo "N:"; -$result = "NaN"; - -if ($type == "loggedin") { - - /* Find out the previous user timestamp - * so we can determine the difference between the current - * and previous user count. If the file is empty return a 0. - */ - $fd = @fopen($tmpfile, "r"); - if ($fd) { - while (!feof($fd)) { - $line = trim(fgets($fd)); - if ($line) { - $previous_user_timestamp = $line; - } else { - $previous_user_timestamp = 0; - } - } - } else { - $previous_user_timestamp = 0; - } - @fclose($fd); - - foreach ($cpdb as $user) { - $user_ip = $user[2]; - // Record the timestamp - $timestamp = $user[0]; - if ($timestamp > $previous_user_timestamp) { - $current_user_count = $current_user_count + 1; - } - } - - // Write out the latest timestamp but not if it is empty - if (!empty($timestamp)) { - $fd = @fopen($tmpfile, "w"); - if ($fd) { - fwrite($fd, $timestamp); - } - @fclose($fd); - } - - /* If $timestamp is less than or equal to previous_user_timestamp return 0, - * as we only want the 'X' number of users logged in since last RRD poll. - */ - if ($timestamp <= $previous_user_timestamp) { - $result = 0; - } else { - $result = $current_user_count; - } -} elseif ($type == "concurrent") { - $result = $no_users; -} - -echo "$result"; - -?> diff --git a/usr/local/bin/easyrule b/usr/local/bin/easyrule deleted file mode 100755 index 8461a7a..0000000 --- a/usr/local/bin/easyrule +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/local/bin/php-cgi -q -<?php -/* - easyrule CLI Program - - Copyright (C) 2010 Jim Pingle (jpingle@gmail.com) - 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. -*/ - -require_once("pfsense-utils.inc"); -require_once("easyrule.inc"); -require_once("filter.inc"); -require_once("shaper.inc"); - -$message = ""; -$specialsrcdst = explode(" ", "any pptp pppoe l2tp openvpn"); -$ifdisp = get_configured_interface_with_descr(); -foreach ($ifdisp as $kif => $kdescr) { - $specialsrcdst[] = "{$kif}"; - $specialsrcdst[] = "{$kif}ip"; -} - -/* Borrow this function from guiconfig.inc since we can't include it for use at the CLI - - - Maybe these need to be moved to util.inc or pfsense-utils.inc? - -*/ -function pconfig_to_address(&$adr, $padr, $pmask, $pnot=false, $pbeginport=0, $pendport=0) { - - $adr = array(); - - if ($padr == "any") { - $adr['any'] = true; - } else if (is_specialnet($padr)) { - $adr['network'] = $padr; - } else { - $adr['address'] = $padr; - if ($pmask != 32) { - $adr['address'] .= "/" . $pmask; - } - } - - if ($pnot) { - $adr['not'] = true; - } else { - unset($adr['not']); - } - - if (($pbeginport != 0) && ($pbeginport != "any")) { - if ($pbeginport != $pendport) { - $adr['port'] = $pbeginport . "-" . $pendport; - } else { - $adr['port'] = $pbeginport; - } - } - - if (is_alias($pbeginport)) { - $adr['port'] = $pbeginport; - } -} - -/* Borrow this one from guiconfig.inc also */ -function is_specialnet($net) { - global $specialsrcdst; - - if (!$net) { - return false; - } - if (in_array($net, $specialsrcdst)) { - return true; - } else { - return false; - } -} - - -if (($argc > 1) && !empty($argv[1])) { - - /* Automagically derive an alternate alias name from the scripts name - * This allows for using alternate alias lists with just a symlink */ - if (($alias = basename($argv[0])) != 'easyrule') { - $blockaliasname = ucfirst($alias).'Rules'; - } - - $message = ""; - switch ($argv[1]) { - case 'block': - $message = easyrule_parse_block($argv[2], $argv[3]); - break; - case 'unblock': - $message = easyrule_parse_unblock($argv[2], $argv[3]); - break; - case 'showblock': - $message = easyrule_parse_getblock($argv[2]); - break; - case 'pass': - $message = easyrule_parse_pass($argv[2], $argv[3], $argv[4], $argv[5], $argv[6]); - break; - } - echo $message . "\n"; -} else { - // Print usage: - echo "usage:\n"; - echo " Blocking only requires an IP to block, block rules can be shown with showblock and revoked using unblock\n"; - echo " " . basename($argv[0]) . " block <interface> <source IP>\n"; - echo "\n"; - echo " Passing requires more detail, as it must be as specific as possible. The destination port is optional if you're using a protocol without a port (e.g. ICMP, OSPF, etc).\n"; - echo " " . basename($argv[0]) . " pass <interface> <protocol> <source IP> <destination ip> [destination port]\n"; - echo "\n"; - echo " Block example:\n"; - echo " " . basename($argv[0]) . " block wan 1.2.3.4\n"; - echo "\n"; - echo " Show active blocks example:\n"; - echo " " . basename($argv[0]) . " showblock wan\n"; - echo "\n"; - echo " Unblock example:\n"; - echo " " . basename($argv[0]) . " unblock wan 1.2.3.4\n"; - echo "\n"; - echo " Pass example (protocol with port):\n"; - echo " " . basename($argv[0]) . " pass wan tcp 1.2.3.4 192.168.0.4 80\n"; - echo "\n"; - echo " Pass example (protocol without port):\n"; - echo " " . basename($argv[0]) . " pass wan icmp 1.2.3.4 192.168.0.4\n"; - echo "\n"; -} -?> diff --git a/usr/local/bin/filterparser.php b/usr/local/bin/filterparser.php deleted file mode 100755 index fa60262..0000000 --- a/usr/local/bin/filterparser.php +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/local/bin/php-cgi -q -<?php -/* $Id$ */ -/* - filterparser.php - part of pfSesne by Scott Ullrich - originally based on m0n0wall (http://m0n0.ch/wall) - - Copyright (C) 2009 Jim Pingle <myfirstname>@<mylastname>.org - Copyright (C) 2013-2015 Electric Sheep Fencing, LP - 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. - - A quick CLI log parser. - Examples: - clog /var/log/filter.log | tail -50 | /usr/local/www/filterparser.php - clog -f /var/log/filter.log | /usr/local/www/filterparser.php -*/ -/* - pfSense_MODULE: logs -*/ - -include_once("functions.inc"); -include_once("filter_log.inc"); - -$log = fopen("php://stdin", "r"); -$lastline = ""; -while (!feof($log)) { - $line = fgets($log); - $line = rtrim($line); - $flent = parse_filter_line(trim($line)); - if ($flent != "") { - $flags = (($flent['proto'] == "TCP") && !empty($flent['tcpflags'])) ? ":" . $flent['tcpflags'] : ""; - echo "{$flent['time']} {$flent['act']} {$flent['realint']} {$flent['proto']}{$flags} {$flent['src']} {$flent['dst']}\n"; - $flent = ""; - } -} -fclose($log); ?> diff --git a/usr/local/bin/mail.php b/usr/local/bin/mail.php deleted file mode 100755 index 130d9e0..0000000 --- a/usr/local/bin/mail.php +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/local/bin/php-cgi -q -<?php -require_once("config.inc"); -require_once("globals.inc"); -require_once("notices.inc"); -$options = getopt("s::"); - -$message = ""; - -if ($options['s'] <> "") { - $subject = $options['s']; -} - - -$in = file("php://stdin"); -foreach ($in as $line){ - $message .= "$line"; -} - -if (!empty($subject)) { - send_smtp_message($message, $subject); -} else { - send_smtp_message($message); -} -?> diff --git a/usr/local/bin/ping_hosts.sh b/usr/local/bin/ping_hosts.sh deleted file mode 100755 index eef64f3..0000000 --- a/usr/local/bin/ping_hosts.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/sh - -# pfSense ping helper -# written by Scott Ullrich -# (C)2006 Scott Ullrich -# All rights reserved. - -# Format of file should be delimited by | -# Field 1: Source IP -# Field 2: Destination IP -# Field 3: Ping count -# Field 4: Script to run when service is down -# Field 5: Script to run once service is restored -# Field 6: Ping time threshold -# Field 7: Wan ping time threshold -# Field 8: Address family - -# Read in ipsec ping hosts and check the CARP status -if [ -f /var/db/ipsecpinghosts ]; then - IPSECHOSTS="/var/db/ipsecpinghosts" - CURRENTIPSECHOSTS="/var/db/currentipsecpinghosts" - IFVPNSTATE=`ifconfig $IFVPN | grep "carp: BACKUP vhid" | wc -l` - if [ $IFVPNSTATE -gt 1 ]; then - echo -e "CARP interface in BACKUP (not pinging ipsec hosts)" - rm -f $CURRENTIPSECHOSTS - touch $CURRENTIPSECHOSTS - else - echo -e "CARP interface is MASTER or non CARP (pinging ipsec hosts)" - cat < $IPSECHOSTS > $CURRENTIPSECHOSTS - fi -fi - -# General file meant for user consumption -if [ -f /var/db/hosts ]; then - HOSTS="/var/db/hosts" -fi - -# Package specific ping requests -if [ -f /var/db/pkgpinghosts ]; then - PKGHOSTS="/var/db/pkgpinghosts" -fi - -cat $PKGHOSTS $HOSTS $CURRENTIPSECHOSTS >/tmp/tmpHOSTS - -if [ ! -d /var/db/pingstatus ]; then - /bin/mkdir -p /var/db/pingstatus -fi - -if [ ! -d /var/db/pingmsstatus ]; then - /bin/mkdir -p /var/db/pingmsstatus -fi - -PINGHOSTS=`cat /tmp/tmpHOSTS` - -PINGHOSTCOUNT=`cat /tmp/tmpHOSTS | wc -l` - -if [ "$PINGHOSTCOUNT" -lt "1" ]; then - exit -fi - -for TOPING in $PINGHOSTS ; do - echo "PROCESSING $TOPING" - SRCIP=`echo $TOPING | cut -d"|" -f1` - DSTIP=`echo $TOPING | cut -d"|" -f2` - COUNT=`echo $TOPING | cut -d"|" -f3` - FAILURESCRIPT=`echo $TOPING | cut -d"|" -f4` - SERVICERESTOREDSCRIPT=`echo $TOPING | cut -d"|" -f5` - THRESHOLD=`echo $TOPING | cut -d"|" -f6` - WANTHRESHOLD=`echo $TOPING | cut -d"|" -f7` - AF=`echo $TOPING | cut -d"|" -f8` - if [ "$AF" == "inet6" ]; then - PINGCMD=ping6 - else - PINGCMD=ping - fi - echo Processing $DSTIP - # Look for a service being down - # Read in previous status - PREVIOUSSTATUS="" - if [ -f "/var/db/pingstatus/${DSTIP}" ]; then - PREVIOUSSTATUS=`cat /var/db/pingstatus/$DSTIP` - fi - $PINGCMD -c $COUNT -S $SRCIP $DSTIP - if [ $? -eq 0 ]; then - # Host is up - if [ "$PREVIOUSSTATUS" != "UP" ]; then - # Service restored - echo "UP" > /var/db/pingstatus/$DSTIP - if [ "$SERVICERESTOREDSCRIPT" != "" ]; then - echo "$DSTIP is UP, previous state was DOWN .. Running $SERVICERESTOREDSCRIPT" - echo "$DSTIP is UP, previous state was DOWN .. Running $SERVICERESTOREDSCRIPT" | logger -p daemon.info -i -t PingMonitor - sh -c $SERVICERESTOREDSCRIPT - fi - fi - else - # Host is down - if [ "$PREVIOUSSTATUS" != "DOWN" ]; then - # Service is down - echo "DOWN" > /var/db/pingstatus/$DSTIP - if [ "$FAILURESCRIPT" != "" ]; then - echo "$DSTIP is DOWN, previous state was UP .. Running $FAILURESCRIPT" - echo "$DSTIP is DOWN, previous state was UP .. Running $FAILURESCRIPT" | logger -p daemon.info -i -t PingMonitor - sh -c $FAILURESCRIPT - fi - fi - fi - echo "Checking ping time $DSTIP" - # Look at ping values themselves - PINGTIME=`$PINGCMD -c 1 -S $SRCIP $DSTIP | awk '{ print $7 }' | grep time | cut -d "=" -f2` - echo "Ping returned $?" - echo $PINGTIME > /var/db/pingmsstatus/$DSTIP - if [ "$THRESHOLD" != "" ]; then - if [ $(echo "${PINGTIME} > ${THRESHOLD}" | /usr/bin/bc) -eq 1 ]; then - echo "$DSTIP has exceeded ping threshold $PINGTIME / $THRESHOLD .. Running $FAILURESCRIPT" - echo "$DSTIP has exceeded ping threshold $PINGTIME / $THRESHOLD .. Running $FAILURESCRIPT" | logger -p daemon.info -i -t PingMonitor - sh -c $FAILURESCRIPT - fi - fi - # Wan ping time threshold - #WANTIME=`rrdtool fetch /var/db/rrd/wan-quality.rrd AVERAGE -r 120 -s -1min -e -1min | grep ":" | cut -f3 -d" " | cut -d"e" -f1` - echo "Checking wan ping time $WANTIME" - echo $WANTIME > /var/db/wanaverage - if [ "$WANTHRESHOLD" != "" -a "$WANTIME" != "" ]; then - if [ $(echo "${WANTIME} > ${WANTHRESHOLD}" | /usr/bin/bc) -eq 1 ]; then - echo "$DSTIP has exceeded wan ping threshold $WANTIME / $WANTHRESHOLD .. Running $FAILURESCRIPT" - echo "$DSTIP has exceeded wan ping threshold $WANTIME / $WANTHRESHOLD .. Running $FAILURESCRIPT" | logger -p daemon.info -i -t PingMonitor - sh -c $FAILURESCRIPT - fi - fi - sleep 1 -done - -exit 0 - diff --git a/usr/local/bin/runmsntp.sh b/usr/local/bin/runmsntp.sh deleted file mode 100755 index d770632..0000000 --- a/usr/local/bin/runmsntp.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# write our PID to file -echo $$ > $1 - -# execute msntp in endless loop; restart if it -# exits (wait 1 second to avoid restarting too fast in case -# the network is not yet setup) -while true; do - /usr/local/bin/msntp -v -r -P no -l $2 -x $3 $4 2>&1 | logger -p daemon.info -i -t msntp - sleep 60 -done diff --git a/usr/local/bin/slowdownpipe.sh b/usr/local/bin/slowdownpipe.sh deleted file mode 100755 index 13b9e8d..0000000 --- a/usr/local/bin/slowdownpipe.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# Illustrates use of a while loop to read a file - -cat - | \ -while read line -do - echo "$line" - sleep 0.01 -done diff --git a/usr/local/bin/viconfig b/usr/local/bin/viconfig deleted file mode 100755 index 93618f2..0000000 --- a/usr/local/bin/viconfig +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -vi /cf/conf/config.xml -rm /tmp/config.cache
\ No newline at end of file diff --git a/usr/local/captiveportal/index.php b/usr/local/captiveportal/index.php deleted file mode 100644 index d450233..0000000 --- a/usr/local/captiveportal/index.php +++ /dev/null @@ -1,252 +0,0 @@ -<?php -/* - $Id$ - part of m0n0wall (http://m0n0.ch/wall) - - Copyright (C) 2013-2015 Electric Sheep Fencing, LP - Copyright (C) 2009 Ermal Luçi - Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. - 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. -*/ -/* - pfSense_MODULE: captiveportal -*/ - -require_once("auth.inc"); -require_once("functions.inc"); -require_once("captiveportal.inc"); - -$errormsg = "Invalid credentials specified."; - -header("Expires: 0"); -header("Cache-Control: no-cache, no-store, must-revalidate"); -header("Pragma: no-cache"); -header("Connection: close"); - -global $cpzone, $cpzoneid; - -$cpzone = $_REQUEST['zone']; -$cpcfg = $config['captiveportal'][$cpzone]; -if (empty($cpcfg)) { - log_error("Submission to captiveportal with unknown parameter zone: " . htmlspecialchars($cpzone)); - portal_reply_page($redirurl, "error", $errormsg); - ob_flush(); - return; -} - -$cpzoneid = $cpcfg['zoneid']; - -$orig_host = $_SERVER['HTTP_HOST']; -/* NOTE: IE 8/9 is buggy and that is why this is needed */ -$orig_request = trim($_REQUEST['redirurl'], " /"); -$clientip = $_SERVER['REMOTE_ADDR']; - -if (!$clientip) { - /* not good - bail out */ - log_error("Zone: {$cpzone} - Captive portal could not determine client's IP address."); - $error_message = "An error occurred. Please check the system logs for more information."; - portal_reply_page($redirurl, "error", $errormsg); - ob_flush(); - return; -} - -$ourhostname = portal_hostname_from_client_ip($clientip); -if ($orig_host != $ourhostname) { - /* the client thinks it's connected to the desired web server, but instead - it's connected to us. Issue a redirect... */ - $protocol = (isset($cpcfg['httpslogin'])) ? 'https://' : 'http://'; - header("Location: {$protocol}{$ourhostname}/index.php?zone={$cpzone}&redirurl=" . urlencode("http://{$orig_host}/{$orig_request}")); - - ob_flush(); - return; -} - -if (!empty($cpcfg['redirurl'])) { - $redirurl = $cpcfg['redirurl']; -} else if (preg_match("/redirurl=(.*)/", $orig_request, $matches)) { - $redirurl = urldecode($matches[1]); -} else if ($_REQUEST['redirurl']) { - $redirurl = $_REQUEST['redirurl']; -} - -$macfilter = !isset($cpcfg['nomacfilter']); -$passthrumac = isset($cpcfg['passthrumacadd']); - -/* find MAC address for client */ -if ($macfilter || $passthrumac) { - $tmpres = pfSense_ip_to_mac($clientip); - if (!is_array($tmpres)) { - /* unable to find MAC address - shouldn't happen! - bail out */ - captiveportal_logportalauth("unauthenticated", "noclientmac", $clientip, "ERROR"); - echo "An error occurred. Please check the system logs for more information."; - log_error("Zone: {$cpzone} - Captive portal could not determine client's MAC address. Disable MAC address filtering in captive portal if you do not need this functionality."); - ob_flush(); - return; - } - $clientmac = $tmpres['macaddr']; - unset($tmpres); -} - -/* find out if we need RADIUS + RADIUSMAC or not */ -if (file_exists("{$g['vardb_path']}/captiveportal_radius_{$cpzone}.db")) { - $radius_enable = TRUE; - if (isset($cpcfg['radmac_enable'])) { - $radmac_enable = TRUE; - } -} - -/* find radius context */ -$radiusctx = 'first'; -if ($_POST['auth_user2']) { - $radiusctx = 'second'; -} - -if ($_POST['logout_id']) { - echo <<<EOD -<html> -<head><title>Disconnecting...</title></head> -<body bgcolor="#435370"> -<span style="color: #ffffff; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px;"> -<b>You have been disconnected.</b> -</span> -<script type="text/javascript"> -<!-- -setTimeout('window.close();',5000) ; ---> -</script> -</body> -</html> - -EOD; - captiveportal_disconnect_client($_POST['logout_id']); - -} else if ($macfilter && $clientmac && captiveportal_blocked_mac($clientmac)) { - captiveportal_logportalauth($clientmac, $clientmac, $clientip, "Blocked MAC address"); - if (!empty($cpcfg['blockedmacsurl'])) { - portal_reply_page($cpcfg['blockedmacsurl'], "redir"); - } else { - portal_reply_page($redirurl, "error", "This MAC address has been blocked"); - } - -} else if ($clientmac && $radmac_enable && portal_mac_radius($clientmac, $clientip, $radiusctx)) { - /* radius functions handle everything so we exit here since we're done */ - -} else if (portal_consume_passthrough_credit($clientmac)) { - /* allow the client through if it had a pass-through credit for its MAC */ - captiveportal_logportalauth("unauthenticated", $clientmac, $clientip, "ACCEPT"); - portal_allow($clientip, $clientmac, "unauthenticated"); - -} else if (isset($config['voucher'][$cpzone]['enable']) && $_POST['accept'] && $_POST['auth_voucher']) { - $voucher = trim($_POST['auth_voucher']); - $timecredit = voucher_auth($voucher); - // $timecredit contains either a credit in minutes or an error message - if ($timecredit > 0) { // voucher is valid. Remaining minutes returned - // if multiple vouchers given, use the first as username - $a_vouchers = preg_split("/[\t\n\r ]+/s", $voucher); - $voucher = $a_vouchers[0]; - $attr = array( - 'voucher' => 1, - 'session_timeout' => $timecredit*60, - 'session_terminate_time' => 0); - if (portal_allow($clientip, $clientmac, $voucher, null, $attr)) { - // YES: user is good for $timecredit minutes. - captiveportal_logportalauth($voucher, $clientmac, $clientip, "Voucher login good for $timecredit min."); - } else { - portal_reply_page($redirurl, "error", $config['voucher'][$cpzone]['descrmsgexpired'] ? $config['voucher'][$cpzone]['descrmsgexpired']: $errormsg); - } - } else if (-1 == $timecredit) { // valid but expired - captiveportal_logportalauth($voucher, $clientmac, $clientip, "FAILURE", "voucher expired"); - portal_reply_page($redirurl, "error", $config['voucher'][$cpzone]['descrmsgexpired'] ? $config['voucher'][$cpzone]['descrmsgexpired']: $errormsg); - } else { - captiveportal_logportalauth($voucher, $clientmac, $clientip, "FAILURE"); - portal_reply_page($redirurl, "error", $config['voucher'][$cpzone]['descrmsgnoaccess'] ? $config['voucher'][$cpzone]['descrmsgnoaccess'] : $errormsg); - } - -} else if ($_POST['accept'] && $radius_enable) { - if (($_POST['auth_user'] && isset($_POST['auth_pass'])) || ($_POST['auth_user2'] && isset($_POST['auth_pass2']))) { - if (!empty($_POST['auth_user'])) { - $user = $_POST['auth_user']; - $paswd = $_POST['auth_pass']; - } else if (!empty($_POST['auth_user2'])) { - $user = $_POST['auth_user2']; - $paswd = $_POST['auth_pass2']; - } - $auth_list = radius($user, $paswd, $clientip, $clientmac, "USER LOGIN", $radiusctx); - $type = "error"; - if (!empty($auth_list['url_redirection'])) { - $redirurl = $auth_list['url_redirection']; - $type = "redir"; - } - - if ($auth_list['auth_val'] == 1) { - captiveportal_logportalauth($user, $clientmac, $clientip, "ERROR", $auth_list['error']); - portal_reply_page($redirurl, $type, $auth_list['error'] ? $auth_list['error'] : $errormsg); - } else if ($auth_list['auth_val'] == 3) { - captiveportal_logportalauth($user, $clientmac, $clientip, "FAILURE", $auth_list['reply_message']); - portal_reply_page($redirurl, $type, $auth_list['reply_message'] ? $auth_list['reply_message'] : $errormsg); - } - } else { - if (!empty($_POST['auth_user'])) { - $user = $_POST['auth_user']; - } else if (!empty($_POST['auth_user2'])) { - $user = $_POST['auth_user2']; - } else { - $user = 'unknown'; - } - captiveportal_logportalauth($user, $clientmac, $clientip, "ERROR"); - portal_reply_page($redirurl, "error", $errormsg); - } - -} else if ($_POST['accept'] && $cpcfg['auth_method'] == "local") { - if ($_POST['auth_user'] && $_POST['auth_pass']) { - //check against local user manager - $loginok = local_backed($_POST['auth_user'], $_POST['auth_pass']); - - if ($loginok && isset($cpcfg['localauth_priv'])) { - $loginok = userHasPrivilege(getUserEntry($_POST['auth_user']), "user-services-captiveportal-login"); - } - - if ($loginok) { - captiveportal_logportalauth($_POST['auth_user'], $clientmac, $clientip, "LOGIN"); - portal_allow($clientip, $clientmac, $_POST['auth_user']); - } else { - captiveportal_logportalauth($_POST['auth_user'], $clientmac, $clientip, "FAILURE"); - portal_reply_page($redirurl, "error", $errormsg); - } - } else { - portal_reply_page($redirurl, "error", $errormsg); - } - -} else if ($_POST['accept'] && $clientip && $cpcfg['auth_method'] == "none") { - captiveportal_logportalauth("unauthenticated", $clientmac, $clientip, "ACCEPT"); - portal_allow($clientip, $clientmac, "unauthenticated"); - -} else { - /* display captive portal page */ - portal_reply_page($redirurl, "login", null, $clientmac, $clientip); -} - -ob_flush(); - -?> diff --git a/usr/local/captiveportal/radius_accounting.inc b/usr/local/captiveportal/radius_accounting.inc deleted file mode 100644 index 2d9c97e..0000000 --- a/usr/local/captiveportal/radius_accounting.inc +++ /dev/null @@ -1,323 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -/* - - $Id$ - - Copyright (c) 2006, Jonathan De Graeve <jonathan.de.graeve@imelda.be> - 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. - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. - - This code cannot simply be copied and put under the GNU Public License or - any other GPL-like (LGPL, GPL2) License. - - This code is made possible thx to samples made by Michael Bretterklieber <michael@bretterklieber.com> - author of the PHP PECL Radius package - -*/ - -/* - pfSense_MODULE: captiveportal -*/ - -define('GIGAWORDS_RIGHT_OPERAND', '4294967296'); // 2^32 - -/* -RADIUS ACCOUNTING START ------------------------ -*/ - -PEAR::loadExtension('bcmath'); - -function RADIUS_ACCOUNTING_START($ruleno, $username, $sessionid, $radiusservers, $clientip, $clientmac) { - - global $config, $cpzone; - - $retvalue = array(); - $nas_mac = mac_format(get_interface_mac("wan")); - $clientmac = mac_format($clientmac); - $nas_port = intval($ruleno); - $radiusvendor = $config['captiveportal'][$cpzone]['radiusvendor'] ? $config['captiveportal'][$cpzone]['radiusvendor'] : null; - - switch ($radiusvendor) { - - case 'cisco': - $calledstationid = $clientmac; - $callingstationid = $clientip; - break; - - default: - if (!function_exists('getNasIP')) - require_once("captiveportal.inc"); - $calledstationid = getNasIP(); - $callingstationid = $clientmac; - break; - } - - // Create our instance - $racct = new Auth_RADIUS_Acct_Start; - - /* Different Authentication options - * - * Its possible todo other authentication methods but still do radius accounting - * - * RADIUS_AUTH_RADIUS => authenticated via Radius - * RADIUS_AUTH_LOCAL => authenticated local - * RADIUS_AUTH_REMOTE => authenticated remote - * - */ - $racct->authentic = RADIUS_AUTH_RADIUS; - - // Construct data package - $racct->username = $username; - /* - Add support for more then one radiusserver. - At most 10 servers may be specified. - When multiple servers are given, they are tried in round-robin fashion until a valid response is received - */ - foreach ($radiusservers as $radsrv) { - // Add a new server to our instance - $racct->addServer($radsrv['ipaddr'], $radsrv['acctport'], $radsrv['key']); - } - - if (PEAR::isError($racct->start())) { - $retvalue['acct_val'] = 1; - $retvalue['error'] = $racct->getMessage(); - - // If we encounter an error immediately stop this function and go back - $racct->close(); - return $retvalue; - - /* Old code: - * $status = $racct->start(); - * if(PEAR::isError($status)) { - * if ($debug) - * printf("Radius start: %s<br />\n", $status->getMessage()); - * exit; - * } - */ - } - - /* - * NAS_PORT_TYPE, int => RADIUS_ETHERNET (15), RADIUS_WIRELESS_OTHER (18), RADIUS_WIRELESS_IEEE_802_11 (19) - */ - - // Default attributes - $racct->putAttribute(RADIUS_NAS_PORT_TYPE, RADIUS_ETHERNET); - $racct->putAttribute(RADIUS_NAS_PORT, $nas_port, 'integer'); - $racct->putAttribute(RADIUS_ACCT_SESSION_ID, $sessionid); - - // Extra data to identify the client and nas - $racct->putAttribute(RADIUS_FRAMED_IP_ADDRESS, $clientip, "addr"); - $racct->putAttribute(RADIUS_CALLED_STATION_ID, $calledstationid); - $racct->putAttribute(RADIUS_CALLING_STATION_ID, $callingstationid); - - // Send request - $result = $racct->send(); - - // Evaluation of the response - // 5 -> Accounting-Response - // See RFC2866 for this. - if (PEAR::isError($result)) { - $retvalue['acct_val'] = 1; - $retvalue['error'] = $result->getMessage(); - - } else if ($result === true) { - $retvalue['acct_val'] = 5 ; - - } else { - $retvalue['acct_val'] = 1 ; - - } - - // close OO RADIUS_ACCOUNTING - $racct->close(); - unset($racct); - - return $retvalue ; - -} - -/* -RADIUS ACCOUNTING STOP/UPDATE ------------------------------ -*/ - -function RADIUS_ACCOUNTING_STOP($ruleno,$username,$sessionid,$start_time,$radiusservers,$clientip,$clientmac, $term_cause = 1, $interimupdate=false,$stop_time = null) { - - global $config, $cpzone; - - $retvalue = array(); - $nas_mac = mac_format(get_interface_mac("wan")); - $volume = getVolume($clientip, $clientmac); - $clientmac = mac_format($clientmac); - $nas_port = intval($ruleno); - $radiusvendor = $config['captiveportal'][$cpzone]['radiusvendor'] ? $config['captiveportal'][$cpzone]['radiusvendor'] : null; - $stop_time = (empty($stop_time)) ? time() : $stop_time; - $session_time = $stop_time - $start_time; - $volume['input_bytes_radius'] = remainder($volume['input_bytes']); - $volume['input_gigawords'] = gigawords($volume['input_bytes']); - $volume['output_bytes_radius'] = remainder($volume['output_bytes']); - $volume['output_gigawords'] = gigawords($volume['output_bytes']); - - switch($radiusvendor) { - - case 'cisco': - $calledstationid = $clientmac; - $callingstationid = $clientip; - break; - - default: - $calledstationid = getNasIP(); - $callingstationid = $clientmac; - break; - } - - // Create our instance, see if we should use Accounting Interim Updates or Accounting STOP messages - if ($interimupdate) - $racct = new Auth_RADIUS_Acct_Update; - else - $racct = new Auth_RADIUS_Acct_Stop; - - /* - Add support for more then one radiusserver. - At most 10 servers may be specified. - When multiple servers are given, they are tried in round-robin fashion until a valid response is received - */ - foreach ($radiusservers as $radsrv) { - // Add a new server to our instance - $racct->addServer($radsrv['ipaddr'], $radsrv['acctport'], $radsrv['key']); - } - - // See RADIUS_ACCOUNTING_START for info - $racct->authentic = RADIUS_AUTH_RADIUS; - - // Construct data package - $racct->username = $username; - // Set session_time - $racct->session_time = $session_time; - - if (PEAR::isError($racct->start())) { - $retvalue['acct_val'] = 1; - $retvalue['error'] = $racct->getMessage(); - - // If we encounter an error immediately stop this function and go back - $racct->close(); - return $retvalue; - } - - // The RADIUS PECL Package doesn't have this vars so we create them ourself - define("RADIUS_ACCT_INPUT_GIGAWORDS", "52"); - define("RADIUS_ACCT_OUTPUT_GIGAWORDS", "53"); - - // Default attributes - $racct->putAttribute(RADIUS_NAS_PORT_TYPE, RADIUS_ETHERNET); - $racct->putAttribute(RADIUS_NAS_PORT, $nas_port, 'integer'); - $racct->putAttribute(RADIUS_ACCT_SESSION_ID, $sessionid); - - // Extra data to identify the client and nas - $racct->putAttribute(RADIUS_FRAMED_IP_ADDRESS, $clientip, "addr"); - $racct->putAttribute(RADIUS_CALLED_STATION_ID, $calledstationid); - $racct->putAttribute(RADIUS_CALLING_STATION_ID, $callingstationid); - - // Volume stuff: Ingress - $racct->putAttribute(RADIUS_ACCT_INPUT_PACKETS, $volume['input_pkts'], "integer"); - $racct->putAttribute(RADIUS_ACCT_INPUT_OCTETS, $volume['input_bytes_radius'], "integer"); - $racct->putAttribute(RADIUS_ACCT_INPUT_GIGAWORDS, $volume['input_gigawords'], "integer"); - // Volume stuff: Outgress - $racct->putAttribute(RADIUS_ACCT_OUTPUT_PACKETS, $volume['output_pkts'], "integer"); - $racct->putAttribute(RADIUS_ACCT_OUTPUT_OCTETS, $volume['output_bytes_radius'], "integer"); - $racct->putAttribute(RADIUS_ACCT_OUTPUT_GIGAWORDS, $volume['output_gigawords'], "integer"); - $racct->putAttribute(RADIUS_ACCT_SESSION_TIME, $session_time, "integer"); - - if (!$interimupdate) - $racct->putAttribute(RADIUS_ACCT_TERMINATE_CAUSE, $term_cause); - - // Send request - $result = $racct->send(); - - // Evaluation of the response - // 5 -> Accounting-Response - // See RFC2866 for this. - if (PEAR::isError($result)) { - $retvalue['acct_val'] = 1; - $retvalue['error'] = $result->getMessage(); - - } else if ($result === true) { - $retvalue['acct_val'] = 5 ; - - } else { - $retvalue['acct_val'] = 1 ; - - } - - // close OO RADIUS_ACCOUNTING - $racct->close(); - - return $retvalue; - -} - - -/** - * Radius Volume Helpers - * - */ - -function gigawords($bytes) { - - - /* - * RFC2866 Specifies a 32bit unsigned integer, which is a max of 4294967295 - * Currently there is a fault in the PECL radius_put_int function which can handle only 32bit signed integer. - */ - - // We use BCMath functions since normal integers don't work with so large numbers - $gigawords = bcdiv( bcsub( $bytes, remainder($bytes) ) , GIGAWORDS_RIGHT_OPERAND) ; - - // We need to manually set this to a zero instead of NULL for put_int() safety - if (is_null($gigawords)) { - $gigawords = 0; - } - - return $gigawords; - -} - -function remainder($bytes) { - - // Calculate the bytes we are going to send to the radius - $bytes = bcmod($bytes, GIGAWORDS_RIGHT_OPERAND); - - if (is_null($bytes)) { - $bytes = 0; - } - - - return $bytes; - -} - -?> diff --git a/usr/local/captiveportal/radius_authentication.inc b/usr/local/captiveportal/radius_authentication.inc deleted file mode 100644 index 9938e24..0000000 --- a/usr/local/captiveportal/radius_authentication.inc +++ /dev/null @@ -1,189 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -/* - $Id$ - - Copyright (c) 2006, Jonathan De Graeve <jonathan.de.graeve@imelda.be> - 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. - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. - - This code cannot simply be copied and put under the GNU Public License or - any other GPL-like (LGPL, GPL2) License. - - This code is made possible thx to samples made by Michael Bretterklieber <michael@bretterklieber.com> - author of the PHP PECL Radius package - -*/ - -/* - pfSense_MODULE: captiveportal -*/ - -/* -RADIUS AUTHENTICATION ---------------------- -*/ - -require_once("CHAP.inc"); - -function RADIUS_AUTHENTICATION($username,$password,$radiusservers,$clientip,$clientmac,$ruleno) { - - global $config, $cpzone; - - $retvalue = array(); - $clientmac = mac_format($clientmac); - $nas_port = $ruleno; - $radiusvendor = $config['captiveportal'][$cpzone]['radiusvendor'] ? $config['captiveportal'][$cpzone]['radiusvendor'] : null; - $radius_protocol = $config['captiveportal'][$cpzone]['radius_protocol']; - // Do we even need to set it to NULL? - $retvalue['error'] = $retvalue['reply_message'] = $retvalue['url_redirection'] = $retvalue['session_timeout'] = null; - $retvalue['idle_timeout'] = $retvalue['session_terminate_time'] = $retvalue['interim_interval'] = null; - - switch($radiusvendor) { - - case 'cisco': - $calledstationid = $clientmac; - $callingstationid = $clientip; - break; - default: - if (!function_exists('getNasIP')) - require_once("captiveportal.inc"); - $calledstationid = getNasIP(); - $callingstationid = $clientmac; - break; - } - - // Create our instance - $classname = 'Auth_RADIUS_' . $radius_protocol; - $rauth = new $classname($username, $password); - - /* - * Add support for more then one radiusserver. - * At most 10 servers may be specified. - * When multiple servers are given, they are tried in round-robin fashion until a valid response is received - */ - foreach ($radiusservers as $radsrv) { - // Add a new server to our instance - $rauth->addServer($radsrv['ipaddr'], $radsrv['port'], $radsrv['key']); - - } - - // Construct data package - $rauth->username = $username; - switch ($radius_protocol) { - case 'CHAP_MD5': - case 'MSCHAPv1': - $classname = $radius_protocol == 'MSCHAPv1' ? 'Crypt_CHAP_MSv1' : 'Crypt_CHAP_MD5'; - $crpt = new $classname; - $crpt->username = $username; - $crpt->password = $password; - $rauth->challenge = $crpt->challenge; - $rauth->chapid = $crpt->chapid; - $rauth->response = $crpt->challengeResponse(); - $rauth->flags = 1; - // If you must use deprecated and weak LAN-Manager-Responses use this: - //$rauth->lmResponse = $crpt->lmChallengeResponse(); - //$rauth->flags = 0; - break; - - case 'MSCHAPv2': - // Construct data package - $crpt = new Crypt_CHAP_MSv2; - $crpt->username = $username; - $crpt->password = $password; - $rauth->challenge = $crpt->authChallenge; - $rauth->peerChallenge = $crpt->peerChallenge; - $rauth->chapid = $crpt->chapid; - $rauth->response = $crpt->challengeResponse(); - break; - - default: - $rauth->password = $password; - break; - } - - if (PEAR::isError($rauth->start())) { - $retvalue['auth_val'] = 1; - $retvalue['error'] = $rauth->getError(); - - // If we encounter an error immediately stop this function and go back - $rauth->close(); - return $retvalue; - } - - // Default attributes - $rauth->putAttribute(RADIUS_SERVICE_TYPE, RADIUS_LOGIN); - $rauth->putAttribute(RADIUS_NAS_PORT_TYPE, RADIUS_ETHERNET); - $rauth->putAttribute(RADIUS_NAS_PORT, $nas_port, 'integer'); - - // Extra data to identify the client and nas - $rauth->putAttribute(RADIUS_FRAMED_IP_ADDRESS, $clientip, addr); - $rauth->putAttribute(RADIUS_CALLED_STATION_ID, $calledstationid); - $rauth->putAttribute(RADIUS_CALLING_STATION_ID, $callingstationid); - - // Send request - $result = $rauth->send(); - - // Evaluation of the response - // 1 -> Access-Request => We will use this value as an error indicator since we can't get a 1 back from the radius - // 2 -> Access-Accept - // 3 -> Access-Reject - // See RFC2865 for this. - if (PEAR::isError($result)) { - $retvalue['auth_val'] = 1; - $retvalue['error'] = $result->getMessage(); - - } else if ($result === true) { - $retvalue['auth_val'] = 2; - - } else { - $retvalue['auth_val'] = 3; - - } - - // Get attributes, even if auth failed. - // We will push the results in the retvalue array - if (!$rauth->getAttributes()) { - $retvalue['error'] = $rauth->getError(); - - } else { - $retvalue = array_merge($retvalue,$rauth->listAttributes()); - - // We convert the session_terminate_time to unixtimestamp if its set before returning the whole array to our caller - if (!empty($retvalue['session_terminate_time'])) { - $stt = &$retvalue['session_terminate_time']; - $stt = strtotime(preg_replace("/\+(\d+):(\d+)$/", " +\${1}\${2}", preg_replace("/(\d+)T(\d+)/", "\${1} \${2}",$stt))); - } - } - - // close OO RADIUS_AUTHENTICATION - $rauth->close(); - unset($rauth); - - return $retvalue; - -} - -?> diff --git a/usr/local/openssl/openssl.cnf b/usr/local/openssl/openssl.cnf deleted file mode 120000 index f95d25b..0000000 --- a/usr/local/openssl/openssl.cnf +++ /dev/null @@ -1 +0,0 @@ -../../../etc/ssl/openssl.cnf
\ No newline at end of file diff --git a/usr/local/pkg/miniupnpd.inc b/usr/local/pkg/miniupnpd.inc deleted file mode 100644 index 4ea768c..0000000 --- a/usr/local/pkg/miniupnpd.inc +++ /dev/null @@ -1,297 +0,0 @@ -<?php - require_once("util.inc"); - require_once("config.inc"); - require_once("functions.inc"); - require_once("shaper.inc"); - - $shortcut_section = "upnp"; - - /* MiniUPnPd */ - - function upnp_notice($msg) { - log_error("miniupnpd: {$msg}"); - } - - function upnp_warn($msg) { - log_error("miniupnpd: {$msg}"); - } - - function upnp_running () { - if ((int)exec('/bin/pgrep -a miniupnpd | /usr/bin/wc -l') > 0) { - return true; - } - return false; - } - - function upnp_write_config($file, $text) { - $handle = fopen($file, 'w'); - if (!$handle) { - upnp_warn("Could not open {$file} for writing."); - return; - } - fwrite($handle, $text); - fclose($handle); - } - - function upnp_uuid() { - /* md5 hash of wan mac */ - $uuid = md5(get_interface_mac(get_real_interface("wan"))); - /* put uuid in correct format 8-4-4-4-12 */ - return substr($uuid, 0, 8) . '-' . substr($uuid, 9, 4) . '-' . substr($uuid, 13, 4) . '-' . substr($uuid, 17, 4) . '-' . substr($uuid, 21, 12); - } - - function upnp_validate_queue($qname) { - read_altq_config(); - $qlist = get_altq_name_list(); - if (is_array($qlist)) { - return in_array($qname, $qlist); - } else { - return false; - } - } - - function upnp_validate_ip($ip, $check_cdir) { - /* validate cidr */ - $ip_array = array(); - if ($check_cdir) { - $ip_array = explode('/', $ip); - if (count($ip_array) == 2) { - if ($ip_array[1] < 1 || $ip_array[1] > 32) { - return false; - } - } else { - if (count($ip_array) != 1) { - return false; - } - } - } else { - $ip_array[] = $ip; - } - - /* validate ip */ - if (!is_ipaddr($ip_array[0])) { - return false; - } - return true; - } - - function upnp_validate_port($port) { - foreach (explode('-', $port) as $sub) { - if ($sub < 0 || $sub > 65535) { - return false; - } - } - return true; - } - - function before_form_miniupnpd(&$pkg) { - global $config; - - } - - function validate_form_miniupnpd($post, &$input_errors) { - if ($post['enable'] && (!$post['enable_upnp'] && !$post['enable_natpmp'])) { - $input_errors[] = 'At least one of \'UPnP\' or \'NAT-PMP\' must be allowed'; - } - if ($post['iface_array']) { - foreach ($post['iface_array'] as $iface) { - if ($iface == 'wan') { - $input_errors[] = 'It is a security risk to specify WAN in the \'Interface\' field'; - } elseif ($iface == $post['ext_iface']) { - $input_errors[] = 'You cannot select the external interface as an internal interface.'; - } - } - } - if ($post['overridewanip'] && !upnp_validate_ip($post['overridewanip'], false)) { - $input_errors[] = 'You must specify a valid ip address in the \'Override WAN address\' field'; - } - if (($post['download'] && !$post['upload']) || ($post['upload'] && !$post['download'])) { - $input_errors[] = 'You must fill in both \'Maximum Download Speed\' and \'Maximum Upload Speed\' fields'; - } - if ($post['download'] && $post['download'] <= 0) { - $input_errors[] = 'You must specify a value greater than 0 in the \'Maximum Download Speed\' field'; - } - if ($post['upload'] && $post['upload'] <= 0) { - $input_errors[] = 'You must specify a value greater than 0 in the \'Maximum Upload Speed\' field'; - } - if ($post['upnpqueue'] && !upnp_validate_queue($post['upnpqueue'])) { - $input_errors[] = 'You must specify a valid traffic shaping queue.'; - } - - /* user permissions validation */ - $j = substr_count(implode(array_keys($post)), "permuser"); - for ($i = 0; $i < $j; $i++) { - if ($post["permuser{$i}"]) { - $perm = explode(' ', $post["permuser{$i}"]); - /* should explode to 4 args */ - if (count($perm) != 4) { - $input_errors[] = "You must follow the specified format in the 'User specified permissions {$i}' field"; - } else { - /* must with allow or deny */ - if (!($perm[0] == 'allow' || $perm[0] == 'deny')) { - $input_errors[] = "You must begin with allow or deny in the 'User specified permissions {$i}' field"; - } - /* verify port or port range */ - if (!upnp_validate_port($perm[1]) || !upnp_validate_port($perm[3])) { - $input_errors[] = "You must specify a port or port range between 0 and 65535 in the 'User specified permissions {$i}' field"; - } - /* verify ip address */ - if (!upnp_validate_ip($perm[2], true)) { - $input_errors[] = "You must specify a valid ip address in the 'User specified permissions {$i}' field"; - } - } - } - } - } - - function sync_package_miniupnpd() { - global $g, $config; - global $input_errors; - - $upnp_config = $config['installedpackages']['miniupnpd']['config'][0]; - $config_file = '/var/etc/miniupnpd.conf'; - - if (!isset($upnp_config['ext_iface']) || empty($upnp_config['ext_iface'])) { - $ext_ifname = get_real_interface(); - } else { - $if = convert_friendly_interface_to_real_interface_name($upnp_config['ext_iface']); - if ($if != $upnp_config['ext_iface']) { - $ext_ifname = $if; - } else { - $ext_ifname = get_real_interface(); - upnp_warn("Could not resolve real interface for {$upnp_config['ext_iface']}, defaulting to WAN"); - } - } - - $config_text = "ext_ifname={$ext_ifname}\n"; - $config_text .= "port=2189\n"; - - $ifaces_active = ''; - - /* since config is written before this file is invoked we don't need to read post data */ - if ($upnp_config['enable'] && !empty($upnp_config['iface_array'])) { - $iface_array = explode(',', $upnp_config['iface_array']); - - foreach ($iface_array as $iface) { - /* Setting the same internal and external interface is not allowed. */ - if ($iface == $upnp_config['ext_iface']) { - continue; - } - $if = convert_friendly_interface_to_real_interface_name($iface); - /* above function returns iface if fail */ - if ($if != $iface) { - $addr = find_interface_ip($if); - $bits = find_interface_subnet($if); - /* check that the interface has an ip address before adding parameters */ - if (is_ipaddr($addr)) { - $config_text .= "listening_ip={$if}\n"; - if (!$ifaces_active) { - $webgui_ip = $addr; - $ifaces_active = $iface; - } else { - $ifaces_active .= ", {$iface}"; - } - } else { - upnp_warn("Interface {$iface} has no ip address, ignoring"); - } - } else { - upnp_warn("Could not resolve real interface for {$iface}"); - } - } - - if (!empty($ifaces_active)) { - /* override wan ip address, common for carp, etc */ - if ($upnp_config['overridewanip']) { - $config_text .= "ext_ip={$upnp_config['overridewanip']}\n"; - } - - $download = $upnp_config['download']*1000; - $upload = $upnp_config['upload']*1000; - - /* set upload and download bitrates */ - if (!empty($download) && !empty($upload)) { - $config_text .= "bitrate_down={$download}\n"; - $config_text .= "bitrate_up={$upload}\n"; - } - - /* enable logging of packets handled by miniupnpd rules */ - if ($upnp_config['logpackets']) { - $config_text .= "packet_log=yes\n"; - } - - /* enable system uptime instead of miniupnpd uptime */ - if ($upnp_config['sysuptime']) { - $config_text .= "system_uptime=yes\n"; - } - - /* set webgui url */ - if (!empty($config['system']['webgui']['protocol'])) { - $config_text .= "presentation_url={$config['system']['webgui']['protocol']}://{$webgui_ip}"; - if (!empty($config['system']['webgui']['port'])) { - $config_text .= ":{$config['system']['webgui']['port']}"; - } - $config_text .= "/\n"; - } - - /* set uuid and serial */ - $config_text .= "uuid=".upnp_uuid()."\n"; - $config_text .= "serial=".strtoupper(substr(upnp_uuid(), 0, 8))."\n"; - - /* set model number */ - $config_text .= "model_number=" . $g['product_version'] . "\n"; - - /* upnp access restrictions */ - foreach ($upnp_config['row'] as $row) { - if ($row['permuser']) { - $config_text .= "{$row["permuser"]}\n"; - } - } - - if ($upnp_config['permdefault']) { - $config_text .= "deny 0-65535 0.0.0.0/0 0-65535\n"; - } - - /* Recheck if queue is valid */ - if (!upnp_validate_queue($upnp_config['upnpqueue'])) { - unset($upnp_config['upnpqueue']); - } - - /* Add shaper queue */ - if ($upnp_config['upnpqueue']) { - $config_text .= "queue={$upnp_config['upnpqueue']}\n"; - } - - /* Allow UPnP or NAT-PMP as requested */ - $config_text .= "enable_upnp=" . ($upnp_config['enable_upnp'] ? "yes\n" : "no\n"); - $config_text .= "enable_natpmp=" . ($upnp_config['enable_natpmp'] ? "yes\n" : "no\n"); - - /* write out the configuration */ - upnp_write_config($config_file, $config_text); - - /* if miniupnpd not running start it */ - if (!upnp_running()) { - upnp_notice("Starting service on interface: {$ifaces_active}"); - upnp_action('start'); - } else { - /* restart miniupnpd if settings were changed */ - upnp_notice("Restarting service on interface: {$ifaces_active}"); - upnp_action('restart'); - } - } - } else { - /* user does not want miniupnpd running */ - /* lets stop the service and remove the rc file */ - - if (file_exists($config_file)) { - if (!$upnp_config['enable']) { - upnp_notice('Stopping service: miniupnpd disabled'); - } else { - upnp_notice('Stopping service: no interfaces selected'); - } - - upnp_action('stop'); - @unlink($config_file); - } - } - } -?> diff --git a/usr/local/pkg/miniupnpd.xml b/usr/local/pkg/miniupnpd.xml deleted file mode 100644 index 33d8ac4..0000000 --- a/usr/local/pkg/miniupnpd.xml +++ /dev/null @@ -1,135 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<packagegui> - <title>Services: UPnP & NAT-PMP</title> - <name>miniupnpd</name> - <version>20100712</version> - <savetext>Change</savetext> - <include_file>/usr/local/pkg/miniupnpd.inc</include_file> - <menu> - <name>UPnP & NAT-PMP</name> - <tooltiptext>Set UPnP & NAT-PMP settings such as interfaces to listen on.</tooltiptext> - <section>Services</section> - <url>/pkg_edit.php?xml=miniupnpd.xml&id=0</url> - </menu> - <additional_files_needed> - <item>https://packages.pfsense.org/packages/config/miniupnpd/miniupnpd.inc</item> - <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> - </additional_files_needed> - <additional_files_needed> - <item>https://packages.pfsense.org/packages/config/miniupnpd/status_upnp.php</item> - <prefix>/usr/local/www/</prefix> - <chmod>0755</chmod> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/sbin/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/miniupnpd/sbin/miniupnpd</item> - </additional_files_needed> - <service> - <name>miniupnpd</name> - <rcfile>miniupnpd.sh</rcfile> - <executable>miniupnpd</executable> - </service> - <fields> - <field> - <name>UPnP & NAT-PMP Settings</name> - <type>listtopic</type> - <enablefields>enable_upnp,enable_natpmp,ext_iface,iface_array,download,upload,overridewanip,upnpqueue,logpackets,sysuptime,permdefault</enablefields> - </field> - <field> |