Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pfBlockerNG v2.1.2_1 #470

Merged
merged 6 commits into from
Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions net/pfSense-pkg-pfBlockerNG/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

PORTNAME= pfSense-pkg-pfBlockerNG
PORTVERSION= 2.1.2
PORTREVISION= 1
CATEGORIES= net
MASTER_SITES= # empty
DISTFILES= # empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2341,7 +2341,6 @@ function pfb_aliastables($mode) {

// Only execute function if platform is NanoBSD or Ramdisks are used.
if (($g['platform'] != 'pfSense') || isset($config['system']['use_mfs_tmpvar'])) {
conf_mount_rw();
if ($mode == 'update') {
// Archive aliastable folder
pfb_logger("\n\nArchiving Aliastable folder\n", 1);
Expand Down Expand Up @@ -2380,14 +2379,11 @@ function pfb_aliastables($mode) {
$msg = "\n** Adding earlyshellcmd **\n";
}
}
conf_mount_ro();
}
else {
if (file_exists("{$pfb['aliasarchive']}")) {
// Remove aliastables archive if found.
conf_mount_rw();
@unlink_if_exists("{$pfb['aliasarchive']}");
conf_mount_ro();
}
// Remove earlyshellcmd if found.
if (isset($config['system']['earlyshellcmd'])) {
Expand Down Expand Up @@ -2505,9 +2501,11 @@ function pfb_livetail($logfile, $mode) {
$pfb_found = FALSE;

if (($handle = @fopen("{$pfb['dnsbl_info']}", 'r')) !== FALSE) {
if (@flock($handle, LOCK_EX)) {
$lock_handle = @try_lock($handle, 5);
if ($lock_handle) {
if (($pfb_output = @fopen("{$pfb['dnsbl_info']}.bk", 'w')) !== FALSE) {
if (@flock($pfb_output, LOCK_EX)) {
$lock_pfb_output = @try_lock($pfb_output, 5);
if ($lock_pfb_output) {
$pfb_found = TRUE;

// Find line with corresponding DNSBL Aliasname
Expand All @@ -2517,12 +2515,14 @@ function pfb_livetail($logfile, $mode) {
}
@fputcsv($pfb_output, $line);
}
@flock($pfb_output, LOCK_UN);
@unlock($lock_pfb_output);
}
@unlock_force($pfb_output);
@fclose($pfb_output);
}
@flock($handle, LOCK_UN);
@unlock($lock_handle);
}
@unlock_force($handle);
@fclose($handle);

if ($pfb_found) {
Expand Down Expand Up @@ -5093,10 +5093,14 @@ function sync_package_pfblockerng($cron='') {
pfb_logger("{$log}", 1);

$tablesin = $tablesout = array();
// Collect all 'pfB_' Rules that are 'Block/Reject' and do not have bypass states enabled
// Collect all 'pfB_' and 'pfb_' rules that are 'Block/Reject' and do not have bypass states enabled
if (isset($config['aliases']['alias'])) {
foreach ($config['aliases']['alias'] as $alias) {
if ($alias['type'] == 'urltable' && strpos($alias['name'], 'pfB_') !== FALSE && strpos($alias['descr'], '[s]') === FALSE) {

if ($alias['type'] == 'urltable' &&
(strpos($alias['name'], 'pfB_') !== FALSE || strpos($alias['name'], 'pfb_') !== FALSE) &&
strpos($alias['descr'], '[s]') === FALSE) {

if (isset($config['filter']['rule'])) {
foreach ($config['filter']['rule'] as $rule) {
if ($alias['name'] === $rule['source']['address'] || $alias['name'] === $rule['destination']['address']) {
Expand Down Expand Up @@ -5740,4 +5744,4 @@ function pfblockerng_do_xmlrpc_sync($sync_to_ip, $port, $protocol, $username, $p
}
}
}
?>
?>
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ USE_MFS_TMPVAR="$(/usr/bin/grep -c use_mfs_tmpvar /cf/conf/config.xml)"
DISK_NAME="$(/bin/df /var/db/rrd | /usr/bin/tail -1 | /usr/bin/awk '{print $1;}')"
DISK_TYPE="$(/usr/bin/basename ${DISK_NAME} | /usr/bin/cut -c1-2)"

if [ "${PLATFORM}" != 'pfSense' ] || [ ${USE_MFS_TMPVAR} -gt 0 ] || [ "${DISK_TYPE}" = 'md' ]; then
/etc/rc.conf_mount_rw > /dev/null 2>&1
fi

if [ ! -d "${pfbdb}" ]; then mkdir "${pfbdb}"; fi
if [ ! -d "${pfsensealias}" ]; then mkdir "${pfsensealias}"; fi
if [ ! -d "${pfbmatch}" ]; then mkdir "${pfbmatch}"; fi
Expand All @@ -99,13 +95,8 @@ if [ ! -f "${masterfile}" ]; then touch "${masterfile}"; fi
if [ ! -f "${mastercat}" ]; then touch "${mastercat}"; fi


# Exit function to set mount RO if required before exiting.
# Remove temp files before exiting.
exitnow() {
if [ "${PLATFORM}" != 'pfSense' ] || [ ${USE_MFS_TMPVAR} -gt 0 ] || [ "${DISK_TYPE}" = 'md' ]; then
/etc/rc.conf_mount_ro > /dev/null 2>&1
fi

# Remove temp files
rm -f /tmp/pfbtemp?_"${rvar}"
exit
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
* limitations under the License.
*/

require_once('util.inc');

header("Cache-Control: private, no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
Expand Down Expand Up @@ -70,9 +72,11 @@

$dnsbl_info = '/var/db/pfblockerng/dnsbl_info';
if (($handle = @fopen("{$dnsbl_info}", 'r')) !== FALSE) {
if (@flock($handle, LOCK_EX)) {
$lock_handle = @try_lock($handle, 5);
if ($lock_handle) {
if (($pfb_output = @fopen("{$dnsbl_info}.bk", 'w')) !== FALSE) {
if (@flock($pfb_output, LOCK_EX)) {
$lock_pfb_output = @try_lock($pfb_output, 5);
if ($lock_pfb_output) {
$pfb_found = TRUE;

// Find line with corresponding DNSBL Aliasname
Expand All @@ -82,17 +86,19 @@
}
@fputcsv($pfb_output, $line);
}
@flock($pfb_output, LOCK_UN);
@unlock($lock_pfb_output);
}
@unlock_force($pfb_output);
@fclose($pfb_output);
}
@flock($handle, LOCK_UN);
@unlock($lock_handle);
}
@unlock_force($handle);
@fclose($handle);
}

if ($pfb_found) {
@rename("{$dnsbl_info}.bk", "{$dnsbl_info}");
}
}
?>
?>