freeradius增加Access-Challeng支持

freeradius默认的逻辑不支持Access-Challeng,只在特定auth-type中Access-Challeng,在auth.c中 只对request->proxy_reply包进行处理,所以你在普通逻辑中如果想返回Access-Challeng必须增加逻辑:

jradius中:

                              RadiusPacket reply = new AccessChallenge();
                                reply.setIdentifier(rep.getIdentifier());
                                reply.addAttribute(new Attr_Prompt(Attr_Prompt.NoEcho));
                                reply.addAttribute(new Attr_ReplyMessage("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"));
                                reply.addAttribute(new Attr_State("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"));
                                jRequest.setReplyPacket(reply);

                               //这里为了防止freeradius中增加逻辑的负作用(防止其它逻辑走进来),可以加其它不常用的Attribute作为条件
                                jRequest.setReturnValue(JRadiusServer.RLM_MODULE_OK);
                                return false;

auth.c中:

int rad_authenticate(REQUEST *request) 函数开始增加几个判断:

        VALUE_PAIR *state;
        VALUE_PAIR *prompt;

       VALUE_PAIR *上面定义的一个不常用的attribute;

        state =  pairfind(request->reply->vps, PW_STATE);
        prompt = pairfind(request->reply->vps, PW_PROMPT);

       不常用的attribute = pairfind(request->reply->vps, PW_不常用的attribute);

       if(state && prompt && 不常用的attribute){

            //这里可remove掉那个不常用的attribute

                request->reply->code = PW_ACCESS_CHALLENGE;
                RDEBUG("Change reply code to Access-Challenge.");
                return RLM_MODULE_OK;

       }


OK,重新编译可以正常返回Access-Challenge了。

freeradius增加Access-Challeng支持

上一篇:NHibernate3快速上手教程FluentNHibernate配置与DBHelper


下一篇:opensuse 安装oracle 界面乱码