diff options
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/globals.inc | 2 | ||||
-rw-r--r-- | etc/inc/interfaces.inc | 414 | ||||
-rw-r--r-- | etc/inc/pfsense-utils.inc | 177 | ||||
-rw-r--r-- | etc/inc/priv.defs.inc | 6 | ||||
-rw-r--r-- | etc/inc/rrd.inc | 135 | ||||
-rw-r--r-- | etc/inc/upgrade_config.inc | 92 | ||||
-rw-r--r-- | etc/phpshellsessions/gitsync | 1 | ||||
-rwxr-xr-x | etc/rc.bootup | 2 |
8 files changed, 570 insertions, 259 deletions
diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc index 782251a..6e2b1f6 100644 --- a/etc/inc/globals.inc +++ b/etc/inc/globals.inc @@ -88,7 +88,7 @@ $g = array( "disablehelpmenu" => false, "disablehelpicon" => false, "debug" => false, - "latest_config" => "6.3", + "latest_config" => "6.4", "nopkg_platforms" => array("cdrom"), "minimum_ram_warning" => "105", "minimum_ram_warning_text" => "128 MB", diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 7bcd95d..e3f5f0c 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -806,13 +806,11 @@ function interface_bring_down($interface = "wan", $destroy = false) { $realif = get_real_interface($interface); switch ($ifcfg['ipaddr']) { + case "ppp": case "pppoe": - killbypid("{$g['varrun_path']}/pppoe_{$interface}.pid"); - sleep(2); - unlink_if_exists("{$g['varetc_path']}/mpd_{$interface}.conf"); - break; case "pptp": - killbypid("{$g['varrun_path']}/pptp_{$interface}.pid"); + case "l2tp": + killbypid("{$g['varrun_path']}/{$ifcfg['ipaddr']}_{$interface}.pid"); sleep(2); unlink_if_exists("{$g['varetc_path']}/mpd_{$interface}.conf"); break; @@ -833,11 +831,6 @@ function interface_bring_down($interface = "wan", $destroy = false) { mwexec("/usr/sbin/arp -d -i {$realif} -a"); } break; - case "ppp": - killbypid("{$g['varrun_path']}/ppp_{$interface}.pid"); - sleep(2); - unlink_if_exists("{$g['varetc_path']}/mpd_{$interface}.conf"); - break; default: if(does_interface_exist("$realif")) { mwexec("/sbin/ifconfig " . escapeshellarg($realif) . " delete", true); @@ -867,122 +860,239 @@ function interface_bring_down($interface = "wan", $destroy = false) { return; } -function interface_ppp_configure($interface) { +/* This function can configure PPPoE, MLPPP (PPPoE), PPtP. +* It writes the mpd config file to /var/etc every time the interfaces is brought up. +*/ + +function interface_ppps_configure($interface) { global $config, $g; - $wancfg =& $config['interfaces'][$interface]; + $intcfg = &$config['interfaces'][$interface]; if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { - foreach ($config['ppps']['ppp'] as $ppp) { - if ($wancfg['if'] == basename($ppp['port'])) + foreach ($config['ppps']['ppp'] as $pppid => $ppp) { + if ($intcfg['ptpid'] == $ppp['ptpid']) break; } } - if (!$ppp || empty($ppp['port'])) - return; + if (!$ppp || $intcfg['ptpid'] != $ppp['ptpid']){ + log_error("PPP configuration error in interface_ppps_configure()."); + return; + } - if ($interface == "wan") - $pppid = "0"; + $pppif = $intcfg['if']; + if ($ppp['type'] == "ppp") + $type = "modem"; else - $pppid = substr($interface, 3); - - $pppif = "ppp{$pppid}"; - - // mpd5 requires a /var/spool/lock directory + $type = $ppp['type']; + $upper_type = strtoupper($ppp['type']); + + // mpd5 requires a /var/spool/lock directory for PPP modem links. if(!is_dir("/var/spool/lock")) { exec("/bin/mkdir -p /var/spool/lock"); exec("/bin/chmod a+rw /var/spool/lock/."); } + // mpd5 modem chat script expected in the same directory as the mpd_xxx.conf files if (!file_exists("{$g['varetc_path']}/mpd.script")) mwexec("/bin/ln -s /usr/local/sbin/mpd.script {$g['varetc_path']}/."); if($g['booting']) - echo " configuring PPP on {$pppif} interface...\n"; + echo " configuring {$upper_type} on {$pppif} interface...\n"; /* generate mpd.conf */ $fd = fopen("{$g['varetc_path']}/mpd_{$interface}.conf", "w"); if (!$fd) { - log_error("Error: cannot open mpd_{$interface}.conf in interface_ppp_configure().\n"); + log_error("Error: cannot open mpd_{$interface}.conf in interface_ppps_configure().\n"); return 1; } + $ports = explode(',',$ppp['ports']); + + if (is_array($ports) && count($ports) > 1) + $multilink = "enable"; + else + $multilink = "disable"; + + if ($type == "modem"){ + if (is_ipaddr($ppp['localip'])) + $localip = $ppp['localip']; + else + $localip = '0.0.0.0'; + + if (is_ipaddr($ppp['gateway'])) + $gateway = $ppp['gateway']; + else + $gateway = "10.6.6.{$pppid}"; + $ranges = "{$localip}/0 {$gateway}/0"; + } + else + $ranges = "0.0.0.0/0 0.0.0.0/0"; + + $localips = explode(',',$ppp['localip']); + $gateways = explode(',',$ppp['gateway']); + $subnets = explode(',',$ppp['subnet']); + + if (isset($ppp['ondemand'])) + $ondemand = "enable"; + else + $ondemand = "disable"; + if (!isset($ppp['idletimeout'])) + $ppp['idletimeout'] = 0; + + if (empty($ppp['username']) && $type == "modem"){ + $ppp['username'] = "user"; + $ppp['password'] = "none"; + } + if (empty($ppp['password']) && $type == "modem") + $passwd = "none"; + else + $passwd = base64_decode($ppp['password']); + $bandwidths = explode(',',$ppp['bandwidth']); + $mtus = explode(',',$ppp['mtu']); + $mrus = explode(',',$ppp['mru']); + + if (!isset($ppp['idletimeout'])) + $mrrus = explode(',',$ppp['mrru']); // Construct the mpd.conf file $mpdconf = <<<EOD startup: - # configure mpd users - set user admin pfsense admin - set user user pfsense # configure the console - set console self 127.0.0.1 500{$pppid} - set console open + set console close # configure the web server set web close - #set web self 127.0.0.1 550{$pppid} - #set web open -EOD; - - if (is_ipaddr($ppp['localip'])) - $localip = $ppp['localip']; - else - $localip = '0.0.0.0'; - if (is_ipaddr($ppp['gateway'])) - $localgw = $ppp['gateway']; - else - $localgw = "10.0.0.{$pppid}"; - - $mpdconf .= <<<EOD default: -pppclient: +{$ppp['type']}client: create bundle static {$interface} set iface name {$pppif} - set iface up-script /usr/local/sbin/ppp-linkup - set iface down-script /usr/local/sbin/ppp-linkdown - set ipcp ranges {$localip}/0 {$localgw}/0 EOD; - - if (isset($config['system']['dnsallowoverride'])) { + $setdefaultgw = false; + $founddefaultgw = false; + if (is_array($config['gateways']['gateway_item'])) { + foreach($config['gateways']['gateway_item'] as $gateway) { + if($interface == $gateway['interface'] && isset($gateway['defaultgw'])) { + $setdefaultgw = true; + break; + } else if (isset($gateway['defaultgw']) && !empty($gateway['interface'])) { + $founddefaultgw = true; + break; + } + } + } + + if (($interface == "wan" && $founddefaultgw == false) || $setdefaultgw == true){ + $setdefaultgw = true; $mpdconf .= <<<EOD - set ipcp yes req-pri-dns - set ipcp yes req-sec-dns + set iface route default EOD; } + $mpdconf .= <<<EOD + set iface {$ondemand} on-demand + set iface idle {$ppp['idletimeout']} + +EOD; - if (isset($ppp['defaultgw'])) { + if (isset($ppp['ondemand'])) $mpdconf .= <<<EOD - set iface route default + set iface addrs 10.10.1.1 10.10.1.2 + +EOD; + + if (isset($ppp['tcpmssfix'])) + $mpdconf .= <<<EOD + set iface enable tcpmssfix EOD; - } $mpdconf .= <<<EOD - create link static lnk{$interface} modem + set iface up-script /usr/local/sbin/ppp-linkup + set iface down-script /usr/local/sbin/ppp-linkdown + set ipcp ranges {$ranges} + +EOD; + if (isset($ppp['vjcomp'])) + $mpdconf .= <<<EOD + set ipcp no vjcomp + +EOD; + + if (isset($config['system']['dnsallowoverride']) && $setdefaultgw == true) + $mpdconf .= <<<EOD + set ipcp enable req-pri-dns + set ipcp enable req-sec-dns + +EOD; + +/* + if (!isset($intcfg['dnsnosec']) && isset($config['system']['dnsallowoverride'])) + $mpdconf .= <<<EOD + set ipcp enable req-sec-dns + +EOD; +*/ + foreach($ports as $pid => $port){ + $mpdconf .= <<<EOD + + create link static {$interface}_link{$pid} {$type} + set link action bundle {$interface} + set link {$multilink} multilink set link keep-alive 10 60 set link max-redial 0 + +EOD; + if (isset($ppp['shortseq'])) + $mpdconf .= <<<EOD + set link no shortseq + +EOD; + + if (isset($ppp['acfcomp'])) + $mpdconf .= <<<EOD + set link no acfcomp + +EOD; + + if (isset($ppp['protocomp'])) + $mpdconf .= <<<EOD + set link no protocomp + +EOD; + + $mpdconf .= <<<EOD set link disable chap pap set link accept chap pap eap - set link enable no-orig-auth - #set link enable incoming - set link action bundle {$interface} + set link disable incoming EOD; - if (empty($ppp['username'])) { - $ppp['username'] = "user"; - $ppp['password'] = "none"; - } - if (empty($ppp['password'])) - $ppp['password'] = "none"; + + if (!empty($bandwidths[$pid])) + $mpdconf .= <<<EOD + set link bandwidth {$bandwidths[$pid]} + +EOD; + + if (!empty($mtus[$pid])) + $mpdconf .= <<<EOD + set link mtu {$mtus[$pid]} + +EOD; + + if (!empty($mrus[$pid])) + $mpdconf .= <<<EOD + set link mru {$mrus[$pid]} + +EOD; $mpdconf .= <<<EOD set auth authname "{$ppp['username']}" - set auth password {$ppp['password']} + set auth password {$passwd} EOD; - - $mpdconf .= <<<EOD - set modem device {$ppp['port']} + if ($type == "modem") { + $mpdconf .= <<<EOD + set modem device {$ppp['ports']} set modem script DialPeer set modem idle-script Ringback set modem watch -cd @@ -990,46 +1100,128 @@ EOD; set modem var \$Telephone "{$ppp['phone']}" EOD; - if (isset($ppp['connect-timeout'])) { - $mpdconf .= <<<EOD + } + if (isset($ppp['connect-timeout']) && $type == "modem") { + $mpdconf .= <<<EOD set modem var \$ConnectTimeout "{$ppp['connect-timeout']}" EOD; - } - if (isset($ppp['initstr'])) { - $initstr = base64_decode($ppp['initstr']); - $mpdconf .= <<<EOD + } + if (isset($ppp['initstr']) && $type == "modem") { + $initstr = base64_decode($ppp['initstr']); + $mpdconf .= <<<EOD set modem var \$InitString "{$initstr}" EOD; - } - if (isset($ppp['simpin'])) { - $mpdconf .= <<<EOD + } + if (isset($ppp['simpin']) && $type == "modem") { + $mpdconf .= <<<EOD set modem var \$SimPin "{$ppp['simpin']}" set modem var \$PinWait "{$ppp['pin-wait']}" EOD; - } - if (isset($ppp['apn'])) { - $mpdconf .= <<<EOD + } + if (isset($ppp['apn']) && $type == "modem") { + $mpdconf .= <<<EOD set modem var \$APN "{$ppp['apn']}" set modem var \$APNum "{$ppp['apnum']}" EOD; - } + } + if (isset($ppp['provider']) && $type == "pppoe") { + $mpdconf .= <<<EOD + set pppoe service "{$ppp['provider']}" - $mpdconf .= "\topen"; +EOD; + } + if ($type == "pppoe") + $mpdconf .= <<<EOD + set pppoe iface {$port} + +EOD; + + if ($type == "pptp" || $type == "l2tp") { + $mpdconf .= <<<EOD + set bundle no noretry + set pptp self {$localips[$pid]} + set pptp peer {$gateways[$pid]} + set pptp disable windowing + +EOD; + } + $mpdconf .= "\topen\r\n"; + } //end foreach($port) // Write out configuration for mpd_ppp.conf and mpd.secret fwrite($fd, $mpdconf); fclose($fd); - // Launch specified ppp instance - if (file_exists("{$ppp['port']}")) { + // Create the uptime log if requested and if it doesn't exist already, or delete it if it is no longer requested. + if (isset($ppp['uptime'])) { + if (!file_exists("/conf/{$pppif}.log")) { + conf_mount_rw(); + mwexec("echo /dev/null > /conf/{$pppif}.log"); + conf_mount_ro(); + } + } else { + if (file_exists("/conf/{$pppif}.log")) { + conf_mount_rw(); + mwexec("rm -f /conf/{$pppif}.log"); + conf_mount_ro(); + } + } + // Check for PPPoE periodic reset request + if ($type == "pppoe") + if (isset($ppp['pppoe-reset-type'])) + setup_pppoe_reset_file($ppp['ptpid'], $interface); + else + setup_pppoe_reset_file($ppp['ptpid']); + + if(file_exists("{$g['varrun_path']}/{$ppp['type']}_{$interface}.pid") and $g['booting']) { + /* if we are booting and mpd has already been started then don't start again. */ + } else { + foreach($ports as $pid => $port){ + switch ($ppp['type']) { + case "pppoe": + /* Bring the parent interface up */ + if($port) + interfaces_bring_up($port); + else + log_error("Could not bring up interface {$port} for {$interface} {$ppp['type']} link in interface_ppps_configure()."); + break; + case "pptp": + case "l2tp": + /* configure interface */ + if($port) + mwexec("/sbin/ifconfig " . escapeshellarg($port) . " " . + escapeshellarg($localips[$pid] . "/" . $subnets[$pid]) . " up"); + else + log_error("Could not bring up interface {$port} for {$interface} {$ppp['type']} link in interface_ppps_configure()."); + break; + case "ppp": + if (!file_exists("{$port}")) { + log_error("Device {$port} does not exist. PPP link cannot start without the modem device."); + return 1; + } + break; + default: + break; + } + } + /* fire up mpd */ - mwexec("/usr/local/sbin/mpd5 -b -k -d {$g['varetc_path']} -f mpd_{$interface}.conf -p {$g['varrun_path']}/ppp_{$interface}.pid -s {$interface} pppclient"); - } else - log_error("Device {$ppp['port']} has disappeared."); + mwexec("/usr/local/sbin/mpd5 -b -k -d {$g['varetc_path']} -f mpd_{$interface}.conf -p {$g['varrun_path']}/{$ppp['type']}_{$interface}.pid -s ppp {$ppp['type']}client"); + } + + /* sleep until wan is up - or 30 seconds, whichever comes first */ + for ($count = 0; $count < 12; $count++) { + if(file_exists("{$g['tmp_path']}/{$pppif}up")) { + break; + } + sleep(1); + } + + return 0; } function interfaces_carp_setup() { @@ -1939,13 +2131,13 @@ function interface_configure($interface = "wan", $reloadall = false) { interface_dhcp_configure($interface); break; case 'pppoe': - interface_pppoe_configure($interface); + interface_ppps_configure($interface); break; case 'pptp': - interface_pptp_configure($interface); + interface_ppps_configure($interface); break; case 'ppp': - interface_ppp_configure($interface); + interface_ppps_configure($interface); break; default: if ($wancfg['ipaddr'] <> "" && $wancfg['subnet'] <> "") { @@ -2648,24 +2840,6 @@ function get_real_interface($interface = "wan") { $counter++; } break; - case "pppoe": - if ($if == "wan") - $wanif = "pppoe0"; - else - $wanif = "pppoe" . substr($if,3); - break; - case "pptp": - if ($if == "wan") - $wanif = "pptp0"; - else - $wanif = "pptp" . substr($if, 3); - break; - case "ppp": - if ($if == "wan") - $wanif = "ppp0"; - else - $wanif = "ppp" . substr($if, 3); - break; default: $wanif = $cfg['if']; break; @@ -2966,9 +3140,10 @@ function get_interfaces_with_gateway() { switch ($ifname['ipaddr']) { case "dhcp": case "carpdev-dhcp": + case "ppp"; case "pppoe": case "pptp": - case "ppp"; + case "l2tp"; $ints[] = $ifdescr; break; default: @@ -3163,16 +3338,17 @@ function is_jumbo_capable($int) { return false; } -function setup_pppoe_reset_file($interface, $status) { - define("CRON_PPPOE_CMD_FILE", "/conf/pppoe{$interface}restart"); - define("CRON_PPPOE_CMD", "#!/bin/sh\necho '<?php require(\"config.inc\"); require(\"interfaces.inc\"); interface_reconfigure({$interface}); ?>' | /usr/local/bin/php -q"); - if ($status == true) { - if (!file_exists(CRON_PPPOE_CMD_FILE)) { - file_put_contents(CRON_PPPOE_CMD_FILE, CRON_PPPOE_CMD); - chmod(CRON_PPPOE_CMD_FILE, 0700); - } +function setup_pppoe_reset_file($ptpid, $iface="") { + global $g; + $cron_file = "{$g['varetc_path']}/pppoe_restart_{$ptpid}"; + + if(!empty($iface) && !empty($ptpid)){ + $cron_cmd = "#!/bin/sh\necho '<?php require(\"config.inc\"); require(\"interfaces.inc\"); interface_reconfigure({$iface}); log_error(\"PPPoE periodic reset executed on {$iface}\"); ?>' | /usr/local/bin/php -q"; + file_put_contents($cron_file, $cron_cmd); + chmod($cron_file, 0700); + sigkillbypid("{$g['varrun_path']}/cron.pid", "HUP"); } else - unlink_if_exists(CRON_PPPOE_CMD_FILE); + unlink_if_exists($cron_file); } ?> diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 21bbe0c..97aa3e6 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1255,14 +1255,23 @@ function get_interface_info($ifdescr) { /* PPP interface? -> get uptime for this session and cumulative uptime from the persistant log file in conf */ case "ppp": if ($ifinfo['status'] == "up") - $ifinfo['ppplink'] = "up"; + $ifinfo['ppplink'] = "up"; else $ifinfo['ppplink'] = "down" ; - $dev = $config['interfaces'][$if]['if']; - if (empty($dev)) + if (empty($ifinfo['status'])) + $ifinfo['status'] = "down"; + + if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { + foreach ($config['ppps']['ppp'] as $pppid => $ppp) { + if ($config['interfaces'][$if]['ptpid'] == $ppp['ptpid']) + break; + } + } + $dev = $ppp['ports']; + if ($config['interfaces'][$if]['ptpid'] != $ppp['ptpid'] || empty($dev)) break; - if (file_exists("/dev/{$dev}")) { + if (file_exists($dev)) { if (file_exists("{$g['varrun_path']}/ppp_{$if}.pid")) { $ifinfo['pppinfo'] = "{$ifinfo['if']}"; $sec = trim(`/usr/local/sbin/ppp-uptime.sh {$ifinfo['if']}`); @@ -2003,4 +2012,164 @@ function get_include_contents($filename) { return false; } +/* This xml 2 array function is courtesy of the php.net comment section on xml_parse. + * it is roughly 4 times faster then our existing pfSense parser but due to the large + * size of the RRD xml dumps this is required. + * The reason we do not use it for pfSense is that it does not know about array fields + * which causes it to fail on array fields with single items. Possible Todo? + */ +function xml2array($contents, $get_attributes = 1, $priority = 'tag') +{ + if (!function_exists('xml_parser_create')) + { + return array (); + } + $parser = xml_parser_create(''); + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); + xml_parse_into_struct($parser, trim($contents), $xml_values); + xml_parser_free($parser); + if (!$xml_values) + return; //Hmm... + $xml_array = array (); + $parents = array (); + $opened_tags = array (); + $arr = array (); + $current = & $xml_array; + $repeated_tag_index = array (); + foreach ($xml_values as $data) + { + unset ($attributes, $value); + extract($data); + $result = array (); + $attributes_data = array (); + if (isset ($value)) + { + if ($priority == 'tag') + $result = $value; + else + $result['value'] = $value; + } + if (isset ($attributes) and $get_attributes) + { + foreach ($attributes as $attr => $val) + { + if ($priority == 'tag') + $attributes_data[$attr] = $val; + else + $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr' + } + } + if ($type == "open") + { + $parent[$level -1] = & $current; + if (!is_array($current) or (!in_array($tag, array_keys($current)))) + { + $current[$tag] = $result; + if ($attributes_data) + $current[$tag . '_attr'] = $attributes_data; + $repeated_tag_index[$tag . '_' . $level] = 1; + $current = & $current[$tag]; + } + else + { + if (isset ($current[$tag][0])) + { + $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; + $repeated_tag_index[$tag . '_' . $level]++; + } + else + { + $current[$tag] = array ( + $current[$tag], + $result + ); + $repeated_tag_index[$tag . '_' . $level] = 2; + if (isset ($current[$tag . '_attr'])) + { + $current[$tag]['0_attr'] = $current[$tag . '_attr']; + unset ($current[$tag . '_attr']); + } + } + $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1; + $current = & $current[$tag][$last_item_index]; + } + } + elseif ($type == "complete") + { + if (!isset ($current[$tag])) + { + $current[$tag] = $result; + $repeated_tag_index[$tag . '_' . $level] = 1; + if ($priority == 'tag' and $attributes_data) + $current[$tag . '_attr'] = $attributes_data; + } + else + { + if (isset ($current[$tag][0]) and is_array($current[$tag])) + { + $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; + if ($priority == 'tag' and $get_attributes and $attributes_data) + { + $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; + } + $repeated_tag_index[$tag . '_' . $level]++; + } + else + { + $current[$tag] = array ( + $current[$tag], + $result + ); + $repeated_tag_index[$tag . '_' . $level] = 1; + if ($priority == 'tag' and $get_attributes) + { + if (isset ($current[$tag . '_attr'])) + { + $current[$tag]['0_attr'] = $current[$tag . '_attr']; + unset ($current[$tag . '_attr']); + } + if ($attributes_data) + { + $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; + } + } + $repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken + } + } + } + elseif ($type == 'close') + { + $current = & $parent[$level -1]; + } + } + return ($xml_array); +} + +function get_country_name($country_code) { + if ($country_code != "ALL" && strlen($country_code) != 2) + return ""; + + $country_names_xml = "/usr/local/share/mobile-broadband-provider-info/iso_3166-1_list_en.xml"; + $country_names_contents = file_get_contents($country_names_xml); + $country_names = xml2array($country_names_contents); + + if($country_code == "ALL") { + $country_list = array(); + foreach($country_names['ISO_3166-1_List_en']['ISO_3166-1_Entry'] as $country) { + $country_list[] = array( "code" => $country['ISO_3166-1_Alpha-2_Code_element'], + "name" => ucwords(strtolower($country['ISO_3166-1_Country_name'])) ); + } + return $country_list; + } + + foreach ($country_names['ISO_3166-1_List_en']['ISO_3166-1_Entry'] as $country) { + if ($country['ISO_3166-1_Alpha-2_Code_element'] == strtoupper($country_code)) { + return ucwords(strtolower($country['ISO_3166-1_Country_name'])); + } + } + return ""; +} + ?> diff --git a/etc/inc/priv.defs.inc b/etc/inc/priv.defs.inc index 2c4543d..7c900fe 100644 --- a/etc/inc/priv.defs.inc +++ b/etc/inc/priv.defs.inc @@ -318,6 +318,12 @@ $priv_list['page-getstats']['descr'] = "Allow access to the 'AJAX: Get Stats' pa $priv_list['page-getstats']['match'] = array(); $priv_list['page-getstats']['match'][] = "getstats.php*"; +$priv_list['page-status-systemlogs-ppp'] = array(); +$priv_list['page-status-systemlogs-ppp']['name'] = "WebCfg - Status: System logs: IPsec VPN page"; +$priv_list['page-status-systemlogs-ppp']['descr'] = "Allow access to the 'Status: System logs: IPsec VPN' page."; +$priv_list['page-status-systemlogs-ppp']['match'] = array(); +$priv_list['page-status-systemlogs-ppp']['match'][] = "diag_logs_ppp.php*"; + $priv_list['page-diagnostics-nanobsd'] = array(); $priv_list['page-diagnostics-nanobsd']['name'] = "WebCfg - Diagnostics: NanoBSD"; $priv_list['page-diagnostics-nanobsd']['descr'] = "Allow access to the 'Diagnostics: NanoBSD' page."; diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc index fa2920e..85221e6 100644 --- a/etc/inc/rrd.inc +++ b/etc/inc/rrd.inc @@ -637,139 +637,4 @@ function kill_traffic_collector() { mwexec("/bin/pkill -f updaterrd.sh"); } -/* This xml 2 array function is courtesy of the php.net comment section on xml_parse. - * it is roughly 4 times faster then our existing pfSense parser but due to the large - * size of the RRD xml dumps this is required. - * The reason we do not use it for pfSense is that it does not know about array fields - * which causes it to fail on array fields with single items. Possible Todo? - */ -function xml2array($contents, $get_attributes = 1, $priority = 'tag') -{ - if (!function_exists('xml_parser_create')) - { - return array (); - } - $parser = xml_parser_create(''); - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); - xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); - xml_parse_into_struct($parser, trim($contents), $xml_values); - xml_parser_free($parser); - if (!$xml_values) - return; //Hmm... - $xml_array = array (); - $parents = array (); - $opened_tags = array (); - $arr = array (); - $current = & $xml_array; - $repeated_tag_index = array (); - foreach ($xml_values as $data) - { - unset ($attributes, $value); - extract($data); - $result = array (); - $attributes_data = array (); - if (isset ($value)) - { - if ($priority == 'tag') - $result = $value; - else - $result['value'] = $value; - } - if (isset ($attributes) and $get_attributes) - { - foreach ($attributes as $attr => $val) - { - if ($priority == 'tag') - $attributes_data[$attr] = $val; - else - $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr' - } - } - if ($type == "open") - { - $parent[$level -1] = & $current; - if (!is_array($current) or (!in_array($tag, array_keys($current)))) - { - $current[$tag] = $result; - if ($attributes_data) - $current[$tag . '_attr'] = $attributes_data; - $repeated_tag_index[$tag . '_' . $level] = 1; - $current = & $current[$tag]; - } - else - { - if (isset ($current[$tag][0])) - { - $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; - $repeated_tag_index[$tag . '_' . $level]++; - } - else - { - $current[$tag] = array ( - $current[$tag], - $result - ); - $repeated_tag_index[$tag . '_' . $level] = 2; - if (isset ($current[$tag . '_attr'])) - { - $current[$tag]['0_attr'] = $current[$tag . '_attr']; - unset ($current[$tag . '_attr']); - } - } - $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1; - $current = & $current[$tag][$last_item_index]; - } - } - elseif ($type == "complete") - { - if (!isset ($current[$tag])) - { - $current[$tag] = $result; - $repeated_tag_index[$tag . '_' . $level] = 1; - if ($priority == 'tag' and $attributes_data) - $current[$tag . '_attr'] = $attributes_data; - } - else - { - if (isset ($current[$tag][0]) and is_array($current[$tag])) - { - $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; - if ($priority == 'tag' and $get_attributes and $attributes_data) - { - $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; - } - $repeated_tag_index[$tag . '_' . $level]++; - } - else - { - $current[$tag] = array ( - $current[$tag], - $result - ); - $repeated_tag_index[$tag . '_' . $level] = 1; - if ($priority == 'tag' and $get_attributes) - { - if (isset ($current[$tag . '_attr'])) - { - $current[$tag]['0_attr'] = $current[$tag . '_attr']; - unset ($current[$tag . '_attr']); - } - if ($attributes_data) - { - $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; - } - } - $repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken - } - } - } - elseif ($type == 'close') - { - $current = & $parent[$level -1]; - } - } - return ($xml_array); -} - ?> diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc index 81ee8f6..d732fed 100644 --- a/etc/inc/upgrade_config.inc +++ b/etc/inc/upgrade_config.inc @@ -1970,4 +1970,96 @@ function upgrade_062_to_063() { } } + +function upgrade_063_to_064() { + global $config; + if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { + foreach ($config['ppps']['ppp'] as $pppid => $ppp) { + if (isset($ppp['port'])){ + $config['ppps']['ppp'][$pppid]['ports'] = $ppp['port']; + unset($config['ppps']['ppp'][$pppid]['port']); + } + if (!isset($ppp['type'])){ + $config['ppps']['ppp'][$pppid]['type'] = "ppp"; + } + if (!isset($ppp['ptpid'])){ + $config['ppps']['ppp'][$pppid]['ptpid'] = uniqid('', true); + } + if (isset($ppp['defaultgw'])){ + unset($config['ppps']['ppp'][$pppid]['defaultgw']); + } + } + + $ifcfg = &$config['interfaces']; + + if (!is_array($config['ppps']['ppp'])) + $config['ppps']['ppp'] = array(); + $a_ppps = &$config['ppps']['ppp']; + + foreach ($ifcfg as $ifname => $ifinfo) { + $ppp = array(); + // For pppoe conversion + if ($ifinfo['ipaddr'] == "pppoe" || $ifinfo['ipaddr'] == "pptp"){ + if (isset($ifinfo['ptpid'])) + continue; + $ppp['ptpid'] = uniqid('', true); + $ppp['type'] = $ifinfo['ipaddr']; + $ppp['ports'] = $ifinfo['if']; + if ($ifinfo['ipaddr'] == "pppoe"){ + $ppp['username'] = $ifinfo['pppoe_username']; + $ppp['password'] = base64_encode($ifinfo['pppoe_password']); + } + if ($ifinfo['ipaddr'] == "pptp"){ + $ppp['username'] = $ifinfo['pptp_username']; + $ppp['password'] = base64_encode($ifinfo['pptp_password']); + } + + if (isset($ifinfo['provider'])) + $ppp['provider'] = $ifinfo['provider']; + if (isset($ifinfo['ondemand'])) + $ppp['ondemand'] = true; + if (isset($ifinfo['timeout'])) + $ppp['idletimeout'] = $ifinfo['timeout']; + if (isset($ifinfo['pppoe']['pppoe-reset-type'])){ + $ppp['pppoe-reset-type'] = $ifinfo['pppoe']['pppoe-reset-type']; + if (is_array($config['cron']['item'])) { + for ($i = 0; $i < count($config['cron']['item']); $i++) { + $item = $config['cron']['item'][$i]; + if (strpos($item['command'], "/conf/pppoe{$ifname}restart") !== false) + $config['cron']['item'][$i]['command'] = "/var/etc/pppoe_restart_" . $ppp['ptpid']; + } + } + } + if (isset($ifinfo['local'])) + $ppp['localip'] = $ifinfo['local']; + if (isset($ifinfo['subnet'])) + $ppp['subnet'] = $ifinfo['subnet']; + if (isset($ifinfo['remote'])) + $ppp['gateway'] = $ifinfo['remote']; + + $ifcfg[$ifname]['ptpid'] = $ppp['ptpid']; + if ($ifname == "wan") + $ifcfg[$ifname]['if'] = $ifinfo['ipaddr'] ."0"; + else + $ifcfg[$ifname]['if'] = $ifinfo['ipaddr'] . substr($ifname,3); + unset($ifcfg[$ifname]['pppoe_username']); + unset($ifcfg[$ifname]['pppoe_password']); + unset($ifcfg[$ifname]['provider']); + unset($ifcfg[$ifname]['ondemand']); + unset($ifcfg[$ifname]['timeout']); + unset($ifcfg[$ifname]['pppoe_reset']); + unset($ifcfg[$ifname]['pppoe_preset']); + unset($ifcfg[$ifname]['pppoe']); + unset($ifcfg[$ifname]['pptp_username']); + unset($ifcfg[$ifname]['pptp_password']); + unset($ifcfg[$ifname]['local']); + unset($ifcfg[$ifname]['subnet']); + unset($ifcfg[$ifname]['remote']); + + $a_ppps[] = $ppp; + + } + } +} + ?> diff --git a/etc/phpshellsessions/gitsync b/etc/phpshellsessions/gitsync index ec7031f..cff0b04 100644 --- a/etc/phpshellsessions/gitsync +++ b/etc/phpshellsessions/gitsync @@ -8,6 +8,7 @@ require_once("globals.inc"); require_once("filter.inc"); require_once("shaper.inc"); require_once("rrd.inc"); +require_once("pfsense-utils.inc"); conf_mount_rw(); diff --git a/etc/rc.bootup b/etc/rc.bootup index 858ea2e..2f977f3 100755 --- a/etc/rc.bootup +++ b/etc/rc.bootup @@ -119,6 +119,8 @@ require_once("/etc/inc/captiveportal.inc"); echo "."; require_once("/etc/inc/rrd.inc"); echo "."; +require_once("/etc/inc/pfsense-utils.inc"); +echo "."; /* get system memory amount */ $memory = get_memory(); |