Actions
Bug #3538
closedCaptivePortal passthrumac delete captiveportal_get_ipfw_passthru_ruleno and captiveportal_get_dn_passthru_ruleno functions
Start date:
03/20/2014
Due date:
% Done:
100%
Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
2.1
Affected Architecture:
amd64
Description
In captive portal i successfully added passthrumac. But when i want to delete mac it can't delete ipfw pipe and rule. It only delete xml passthrumac entry.
in the body of rule number functions cut -d values is wrong. the valid code be like below. (sorry for bad english. i hope someone understand issue).
function captiveportal_get_dn_passthru_ruleno($value) { . . . $_gb = exec("/sbin/ipfw -x {$cpzone} show | /usr/bin/grep {$value} | /usr/bin/grep -v grep | /usr/bin/cut -d \" \" -f 5 | /usr/bin/head -n 1", $output);
must be
function captiveportal_get_dn_passthru_ruleno($value) { . . . $_gb = exec("/sbin/ipfw -x {$cpzone} show | /usr/bin/grep {$value} | /usr/bin/grep -v grep | /usr/bin/cut -d \" \" -f 20 | /usr/bin/head -n 1", $output);
and
function captiveportal_get_ipfw_passthru_ruleno($value) { . . . $_gb = exec("/sbin/ipfw -x {$cpzone} show | /usr/bin/grep {$value} | /usr/bin/grep -v grep | /usr/bin/cut -d \" \" -f 5 | /usr/bin/head -n 1", $output);
must be
function captiveportal_get_ipfw_passthru_ruleno($value) { . . . $_gb = exec("/sbin/ipfw -x {$cpzone} show | /usr/bin/grep {$value} | /usr/bin/grep -v grep | /usr/bin/cut -d \" \" -f 1 | /usr/bin/head -n 1", $output);
Updated by Sabri Arslan almost 11 years ago
cut -d \" \" -f 20 not true still searching
Updated by Sabri Arslan almost 11 years ago
Finally fully working code is below
function captiveportal_get_ipfw_passthru_ruleno($value) { global $config, $g, $cpzone; $cpcfg = $config['captiveportal'][$cpzone]; if(!isset($cpcfg['enable'])) return NULL; $cpruleslck = lock("captiveportalrules{$cpzone}", LOCK_EX); $ruleno = NULL; if (file_exists("{$g['vardb_path']}/captiveportal_{$cpzone}.rules")) { $rules = unserialize(file_get_contents("{$g['vardb_path']}/captiveportal_{$cpzone}.rules")); unset($output); $_gb = exec("/sbin/ipfw -x {$cpzone} show | /usr/bin/grep {$value} | /usr/bin/grep -v grep | /usr/bin/head -n 1", $output); if(is_array($output)&&count($output)>0) { $t=split(" ",$output[0]); if(is_array($t)&&count($t)>0) { $ruleno = intval($t[0]); } } $ruleno = intval($output[0]); if (!$rules[$ruleno]) $ruleno = NULL; } unlock($cpruleslck); unset($rules); return $ruleno; }
function captiveportal_get_dn_passthru_ruleno($value) { global $config, $g, $cpzone; $cpcfg = $config['captiveportal'][$cpzone]; if(!isset($cpcfg['enable'])) return NULL; $cpruleslck = lock("captiveportalrulesdn", LOCK_EX); $ruleno = NULL; if (file_exists("{$g['vardb_path']}/captiveportaldn.rules")) { $rules = unserialize(file_get_contents("{$g['vardb_path']}/captiveportaldn.rules")); unset($output); $_gb = exec("/sbin/ipfw -x {$cpzone} show | /usr/bin/grep {$value} | /usr/bin/grep -v grep | /usr/bin/head -n 1", $output); if(is_array($output)&&count($output)>0) { $t=split("pipe",$output[0]); if(is_array($t)&&count($t)>0) { $r=split("ip",$t[1]); if(is_array($r)&&count($r)>0) { $ruleno = intval($r[0]); } } } if (!$rules[$ruleno]) $ruleno = NULL; unset($rules); } unlock($cpruleslck); return $ruleno; }
Updated by Phillip Davis almost 11 years ago
It will be much easier to quickly review your change if you edit on GitHub and submit a pull request: https://github.com/pfsense/pfsense
Updated by Renato Botelho over 10 years ago
- Status changed from New to Feedback
- % Done changed from 0 to 100
Applied in changeset c4fb986b27a6b6e81d7605ae48eda169a7d680cf.
Updated by Renato Botelho over 10 years ago
Applied in changeset dae77fe374ebaf1f97d2835ef0f52daff3b26be9.
Updated by Renato Botelho over 10 years ago
- Status changed from Feedback to Resolved
Actions