Welcome, Guest. Please login or register.

Author Topic: Bug in RADIUS authentication with IPv6  (Read 1123 times)

kmall

  • Guest
Bug in RADIUS authentication with IPv6
« on: June 28, 2015, 10:08:54 AM »
Hi,

if you connect with IPv6 to your nedi server, $_SERVER['SERVER_ADDR'] is the IPv6 address of the server. That makes the function radius_put_addr  in index.php fail at line 87 because it expects an IPv4 address.

Klara

gerold

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Bug in RADIUS authentication with IPv6
« Reply #1 on: September 27, 2017, 11:04:53 AM »
Hi,

on nedi-1.7.090, the following patch works for me:

Code: [Select]
diff -u -r1.2 index.php
--- index.php   2017/07/31 09:07:18     1.2
+++ index.php   2017/09/26 14:27:54
@@ -69,6 +69,7 @@
                }
        }elseif( strstr($guiauth,'radius') && $user != "admin" ){                                       # Based on Radius code by Till Elsner
                $radres = radius_auth_open();
+               $server_is_v4 = preg_match('/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/', $_SERVER['SERVER_ADDR']);
                echo $radres;
                if (!$radres) {
                        echo "Error while preparing RADIUS authentication: ".radius_strerror($radres);
@@ -84,7 +85,8 @@
                if (!(  radius_put_string($radres, RADIUS_USER_NAME, $user)
                        && radius_put_string($radres, RADIUS_USER_PASSWORD, $_POST['pass'])
                        && radius_put_string($radres, RADIUS_CALLING_STATION_ID, $_SERVER['REMOTE_ADDR'])# dstrezov's suggestion for ACS compliance
-                       && radius_put_addr($radres, RADIUS_NAS_IP_ADDRESS, $_SERVER['SERVER_ADDR']) )){
+                       && ( $server_is_v4 ? radius_put_addr($radres, RADIUS_NAS_IP_ADDRESS, $_SERVER['SERVER_ADDR']) : radius_put_string($radres, RADIUS_NAS_IPV6_ADDRESS, $_SERVER['SERVER_ADDR']))
+               )){
                        echo "RADIUS put: ".radius_strerror($radres);
                }
                $radauth = radius_send_request($radres);

Hope this helps!

Gerold

rickli

  • Administrator
  • Hero Member
  • *****
  • Posts: 2558
    • View Profile
    • NeDi
Re: Bug in RADIUS authentication with IPv6
« Reply #2 on: September 29, 2017, 12:54:40 PM »
Cool, thanks for your fix! I'll include it in the next release...
Please consider Other-Invoices on your NeDi installation for an annual contribution, tx!
-Remo