/usr/share/doc/freeradius/examples/postgresql_update_radacct_group_trigger.sql is in freeradius 2.1.12+dfsg-1.2ubuntu8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | /*
* $Id$
*
* OPTIONAL Postgresql trigger for FreeRADIUS
*
* This trigger updates fills in the groupname field (which doesnt come in Accounting packets)
* by querying the radusergroup table.
* This makes it easier to do group summary reports, however note that it does add some extra
* database load to 50% of your SQL accounting queries. If you dont care about group summary
* reports then you dont need to install this.
*
*/
CREATE OR REPLACE FUNCTION upd_radgroups() RETURNS trigger AS'
DECLARE
v_groupname varchar;
BEGIN
SELECT INTO v_groupname groupname FROM radusergroup WHERE calledstationid = NEW.calledstationid AND username = NEW.username;
IF FOUND THEN
UPDATE radacct SET groupname = v_groupname WHERE radacctid = NEW.radacctid;
END IF;
RETURN NEW;
END
'LANGUAGE plpgsql;
DROP TRIGGER upd_radgroups ON radacct;
CREATE TRIGGER upd_radgroups AFTER INSERT ON radacct
FOR EACH ROW EXECUTE PROCEDURE upd_radgroups();
|