<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PostalCode"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="Street"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="address"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="City"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Bookman Old Style";
        panose-1:2 5 6 4 5 5 5 2 2 4;}
@font-face
        {font-family:"MS Serif";}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p
        {mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Hi All,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I am using FreeRadius with PostgreSQL and everything is running
like a charm besides a small issue.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I am using ‘session-timeout’ attribute in radreply
table to control user session time. <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I have added a trigger on RADACCT table which subtracts amount
of time used by user from RADREPLY each time when he logs in.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>It does work but when time is below 0 or negative I need to
stop user from getting into my system and I am failing to do so.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Here are my RADREPLY Table entries <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>INSERT INTO radreply (id, username, attribute, op, value)
VALUES (2, 'sagar', 'Idle-Timeout', ':=', '300');<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>INSERT INTO radreply (id, username, attribute, op, value)
VALUES (3, 'sagar', 'Reply-Message', ':=', 'You Have Logged in Successfully');<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>INSERT INTO radreply (id, username, attribute, op, value)
VALUES (1, 'sagar', 'Acct-Interim-Interval', ':=', '120');<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>INSERT INTO radreply (id, username, attribute, op, value)
VALUES (4, 'sagar', <b><span style='font-weight:bold'>'Session-Timeout', ':=',
'-904')</span></b>;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>The easiest way would be altering Authenticate SQL and
adding a condition to check Session-Timeout to see it doesn’t fall below
0<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I am not very good in POSTGRES so can someone please let me
know how to do it.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>The other way would be using a Function /Procedure to carry
out this check but my question is how to use procedures/functions in
postgres.conf <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>       
authenticate_query = "SELECT Value,Attribute FROM ${authcheck_table} \<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>               
WHERE UserName = '%{User-Name}' AND ( Attribute = 'User-Password' OR Attribute
= 'Crypt-Password' ) \<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>               
ORDER BY Attribute DESC"</span></font><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p style='margin-bottom:3.0pt'><i><font size=5 color=blue
face="Bookman Old Style"><span lang=EN-GB style='font-size:20.0pt;font-family:
"Bookman Old Style";color:blue;font-style:italic'>Sagar Patil<o:p></o:p></span></font></i></p>

<p style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:3.0pt;
margin-left:0cm'><font size=1 color=gray face="MS Serif"><span lang=EN-GB
style='font-size:7.5pt;font-family:"MS Serif";color:gray'>British
Telecommunications plc <br>
Registered office: <st1:address w:st="on"><st1:Street w:st="on">81 Newgate
  Street</st1:Street> <st1:City w:st="on">London</st1:City> <st1:PostalCode
 w:st="on">EC1A 7AJ</st1:PostalCode></st1:address> <br>
Registered in England no. 1800000. <br>
<br>
This electronic message contains information from British Telecommunications
plc which may <br>
be privileged or confidential. The information is intended to be for the use of
the individual(s) or <br>
entity named above. If you are not the intended recipient be aware that any
disclosure, <br>
copying, distribution or use of the contents of this information is prohibited.
If you have <br>
received this electronic message in error, please notify us by telephone or
email (to the <br>
numbers or address above) immediately.</span></font><span lang=EN-GB><o:p></o:p></span></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>

</div>

</body>

</html>