[OpenSIPS-Users] bug in the RadiusDictionaryFile fonction

Dan Pascu dan at ag-projects.com
Tue Oct 14 00:29:38 CEST 2008


The original version loads the included files in-place which is how it 
should be done. Your modified version wants to append them one after the 
other, which is not correct. Yet, the implementation fails to do even 
that, as it will stop after reading the first line which is not an 
include statement (considering the broken logic to increment i).

So I fail to see what you wish to accomplish with this code as it replaces 
a perfectly functional piece of code with one that is broken in both the 
semantics and the implementation, without giving a single hint of what is 
wrong with the original version.

On Tuesday 07 October 2008, Geoffroy Rabouin wrote:
> Hi,
> There is a bug when a $INCLUDE is use in the dict file of the
> radiusclient-ng.
> If I concatenate all my dict in one bigger, all is ok.
> I try to make a fonction who handle the $INCLUDE :
> class RadiusDictionaryFile(object):
>     def __init__(self, base_file_name):
>         self.file_names = [base_file_name]
>         log.warn(base_file_name)
>         self.fd_stack = [open(base_file_name)]
>
>     def readlines(self):
>         i=-1
>         while i<len(self.fd_stack)-1:
>             line = self.fd_stack[i].readline()
>             if line:
>                 if line.startswith("$INCLUDE"):
>                     file_name = line.rstrip("\n").split(None, 1)[1]
>                     if file_name not in self.file_names:
>                         self.file_names.append(file_name)
>                         self.fd_stack.append(open(file_name))
>                     continue
>                 else:
>                     yield line
>             else:
>                 self.fd_stack.pop()
>                 if len(self.fd_stack) == 0:
>                     return
>             i=i+1
>
>
> Let me know if this is correct for you.
> Have a nice day.
>
> --
> Geoffroy Rabouin
> HighColoc
> 13710 La Barque
> FRANCE
> téléphone : +33 6-27-19-13-07



-- 
Dan



More information about the Users mailing list