rlm_rediswho with spaces

Phil Mayers p.mayers at imperial.ac.uk
Thu Oct 25 18:41:01 CEST 2012


On 25/10/12 15:10, Brian Candler wrote:

> * Parse the string, if it contains quoted words then break into

Why not do it for everything? Why just quoted?

>    %s substitutions before passing to redisCommand. This would be the
>    most transparent solution I think.

You can probably use the escape context stuff for this.

Basically:

  1. Define a struct for holding the command and arguments

struct redis_command {
   char *arg[LEN];
   int argnum;
}

  2. Modify the redis_escape function to save to the context:

int resdis_escape(REQUEST *in, char *out, size_t outlen,
                   const char *in, void *arg) {

   struct redis_command *c = arg;
   c->arg[c->argnum++] = strdup(in);
   *out++ = '%';
   *out++ = 's';
   *out++ = '\0';
   return 2;
}

  3. In the command func, just call radius_xlat on the command string 
with a zero-ed struct:

   char query[256];
   struct redis_command c;

   c.argnum = 0;
   radius_xlat(query, sizeof(query), fmt, request, redis_escape, &c);

...the escape func will collect all your arguments and substitute "%s". 
You then just need to collate the "arg" into a va_thingy struct and call 
the va_thingy variant of the function.


More information about the Freeradius-Devel mailing list