Accessing %{client:...} in C custom module

Boris Lytochkin lytboris at yandex-team.ru
Wed Mar 2 14:53:40 CET 2016


Hi.

Thanks. That was it.

Correct code snippet (no checks though):
         CONF_PAIR *mycp;
         mycp = cf_pair_find(request->client->cs, "group");
         p = cf_pair_value(mycp);

This works fine even with garbage-like cs pointer:
(gdb) p *request->client->cs
$3 = {item = {next = 0xa00000038, parent = 0x803496330, lineno = 805314604,
     filename = 0x800300034 <Error reading address 0x800300034: Bad address>, type = 1919181921}, name1 = 0x0,
   name2 = 0xb0000003b <Error reading address 0xb0000003b: Bad address>, name2_type = 172, children = 0x1300000049, tail = 0x135,
   template = 0xb0000000b, pair_tree = 0x2aa30, section_tree = 0x100000012, name2_tree = 0x2aad0, data_tree = 0x600000040, base = 0x64f0,
   depth = 1, variables = 0x416}
(gdb) p p
$4 = 0x802e58ee0 "8021X"


On 02.03.2016 14:35, Matthew Newton wrote:
> On Wed, Mar 02, 2016 at 02:19:31PM +0300, Boris Lytochkin wrote:
>> On 02.03.2016 13:08, Stefan Paetow wrote:
>>> Try this:
>>>
>>> if ("%{client:group}" == '8021X') {
>> That works, thanks :) Will go track how this is being expanded now.
> It's an xlat, so look for the xlat_register function for it.
>
> ~/git/freeradius-server/src/main$ grep xlat * | grep client
> mainconfig.c:static ssize_t xlat_client(UNUSED void *instance, REQUEST *request, char const *fmt, char *out, size_t outlen)
> mainconfig.c:static ssize_t xlat_getclient(UNUSED void *instance, REQUEST *request, char const *fmt, char *out, size_t outlen)
> mainconfig.c: xlat_register("client", xlat_client, NULL, NULL);
> <<<
> mainconfig.c: xlat_register("getclient", xlat_getclient, NULL, NULL);
> radclient.c:       *  xlat expansions aren't supported here
> radclient.c:          vp->vp_strvalue = vp->value.xlat;
> radclient.c:       *  Double quoted strings get marked up as xlat expansions,
> radclient.c:        vp->vp_strvalue = vp->value.xlat;
>
> look at the xlat_client function in mainconfig.c
>
> Matthew
>
>

-- 
Boris Lytochkin
Yandex NOC
+7 (495) 739 70 00 ext. 7671



More information about the Freeradius-Devel mailing list