https://redmine.pfsense.org/https://redmine.pfsense.org/favicon.ico?16780521162015-04-24T04:21:36ZpfSense bugtrackerpfSense - Bug #4652: Captive Portal Idle-Timeout causes 2147483647 for acctsessiontime when no data transferredhttps://redmine.pfsense.org/issues/4652?journal_id=182682015-04-24T04:21:36ZMarkus Tellianmarkus.tellian@outlook.com
<ul></ul><p>If you log in to captive portal and a Idle-Timeout is set (in my setup from radius)<br />the function captiveportal_get_last_activity() in captiveportal.inc returns a random unix date if the client did not consumed any data.<br />This value in $lastact causes an error in a date calculation.</p>
<p>The solution is to check if the client consumed data yet. If we return 0 the time is set correctly in the past code.<br />I wrote a simple bugfix:</p>
<p>//file: /etc/inc/captiveportal.inc<br /><pre>
// get last activity timestamp given client IP address
function captiveportal_get_last_activity($ip, $mac = NULL, $table = 2) {
global $cpzoneid;
$ipfw_tbl1 = pfSense_ipfw_getTablestats($cpzoneid, IP_FW_TABLE_XLISTENTRY, 1, $ip, $mac); //get data from table1 download
$ipfw_tbl2 = pfSense_ipfw_getTablestats($cpzoneid, IP_FW_TABLE_XLISTENTRY, 2, $ip, $mac); //get data from table1 upload
//BUGFIX
if (is_array($ipfw_tbl1)) {
if ($ipfw_tbl1['packets'] > 0) { //if packets sent, timestamp is correct
return $ipfwoutput['timestamp'];
}
else { //if no packets sent, return 0 to avoid fals time by bugfunction pfSense_ipfw_getTablestats
openlog("logportalauth", LOG_PID, LOG_LOCAL4);
syslog(LOG_INFO, "BUG AVOIDED table1");
closelog();
return 0;
}
}
if (is_array($ipfw_tbl2)) {
if ($ipfw_tbl2['packets'] > 0) { //if packets sent, timestamp is correct
return $ipfwoutput['timestamp'];
}
else { //if no packets sent, return 0 to avoid fals time by bugfunction pfSense_ipfw_getTablestats
openlog("logportalauth", LOG_PID, LOG_LOCAL4);
syslog(LOG_INFO, "BUG AVOIDED table2");
closelog();
return 0;
}
}
return 0;
}
</pre></p> pfSense - Bug #4652: Captive Portal Idle-Timeout causes 2147483647 for acctsessiontime when no data transferredhttps://redmine.pfsense.org/issues/4652?journal_id=182692015-04-24T04:44:33ZMarkus Tellianmarkus.tellian@outlook.com
<ul></ul><p>Accidentally I posted the code from my dev PfSense, here is the working code:</p>
<pre>
/* get last activity timestamp given client IP address */
function captiveportal_get_last_activity($ip, $mac = NULL, $table = 2) {
global $cpzoneid;
$ipfw_tbl1 = pfSense_ipfw_getTablestats($cpzoneid, IP_FW_TABLE_XLISTENTRY, 1, $ip, $mac); //get data from table1 download
$ipfw_tbl2 = pfSense_ipfw_getTablestats($cpzoneid, IP_FW_TABLE_XLISTENTRY, 2, $ip, $mac); //get data from table1 upload
//BUGFIX
if (is_array($ipfw_tbl1)) {
if ($ipfw_tbl1['packets'] > 0) { //if packets sent, timestamp is correct
return $ipfw_tbl1['timestamp'];
}
else { //if no packets sent, return 0 to avoid fals time by bugfunction pfSense_ipfw_getTablestats
return 0;
}
}
if (is_array($ipfw_tbl2)) {
if ($ipfw_tbl2['packets'] > 0) { //if packets sent, timestamp is correct
return $ipfw_tbl2['timestamp'];
}
else { //if no packets sent, return 0 to avoid fals time by bugfunction pfSense_ipfw_getTablestats
return 0;
}
}
return 0;
}
</pre> pfSense - Bug #4652: Captive Portal Idle-Timeout causes 2147483647 for acctsessiontime when no data transferredhttps://redmine.pfsense.org/issues/4652?journal_id=183162015-05-01T13:58:43ZErmal Luçieri@pfsense.org
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Feedback</i></li></ul><p>Committed.</p> pfSense - Bug #4652: Captive Portal Idle-Timeout causes 2147483647 for acctsessiontime when no data transferredhttps://redmine.pfsense.org/issues/4652?journal_id=183182015-05-01T14:10:10ZErmal Luçieri@pfsense.org
<ul><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>Applied in changeset <a class="changeset" title="Fixes #4652 put workaround for bogus timestamp until real data are cosnumed." href="https://redmine.pfsense.org/projects/pfsense/repository/2/revisions/2842c8d407e34a9183908a1677ec162a7b0ea209">2842c8d407e34a9183908a1677ec162a7b0ea209</a>.</p> pfSense - Bug #4652: Captive Portal Idle-Timeout causes 2147483647 for acctsessiontime when no data transferredhttps://redmine.pfsense.org/issues/4652?journal_id=183192015-05-01T14:10:10ZErmal Luçieri@pfsense.org
<ul></ul><p>Applied in changeset <a class="changeset" title="Fixes #4652 put workaround for bogus timestamp until real data are cosnumed." href="https://redmine.pfsense.org/projects/pfsense/repository/2/revisions/120acbae8c2edd2e60685dd7ca16966cd988afc7">120acbae8c2edd2e60685dd7ca16966cd988afc7</a>.</p> pfSense - Bug #4652: Captive Portal Idle-Timeout causes 2147483647 for acctsessiontime when no data transferredhttps://redmine.pfsense.org/issues/4652?journal_id=183422015-05-05T07:01:05ZMarkus Tellianmarkus.tellian@outlook.com
<ul></ul><p>The change applied in <a href="https://redmine.pfsense.org/projects/pfsense/repository/revisions/120acbae8c2edd2e60685dd7ca16966cd988afc7" class="external">120acbae8c2edd2e60685dd7ca16966cd988afc7</a><br />only reads the output table for bytes.<br />I have not tested it yet and download without upload should probably never happen in a normal use scenario but it will still cause the related error.</p> pfSense - Bug #4652: Captive Portal Idle-Timeout causes 2147483647 for acctsessiontime when no data transferredhttps://redmine.pfsense.org/issues/4652?journal_id=183432015-05-05T07:04:18ZMarkus Tellianmarkus.tellian@outlook.com
<ul></ul><p>Markus Tellian wrote:</p>
<blockquote>
<p>The change applied in <a href="https://redmine.pfsense.org/projects/pfsense/repository/revisions/120acbae8c2edd2e60685dd7ca16966cd988afc7" class="external">120acbae8c2edd2e60685dd7ca16966cd988afc7</a><br />only reads the output table for bytes.<br />I have not tested it yet and download without upload should probably never happen in a normal use scenario but then it will still cause the related error.</p>
</blockquote> pfSense - Bug #4652: Captive Portal Idle-Timeout causes 2147483647 for acctsessiontime when no data transferredhttps://redmine.pfsense.org/issues/4652?journal_id=189252015-06-21T22:13:27ZChris Buechlercbuechler@gmail.com
<ul><li><strong>Subject</strong> changed from <i>Captive Portal Idle-Timeout causes 2147483647 for acctsessiontime</i> to <i>Captive Portal Idle-Timeout causes 2147483647 for acctsessiontime when no data transferred</i></li><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Resolved</i></li><li><strong>Affected Version</strong> changed from <i>2.2.1</i> to <i>2.2.x</i></li><li><strong>Affected Architecture</strong> <i></i> added</li><li><strong>Affected Architecture</strong> deleted (<del><i>amd64</i></del>)</li></ul><p>works from what I can tell. Markus, if you can see any remaining issues here in 2.2.3, please follow up.</p>