freeradius 如何调用module 处理auth

例子

复制代码
static rlm_rcode_t _test_sql_authenticate(UNUSED rlm_eap_t *inst, REQUEST *request)
{
    REQUEST *fake;
    VALUE_PAIR *vp1, *vp2;
    int rc = RLM_MODULE_FAIL;
    int idx;
    DICT_VALUE *dval;

    fake = request_alloc_fake(request);
    rad_assert(!fake->packet->vps);

    fake->packet->vps = fr_pair_list_copy(fake->packet, request->packet->vps);

    /* set the virtual server to use */
    if ((vp1 = fr_pair_find_by_num(request->config, PW_VIRTUAL_SERVER, 0, TAG_ANY)) != NULL) {
        fake->server = vp1->vp_strvalue;
    } else {
        fake->server = "check-by-controller";
    }

    /* set auth result */
    vp2 = fr_pair_find_by_num(fake->packet->vps, PW_FREERADIUS_STATS_ERROR, VENDORPEC_FREERADIUS, TAG_ANY);
    if (!vp2) {
        vp2 = fr_pair_afrom_num(fake->packet, PW_FREERADIUS_STATS_ERROR, VENDORPEC_FREERADIUS);
    }

    if (rc == RLM_MODULE_OK) {
        fr_pair_value_strcpy(vp2, "accept");
    } else {
        fr_pair_value_strcpy(vp2, "reject");
    }
    fr_pair_add(&fake->packet->vps, vp2);

    RDEBUG2("process eap_peap  authenticate at virtual server %s", fake->server);

    dval = dict_valbyname(PW_AUTH_TYPE, 0, "sql");
    idx = dval->value;
    rc = process_authenticate(idx, fake);

    /* copy the reply vps back to our reply */
    fr_pair_list_mcopy_by_num(request->reply, &request->reply->vps,
        &fake->reply->vps, 0, 0, TAG_ANY);

    talloc_free(fake);
    return rc;
}
复制代码

 

posted @   codestacklinuxer  阅读(6)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
历史上的今天:
2022-08-16 DPVS简介 转载
2020-08-16 http 怎样关闭
2020-08-16 http 响应 ngx_http_send_header ngx_http_output_filter
2020-08-16 http 请求体数据处理2--ngx
2020-08-16 http 请求体数据--ngx
点击右上角即可分享
微信分享提示