<div>why radius say :</div>
<div> </div>
<div>authorize: function call failed<br>exceptions.TypeError: unsubscriptable object </div>
<div> </div>
<div> </div>
<div>below is a modify radius_test.py</div>
<div> </div>
<div>=====================================</div>
<div>
<p># Miguel A.L. Paraz <<a href="mailto:mparaz@mparaz.com">mparaz@mparaz.com</a>></p>
<p>import radiusd<br>import MySQLdb</p>
<p>def instantiate(p):<br> print "*** instantiate ***"<br> print p</p>
<p>def authorize(p):<br> print "*** authorize ***"<br> print<br> radiusd.radlog(radiusd.L_INFO, '*** radlog call in authorize ***')<br> print<br> print p</p>
<p> dbHandle = MySQLdb.connect(db="radius", host="localhost", user="radius", passwd="radius")</p>
<p> userName = None<br> userPasswd = None</p>
<p> for t in p:<br> if t[0] == 'User-Name':<br> userName = t[1]<br> elif t[0] == 'Password':<br> userPasswd = t[1]</p>
<p> sql = 'select value from radcheck where username = ' + userName + ' limit 1'</p>
<p> dbCursor = dbHandle.cursor()<br> dbCursor.execute(sql)<br> result = dbCursor.fetchone()</p>
<p> if not result:<br> dbCursor.close()<br> return radiusd.RLM_MODULE_NOTFOUND</p>
<p> if result[0] != userPasswd[1:-1]:<br> return radiusd.RLM_MODULE_REJECT</p>
<p> dbCursor.close()</p>
<p> return (radiusd.RLM_MODULE_OK,<br> (('Reply-Message', 'ok'),),<br> (('Auth-Type', 'python'),))</p>
<p><br>def preacct(p):<br> print "*** preacct ***"<br> print p<br> return radiusd.RLM_MODULE_OK</p>
<p>def accounting(p):<br> print "*** accounting ***"<br> radiusd.radlog(radiusd.L_INFO, '*** radlog call in accounting (0) ***')<br> print<br> print p<br> return radiusd.RLM_MODULE_OK</p>
<p><br>def detach():<br> print "*** goodbye from radiusd_test.py ***"<br> return radiusd.RLM_MODULE_OK<br></p>
<p>======================================</p>
<p>and my python.conf</p>
<p>======================================</p>
<p>python {<br> mod_instantiate = radiusd_test<br> func_instantiate = instantiate</p>
<p> mod_authorize = radiusd_test<br> func_authorize = authorize</p>
<p> mod_accounting = radiusd_test<br> func_accounting = accounting</p>
<p> mod_preacct = radiusd_test<br> func_preacct = preacct</p>
<p> mod_detach = radiusd_test<br> func_detach = detach</p>
<p> }</p>
<p> </p>
<p>======================================</p>
<p> </p>
<p> </p>
<p>i had test original radiusd_test ,it's work well,</p>
<p>but i add the sql query,it's dont work... </p>
<p>and i also test the pure python script ,it's work well with "import MySQLdb" and some sql query...</p>
<p>i don't know why...please help me....</p>
<p> </p>
<p> </p>
<p> </p></div>