rlm_rediswho with spaces

Brian Candler B.Candler at pobox.com
Thu Oct 25 16:10:21 CEST 2012


There appears to be a bit of a problem with rlm_rediswho and attributes
which contain spaces.

rlm_redis_query() calls underlying redisCommand(dissocket->conn, query) in
libhiredis.

However this API separates arguments by spaces, and does not allow any
spaces embedded with arguments, not even with quoting.

If you try something like this:

        start-insert = "LPUSH \"%{User-Name}\" \"%{attr},%{attr},...\""

then it actually pushes keys and values with surrounding double quotes.

As far as I can see, you are supposed to call redisCommand(context, "SET %s
%s", key, value) if key and/or value contain spaces.

https://github.com/redis/hiredis
https://groups.google.com/forum/?fromgroups=#!topic/redis-db/SeDznDcXQiw

Possible solutions I can see:

* Add a safe-characters array like sql_xlat, and don't include space
  (so it expands to =20). Icky.

* Parse the string, if it contains quoted words then break into
  %s substitutions before passing to redisCommand. This would be the
  most transparent solution I think.

* Change rlm_rediswho so that it has template and value, e.g.

  alive-insert = "LPUSH %s %s"
  alive-insert-0 = "%{User-Name}"
  alive-insert-1 = "%l,%{Acct-Session-Id},%{NAS-IP-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{Acct-Input-Gigawords:-0},%{Acct-Output-Gigawords:-0},%{Acct-Input-Octets:-0},%{Acct-Output-Octets:-0}"

  Icky again.

Any one have any better ideas?

Regards,

Brian.


More information about the Freeradius-Devel mailing list