[PATCH] return notfound from rlm_sql
Greetings, The attached patch makes rlm_sql return RLM_MODULE_NOTFOUND when no rows were affected by the accounting queries, and modifies acct.c and modcall.c to recognize notfound as a valid accounting return status. As far as I can tell, this patch shouldn't affect any existing configurations which don't expect notfound for accounting packets. The scenario where this is useful is a staged migration from a legacy Radius platform to a new FreeRadius setup. During migration phase, new users are created in the new database, existing users are gradually moved from the old database to the new one. Users existing in the new database are handled locally, auth and acct packets for users that weren't migrated yet are proxied to the legacy platform. To make use of the attached patch in such scenario, accounting INSERT queries in dialup.conf are changed into: INSERT ... SELECT <same set of values> FROM radcheck WHERE username = '%{SQL-User-Name}' ORDER BY id LIMIT 1 In the server configuration, invocation of rlm_sql is followed by: if(notfound) { update control { Proxy-To-Realm = legacy } updated } -- Dmitry Borodaenko
Dmitry Borodaenko wrote:
The scenario where this is useful is a staged migration from a legacy Radius platform to a new FreeRadius setup. During migration phase, new users are created in the new database, existing users are gradually moved from the old database to the new one. Users existing in the new database are handled locally, auth and acct packets for users that weren't migrated yet are proxied to the legacy platform.
That's a good use-case. It would probably be better, though, to have the module return NOOP if it doesn't do anything. That's the intent of NOOP after all. Doing it that way means that the change is limited to the SQL module, and no patching of modcall.c is necessary. Alan DeKok.
participants (2)
-
Alan DeKok -
Dmitry Borodaenko