2016-09-09 - Re: Power Off and User Re-Login

Header Data

From: Eliot Ness <sc***7@googlemail.com>
Message Hash: f54f3cb2e772993475495a2952a317519160b674bf6fbac6db114ffa56e04bda
Message ID: <8a5dc0cf-a32a-4c4f-8df8-9ceadbc21922@grasehotspot.org>
Reply To: <a892365d-ce49-4a1f-b689-ab8f1520bdad@grasehotspot.org>
UTC Datetime: 2016-09-09 06:11:38 UTC
Raw Date: Fri, 09 Sep 2016 06:11:38 -0700

Raw message

Let's have a detailed review :

<?php
 
 # GET ALL DEVICES CONNECTED TO HOTSPOT WITHOUT LOGIN
 $result = str_replace("\n", "|", trim(shell_exec("sudo chilli_query list | 
grep 'dnat' | awk '{print $1}'")));
 $macs_connected = explode("|",$result);
 echo "<h1>Connected devices without login</h1>";
 echo "<pre>";
 print_r($macs_connected);
 echo "</pre>";
 
 # GET ALL UNCLOSED SESSIONS FROM DATABASE THAT MATCH THE CURRENTLY 
CONNECTED DEVICES WITHOUT LOGIN
 $link = mysqli_connect("127.0.0.1", "root", "password", "radius");
 $query = "SELECT CallingStationId, UserName, FramedIpAddress, AcctStopTime 
FROM radius.radacct WHERE UserName != 'CoovaChilli' and AcctStopTime is 
null and CallingStationId in ('".implode("','",$macs_connected)."') Group 
BY CallingStationId ORDER by RadAcctId DESC";
 if ($result = $link->query($query))
 {
    $loggedin = array();
    while ($device= $result->fetch_assoc()) {
        shell_exec("sudo chilli_query authorize mac 
".$device['CallingStationId']." username ".$device['UserName']);
        $loggedin[]=$row['CallingStationId'];
    }
    $result->free();
    echo "<h1>Devices we auto-logged in</h1>";
    var_dump($loggedin);
 }
 mysqli_close($link);
?>

The above script seems that running ok.
I cant run with wget, but i test it on var/www/html and call it via web 
browser.

So if i call it on http://grase-ip/reconnect.php  results are ( where xx is 
the device mac address )

Connected devices without login

Array
(
    [0] => xx-xx-xx-xx-xx-xx  
)

Devices we auto-logged in
array(0) { } 

So on reboot it does not reconnect any device and result is
Devices we auto-logged in
array(0) { } 

This script need an extra param to re-auth users....but i dont know what.
Any php expert can help?

On Thursday, June 2, 2016 at 9:40:51 AM UTC+3, Eliot Ness wrote:
>
> At least one Pi2 comes yesterday in my hands, and ....grase run again.
> Detailed tutorial steps install on next days.
>
> As simple question : On power off or reboot, user have login again, except 
> if admin store mac adr.
>
> Is there any way on grase to remember users after reboot ? So no need user 
> to login again....
>
> Anyone?
>

Thread