Nie jesteś zalogowany.
Jeśli nie posiadasz konta, zarejestruj je już teraz! Pozwoli Ci ono w pełni korzystać z naszego serwisu. Spamerom dziękujemy!
Prosimy o pomoc dla małej Julki — przekaż 1% podatku na Fundacji Dzieciom zdazyć z Pomocą.
Więcej informacji na dug.net.pl/pomagamy/.
Witam,
mam taki problem w związku radiusem i sql'em...
skonfigurowałem Radiusa razem z postgresem...gdzie chciałbym
np autoryzować sobie użytkowników przy zapytaniach sql'owych.
Znalazłem troche informacji na ten temat...ale zastanawiam się
gdzie dokładnie umieszczać takie zapytania..? ( w jakim pliku? )
Domyslnie jest to niby - /etc/freeradius/sites-available/default
( np sekcja authorize {}) Ale kiedy próbuję wrzucić tam jakieś
zapytanie to po restarcie radiusa wywala mi błąd..( w sensie radius się nie uruchamia ).
Jest to najnowsza wersja...ciężko mi określić co może być nie tak...bo przemaglowałem wszystkie pliki...
przykład:
authorize { preprocess if("%{sql:SELECT COUNT(*) FROM `useros` WHERE username = '%{User-Name}'}" >= 1) { ok update control { Auth-Type := Accept } } else { reject } }
nie wiem czy to wersja radiusa czy jak?
Offline
A co logi na ten temat piszą, znaczy się dlaczego radius się nie uruchamia?
Offline
rzuca się do zapytania.... dlatego nie wiem czy to problem z tymże w złym miejscu deklaruje zapytanie?
Thu Jul 28 12:32:58 2016 : Debug: including configuration file /etc/freeradius/sql.conf Thu Jul 28 12:32:58 2016 : Debug: including configuration file /etc/freeradius/sql/postgresql/dialup.conf Thu Jul 28 12:32:58 2016 : Debug: including configuration file /etc/freeradius/policy.conf Thu Jul 28 12:32:58 2016 : Debug: including files in directory /etc/freeradius/sites-enabled/ Thu Jul 28 12:32:58 2016 : Debug: including configuration file /etc/freeradius/sites-enabled/default Thu Jul 28 12:32:58 2016 : Error: /etc/freeradius/sites-enabled/default[75] Unexpected text Auth-Type := Accept }. See "man unlang" Thu Jul 28 12:32:58 2016 : Error: Errors reading or parsing /etc/freeradius/radiusd.conf
Offline
Próbowałeś zmienić na Auth-Type := "Accept" ? Kwestia, żeby dorzucić "".
Offline
tak, próbowałem ale jest to samo...
pytanie...jak można poprawnie wykonać zapytanie w tym miejscu?
( z dobrą składnią ) bo to będzie problem składni.
Offline
if("%{sql:SELECT COUNT(*) FROM `useros` WHERE username = '%{User-Name}'}" >= 1) { ok update control { Auth-Type := "Accept" } } else { update control { Auth-Type := "Reject" } }
Takie coś u mnie puściło - brak błędów.
Offline
Jest OK! Czyli wyglada na to że składania... Dzieki bardzo :)
Offline
Freeradius z Mysql - 2 vhosty na różnych portach (mają różne bazy):
sql { # Connect info database = "mysql" driver = "rlm_sql_${database}" server = "localhost" login = "radiusd" password = "HASEŁKO1" # Database table configuration radius_db = "radiusd" acct_table1 = "radacct" acct_table2 = "radacct" postauth_table = "radpostauth" authcheck_table = "radcheck" authreply_table = "radreply" groupcheck_table = "radgroupcheck" groupreply_table = "radgroupreply" usergroup_table = "radusergroup" deletestalesessions = yes sqltrace = no sqltracefile = ${logdir}/sqltrace.sql num_sql_socks = 5 connect_failure_retry_delay = 60 readclients = yes nas_table = "nas" $INCLUDE sql/${database}/dialup.conf nas_query = "SELECT id, nasname, shortname, type, secret FROM ${nas_table}" authorize_check_query = "SELECT id, UserName, Attribute, Value, op FROM radcheck WHERE Username = '%{User-Name}' ORDER BY id" authreply_query = "SELECT id, username, attribute, op, value FROM radreply WHERE username = '%{User-Name}' ORDER BY id" # group_membership_query = "SELECT groupname FROM ${usergroup_table} WHERE username = '%{SQL-User-Name}' ORDER BY priority" # authorize_group_check_query = "SELECT id, groupname, attribute, Value, op FROM ${groupcheck_table} WHERE groupname = '%{Sql-Group}' ORDER BY id" # authorize_group_reply_query = "SELECT id, groupname, attribute, value, op FROM ${groupreply_table} WHERE groupname = '%{Sql-Group}' ORDER BY id" } sql sql_fstest { # Connect info database = "mysql" driver = "rlm_sql_${database}" server = "localhost" login = "radiusd" password = "HASEŁKO2 # Database table configuration radius_db = "fsradiusd" acct_table1 = "radacct" acct_table2 = "radacct" postauth_table = "radpostauth" authcheck_table = "radcheck" authreply_table = "radreply" groupcheck_table = "radgroupcheck" groupreply_table = "radgroupreply" usergroup_table = "radusergroup" deletestalesessions = yes sqltrace = no sqltracefile = ${logdir}/sqltrace.sql num_sql_socks = 5 connect_failure_retry_delay = 60 readclients = yes nas_table = "nas" $INCLUDE sql/${database}/dialup.conf nas_query = "SELECT id, nasname, shortname, type, secret FROM ${nas_table}" authorize_check_query = "SELECT id, UserName, Attribute, Value, op FROM radcheck WHERE Username = '%{User-Name}' ORDER BY id" authreply_query = "SELECT id, username, attribute, op, value FROM radreply WHERE username = '%{User-Name}' ORDER BY id" # group_membership_query = "SELECT groupname FROM ${usergroup_table} WHERE username = '%{SQL-User-Name}' ORDER BY priority" # authorize_group_check_query = "SELECT id, groupname, attribute, Value, op FROM ${groupcheck_table} WHERE groupname = '%{Sql-Group}' ORDER BY id" # authorize_group_reply_query = "SELECT id, groupname, attribute, value, op FROM ${groupreply_table} WHERE groupname = '%{Sql-Group}' ORDER BY id" }
Oba działają.
Przykład z radtesta:
Sending Access-Request packet to host 127.0.0.1 port 1812, id=245, length=0 User-Name = "test" User-Password = "test" NAS-IP-Address = 127.0.0.1 NAS-Port = 0 Message-Authenticator = 0x00 EAP-Code = Response EAP-Type-Identity = 0x74657374 EAP-Message = 0x02f400090174657374 rlm_eap: EAP-Message not found Received Access-Accept packet from host 127.0.0.1 port 1812, id=245, length=32 Framed-IP-Address = 192.168.2.229 Framed-IP-Netmask = 255.255.255.0 Sending Access-Request of id 184 to 127.0.0.1 port 1815 User-Name = "test" CHAP-Password = 0xb84f01c154d281d2a9cdaa12dc84679bd4 NAS-IP-Address = 127.0.0.1 NAS-Port = 0 Message-Authenticator = 0x00000000000000000000000000000000 rad_recv: Access-Accept packet from host 127.0.0.1 port 1815, id=184, length=57 Freeswitch-Context = "default" Freeswitch-AVPair = "account=tester"
Może się przyda, składnia dosyć prosta, spełnia wymogi SQL:2003, do Postgresa powinna pasować.
Pozdro
;-)
Offline
Time (s) | Query |
---|---|
0.00014 | SET CHARSET latin2 |
0.00005 | SET NAMES latin2 |
0.00161 | SELECT u.*, g.*, o.logged FROM punbb_users AS u INNER JOIN punbb_groups AS g ON u.group_id=g.g_id LEFT JOIN punbb_online AS o ON o.ident='18.119.122.140' WHERE u.id=1 |
0.00086 | UPDATE punbb_online SET logged=1732740568 WHERE ident='18.119.122.140' |
0.00063 | SELECT * FROM punbb_online WHERE logged<1732740268 |
0.00075 | DELETE FROM punbb_online WHERE ident='66.249.66.73' |
0.00084 | SELECT topic_id FROM punbb_posts WHERE id=303650 |
0.00067 | SELECT id FROM punbb_posts WHERE topic_id=28821 ORDER BY posted |
0.00067 | SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM punbb_topics AS t INNER JOIN punbb_forums AS f ON f.id=t.forum_id LEFT JOIN punbb_forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id=28821 AND t.moved_to IS NULL |
0.00005 | SELECT search_for, replace_with FROM punbb_censoring |
0.00118 | SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online FROM punbb_posts AS p INNER JOIN punbb_users AS u ON u.id=p.poster_id INNER JOIN punbb_groups AS g ON g.g_id=u.group_id LEFT JOIN punbb_online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id=28821 ORDER BY p.id LIMIT 0,25 |
0.00081 | UPDATE punbb_topics SET num_views=num_views+1 WHERE id=28821 |
Total query time: 0.00826 s |