Multiple output pairs in rlm_exec - How to format the response pai string?

Hanno Schupp hanno.schupp at gmail.com
Tue Jan 13 01:54:09 CET 2009


I try to determine some data externally through an PHP programme with the
'exec' module.

 

Everything is fine as long as I do only return one value from PHP, the
return attribute is duly accepted and processed. 

 

As soon as I return more than one the exec module gets confused, as
everything is returned in one long string (see debug output). There is no
documentation in the echo or exec module as far as I can see, so I tried
spaces, \r\n, and commas ',' as delimiters. Nothing worked.

 

Is this a limitation of the exec module, that it only accepts one reply
value back? The name of the parameter 'output_pairs' seems to suggest
otherwise.

 

Can anyone advise on the proper delimitation of multiple return values?

 

 

BTW, thanks everyone for all their help so far.

 

 

 

Debug output:

...

Tue Jan 13 13:38:40 2009 : Debug:       expand: %{User-Name} -> yubvef24

Tue Jan 13 13:38:40 2009 : Debug: Exec-Program output:
WISPr-Bandwidth-Max-Down := 256000   Reply-Message := "Connection speed has
been reduced"  WISPr-Bandwidth-Max-Up := 32000   Reply-Message :=
"Connection speed has been reduced"

Tue Jan 13 13:38:40 2009 : Debug: Exec-Program-Wait: plaintext:
WISPr-Bandwidth-Max-Down := 256000   Reply-Message := "Connection speed has
been reduced"  WISPr-Bandwidth-Max-Up := 32000   Reply-Message :=
"Connection speed has been reduced"

Tue Jan 13 13:38:40 2009 : Debug: Exec-Program: returned: 0

Tue Jan 13 13:38:40 2009 : Info: +++[maxspeedrestrict] returns ok

...

 

PHP code creating the response:

...

$colname_Recordset1 = "-1";

if (isset($_ENV['USER_NAME'])) {

  $colname_Recordset1 = substr($_ENV['USER_NAME'], 1,
strlen($_ENV['USER_NAME']) - 2);

}

 

$retval = 2;

 

mysql_select_db($database_chilli, $chilli);

$query_Recordset1 = sprintf("SELECT Value, op FROM radcheck WHERE UserName =
%s AND Attribute = 'Download-Speed-Restricted'",
GetSQLValueString($colname_Recordset1, "text"));

$Recordset1 = mysql_query($query_Recordset1, $chilli) or die(mysql_error);

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

$totalRows_Recordset1 = mysql_num_rows($Recordset1);

 

$query_Recordset2 = sprintf("SELECT Value, op FROM radcheck WHERE UserName =
%s AND Attribute = 'Upload-Speed-Restricted'",
GetSQLValueString($colname_Recordset1, "text"));

$Recordset2 = mysql_query($query_Recordset2, $chilli) or die(mysql_error);

$row_Recordset2 = mysql_fetch_assoc($Recordset2);

$totalRows_Recordset2 = mysql_num_rows($Recordset2);

 

if ($totalRows_Recordset1 == '1') {

                echo 'WISPr-Bandwidth-Max-Down '.$row_Recordset1['op'].'
'.$row_Recordset1['Value']." \r\n";

                echo 'Reply-Message := "Connection speed has been
reduced"'."\r\n";

                $retval = 0;

}        

 

if ($totalRows_Recordset2 == '1') {

                echo 'WISPr-Bandwidth-Max-Up '.$row_Recordset2['op'].'
'.$row_Recordset2['Value']." \r\n";

                echo 'Reply-Message := "Connection speed has been
reduced"'."\r\n";

                $retval = 0;

}

 

if ($retval == '2') {

                echo 'Reply-Message := "Time or Data allowance has been
exhausted"';

}       

 

exit ($retval);

?>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20090113/9f83acae/attachment.html>


More information about the Freeradius-Users mailing list