Hello Julien, ALL<br><br>I have reproduced steps, to show you sample on another module and its results in INN (becouse i really like to solve this :)<br><br>Here is part from nnrpd_auth.py module autheticate(args) which is called when authentication begins:<br>
<br>part from readers.conf :<br><br><b><span style="font-family: courier new,monospace;">auth &quot;pdg&quot; {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; python_auth: &quot;nnrpd_auth.py&quot;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span></b><br><br><font face="arial,sans-serif">part from nnrpd_auth.py: (here you can also see how i solved problem with ldap module, i am calling external script and reading result from its standard output - commented lines)<br>
<br><b><span style="font-family: courier new,monospace;">def authenticate(self, attributes):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;Called when python_auth is encountered in readers.conf&quot;&quot;&quot;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # just for debugging purposes</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; syslog(&#39;notice&#39;, &#39;n_a authenticate() invoked: hostname %s, ipaddress %s, interface %s, user %s&#39; % (\</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; attributes[&#39;hostname&#39;], \</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; attributes[&#39;ipaddress&#39;], \</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; attributes[&#39;interface&#39;], \</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; attributes[&#39;user&#39;]))</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # do username passworld authentication</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if &#39;foo&#39; == str(attributes[&#39;user&#39;])&nbsp; \</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #&nbsp;&nbsp; and &#39;foo&#39; == str(attributes[&#39;pass&#39;]):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp; syslog(&#39;notice&#39;, &#39;authentication by username succeeded&#39;)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp; return ( self.authcodes[&#39;ALLOWED&#39;], &#39;No error&#39;, &#39;default_user&#39;)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #else:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp; syslog(&#39;notice&#39;, &#39;authentication by username failed&#39;)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp; return ( self.authcodes[&#39;DENIED&#39;], &#39;Access Denied!&#39;)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #import os</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #result = int(os.popen(&quot;%s %s %s&quot; %(&quot;/opt/pdg/newsauth.py&quot;,str(attributes[&#39;user&#39;]),str(attributes[&#39;pass&#39;])), &quot;r&quot;).read())</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if result == 1:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; syslog(&#39;notice&#39;, &#39;authentication by username succeeded&#39;)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(self.authcodes[&#39;ALLOWED&#39;], &#39;OK&#39;)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #else:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; syslog(&#39;notice&#39;, &#39;authentication by username failed&#39;)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ( self.authcodes[&#39;DENIED&#39;], &#39;FAILED&#39;)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import commands</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = commands.getoutput(&#39;ls -l&#39;)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; syslog(&#39;notice&#39;, result)<br><br></span></b><span style="font-family: courier new,monospace;"><span style="font-family: arial,sans-serif;">And now comes my test.py where i am testing my nnrpd_auth.py:<br>
<br><b style="font-family: courier new,monospace;">from nnrpd_auth import *<br><br>myauth = AUTH()<br><br>print&nbsp; myauth.authenticate({&#39;user&#39;:&#39;boss&#39;,&#39;pass&#39;:&#39;supersecret&#39;,&#39;interface&#39;:None,&#39;ipaddress&#39;:None,&#39;hostname&#39;:None})<br>
</b></span></span></font><br>As you can see my test.py is calling autenticate method same as INN is calling when auth begins.<br>Here comes the result from my test.py:<br><br><span style="font-family: arial,sans-serif;">-- syslog level: notice message: nnrpd authentication class instance created</span><br style="font-family: arial,sans-serif;">
<span style="font-family: arial,sans-serif;">** set_auth_hook for &lt;nnrpd_auth.AUTH instance at 0xb7eb424c&gt;</span><br style="font-family: arial,sans-serif;"><span style="font-family: arial,sans-serif;">-- syslog level: notice message: authentication module successfully hooked into nnrpd</span><br style="font-family: arial,sans-serif;">
<span style="font-family: arial,sans-serif;">-- syslog level: notice message: nnrpd authentication class instance created</span><br style="font-family: arial,sans-serif;"><span style="font-family: arial,sans-serif;">-- syslog level: notice message: n_a authenticate() invoked: hostname None, ipaddress None, interface None, user boss</span><br style="font-family: arial,sans-serif;">
<b style="font-family: arial,sans-serif;">-- syslog level: notice message: total 104<br>-rw-r--r-- 1 news news&nbsp; 859 Jun&nbsp; 4 10:38 INN.py<br>-rw-r--r-- 1 news news 1351 Jun&nbsp; 4 10:38 INN.pyc<br>-rw-r--r-- 1 news news 1351 Jun&nbsp; 4 10:38 INN.pyo<br>
-rw-r--r-- 1 news news&nbsp; 479 Jun&nbsp; 4 10:38 filter.tcl<br>-rw-r--r-- 1 news news 8860 Jun&nbsp; 4 10:38 filter_innd.py<br>-rw-r--r-- 1 news news 7381 Jun&nbsp; 4 10:38 filter_innd.pyc<br>-rw-r--r-- 1 news news 7381 Jun&nbsp; 4 10:38 filter_innd.pyo<br>
-rw-r--r-- 1 news news 2259 Jun&nbsp; 4 10:38 filter_nnrpd.pl<br>-rw-r--r-- 1 root root&nbsp; 512 Jun&nbsp; 4 10:37 nnrpd.py<br>-rw-r--r-- 1 root root&nbsp; 603 Jun&nbsp; 5 11:34 nnrpd.pyc<br>-rw-r--r-- 1 news news 4181 Jun&nbsp; 4 10:38 nnrpd_access.pl<br>
-rw-r--r-- 1 news news 2657 Jun&nbsp; 4 10:38 nnrpd_auth.pl<br>-rw-r--r-- 1 root root 7998 Jun&nbsp; 7 13:06 nnrpd_auth.py<br>-rw-r--r-- 1 root root 8200 Jun&nbsp; 5 12:18 nnrpd_auth.py.backup<br>-rw-r--r-- 1 root root 3109 Jun&nbsp; 7 13:06 nnrpd_auth.pyc<br>
-rw-r--r-- 1 news news&nbsp; 469 Jun&nbsp; 4 10:38 startup.tcl<br>-rw-r--r-- 1 news news 1324 Jun&nbsp; 4 10:38 startup_innd.pl<br>-rw-r--r-- 1 root root&nbsp; 259 Jun&nbsp; 7 13:06 test.py</b><br style="font-family: arial,sans-serif;"><span style="font-family: arial,sans-serif;">None</span><br>
<br>Please note the syslog result .. which is this part from nnrpd_auth.py :<br><font face="arial,sans-serif"><b><span style="font-family: courier new,monospace;">import commands</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = commands.getoutput(&#39;ls -l&#39;)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; syslog(&#39;notice&#39;, result)<br><br></span></b><span style="font-family: courier new,monospace;"><span style="font-family: arial,sans-serif;">And now please note the result from INN where result is completely ignored :</span></span><b><span style="font-family: courier new,monospace;"><br>
<br>Jun&nbsp; 7 13:15:20 dev01 nnrpd[1400]: python: n_a authenticate() invoked: hostname david-nb.net.hlacik.eu, ipaddress <a href="http://10.10.10.199">10.10.10.199</a>, interface <a href="http://10.10.10.183">10.10.10.183</a>, user b<br>
Jun&nbsp; 7 13:15:20 dev01 nnrpd[1400]: python authenticate method returned wrong result<br>Jun&nbsp; 7 13:15:20 dev01 nnrpd[1400]: david-nb.net.hlacik.eu times user 0.000 system 0.008 idle 0.000 elapsed 0.034<br><font style="font-family: arial,sans-serif;" size="2"><br>
Thanks!<br><br>David<br></font></span></b></font><br><br><div class="gmail_quote">On Sat, Jun 7, 2008 at 11:35 AM, David Hláčik &lt;david@hlacik.eu&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello , of course i am importing without .py . I have checked all paths with sys.path and also check if INN is using same python version with same environment as mine - and yes it is.<br>What i have discovered is that nnrpd_auth.py has a really problem with importing anything except builtin sys module.<br>

Module ldap is not working, module commands is not working ... it will simple print no result ...<br>When i test it trought my test script it will does. When i test it directly with INN i see only &quot;python auth returned wrong result&quot;.<br>

When i try to investigate that with try except Exception .. i simple see no error there but null result ... it will simple not call the result... even simple commands.getoutput(&quot;ls -l&quot;) does not work! :(<br>Only one solution i have found is to import sys module and call popen to open external script .. also writen in python .. which will simple to standart out return result (and which is using module ldap without problem) .. and then i read output in nnrpd_auth and work with that.<br>

Such ugly think , i spent 3 days working with nnrpd_auth.py and nothing worked as i wanted (and i am programming in python for 3 years actually so i dont think i am lame ).<br><br>Thanks! and if someone really will help me to investigate problem i will sent them a package of Czech Beers (Gambrinus,Plzen or Budvar) as i am live in czech republic!<div>
<div></div><div class="Wj3C7c"><br>
<br><div class="gmail_quote">On Fri, Jun 6, 2008 at 8:27 PM, Julien ÉLIE &lt;<a href="mailto:julien@trigofacile.com" target="_blank">julien@trigofacile.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

Hi David (thrice),<div><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have created own try, except part to see error, but all i got is : python:<br>
Error: No module named py<br>
I want to know more , i want to know why? There is no other info in logs.<br>
</blockquote>
<br></div>
Do you &quot;import module.py&quot; or &quot;import module&quot;? &nbsp;The last one is the right thing to do<br>
inside your scripts. &nbsp;Also check whether paths are correct.<br>
<br>
And in readers.conf, did you try without &quot;.py&quot; too in the python_auth: parameter?<br>
(I do not know whether it is required.)<br><font color="#888888">
<br>
-- <br>
Julien ÉLIE<br>
<br>
« Mon père, ce héros au sourire si doux. » (Victor Hugo)<br>
<br>
</font></blockquote></div><br>
</div></div></blockquote></div><br>