Mailman-2.1.23 and reCAPTCHA

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Mailman-2.1.23 and reCAPTCHA

sp2l
Greetings.


Does somebody  succeeded intergating
reCAPTCHA to Mailman-2.1.23 ?

I tried belows:
https://www.dragonsreach.it/2014/05/03/adding-recaptcha-support-to-mailman/


but unsuccessfully...

Mailman reports the following:

Jun 02 18:07:09 2017 admin(4038): @@@@@@@@@@
admin(4038): [----- Mailman Version: 2.1.23 -----]
admin(4038): [----- Traceback ------]
admin(4038): Traceback (most recent call last):
admin(4038):   File "/usr/local/mailman/scripts/driver", line 102, in run_main
admin(4038):     pkg = __import__('Mailman.Cgi', globals(), locals(), [scriptname])
admin(4038):   File "/usr/local/mailman/Mailman/Cgi/listinfo.py", line 37, in <module>
admin(4038):    from recaptcha.client import captcha
admin(4038): ImportError: No module named recaptcha.client
admin(4038): [----- Python Information -----]
admin(4038): sys.version     =   2.7.9 (default, Aug 13 2016, 16:41:35)
[GCC 4.9.2]
admin(4038): sys.executable  =   /usr/bin/python
admin(4038): sys.prefix      =   /usr
admin(4038): sys.exec_prefix =   /usr
admin(4038): sys.path        =   ['/usr/local/mailman/pythonlib', '/usr/local/mailman', '/usr/local/mailman/scripts', '/usr/local/mailman', '/usr/lib/python2.7/', '/usr/lib/python2.7/plat-i386-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/lib/python2.7/site-packages', '/usr/share/pyshared']
admin(4038): sys.platform    =   linux2
admin(4038): [----- Environment Variables -----]
admin(4038): HTTP_COOKIE: fusion27SN8_visited=yes; fusion27SN8_cookieconsent=yes; mailviewsplitterv=165; mailviewsplitter=205; phpipam=ipe9n75m8erj33340dn786bcf2
admin(4038): CONTEXT_DOCUMENT_ROOT: /usr/local/mailman/cgi-bin/
admin(4038): SERVER_SOFTWARE: Apache/2.4.10 (Debian)
admin(4038): CONTEXT_PREFIX: /mailman/
admin(4038): SERVER_SIGNATURE: <address>Apache/2.4.10 (Debian) Server at www.sp2l.ampr.org Port 80</address>
admin(4038):
admin(4038): REQUEST_METHOD: GET
admin(4038): SERVER_PROTOCOL: HTTP/1.1
admin(4038): QUERY_STRING:  
admin(4038): HTTP_USER_AGENT: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
admin(4038): HTTP_CONNECTION: keep-alive
admin(4038): HTTP_REFERER: http://www.sp2l.ampr.org/news.php 
admin(4038): SERVER_NAME: www.sp2l.ampr.org
admin(4038): REMOTE_ADDR: 87.251.250.110
admin(4038): SERVER_PORT: 80
admin(4038): SERVER_ADDR: 192.168.0.101
admin(4038): DOCUMENT_ROOT: /var/www
admin(4038): PYTHONPATH: /usr/local/mailman
admin(4038): SCRIPT_FILENAME: /usr/local/mailman/cgi-bin/listinfo
admin(4038): SERVER_ADMIN: [hidden email]
admin(4038): HTTP_HOST: www.sp2l.ampr.org
admin(4038): SCRIPT_NAME: /mailman/listinfo
admin(4038): HTTP_CACHE_CONTROL: max-age=0
admin(4038): REQUEST_URI: /mailman/listinfo
admin(4038): HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
admin(4038): GATEWAY_INTERFACE: CGI/1.1
admin(4038): REMOTE_PORT: 42610
admin(4038): HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.5
admin(4038): REQUEST_SCHEME: http
admin(4038): HTTP_ACCEPT_ENCODING: gzip, deflate

===================================================



1. Mailman-2.1.23  – installed, up&running
2. python-recaptcha  – installed
3. System Debian-8.8./32b - updated to date.



Best regards.
Tom – SP2L
------------------------------------------------------
Mailman-Users mailing list [hidden email]
https://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: https://mail.python.org/mailman/options/mailman-users/lists%2Bs9n3h93%40n7.nabble.com
Reply | Threaded
Open this post in threaded view
|

Re: Mailman-2.1.23 and reCAPTCHA

Mark Sapiro-3
On 06/02/2017 10:03 AM, sp2l wrote:

> Greetings.
>
>
> Does somebody  succeeded intergating
> reCAPTCHA to Mailman-2.1.23 ?
>
> I tried belows:
> https://www.dragonsreach.it/2014/05/03/adding-recaptcha-support-to-mailman/
>
>
> but unsuccessfully...
>
> Mailman reports the following:
>
> Jun 02 18:07:09 2017 admin(4038): @@@@@@@@@@
> admin(4038): [----- Mailman Version: 2.1.23 -----]
> admin(4038): [----- Traceback ------]
> admin(4038): Traceback (most recent call last):
> admin(4038):   File "/usr/local/mailman/scripts/driver", line 102, in run_main
> admin(4038):     pkg = __import__('Mailman.Cgi', globals(), locals(), [scriptname])
> admin(4038):   File "/usr/local/mailman/Mailman/Cgi/listinfo.py", line 37, in <module>
> admin(4038):    from recaptcha.client import captcha
> admin(4038): ImportError: No module named recaptcha.client


The patch you installed requires the installation of recaptcha-client
<https://pypi.python.org/pypi/recaptcha-client/>.

This is not recaptcha <https://pypi.python.org/pypi/recaptcha/1.0rc1>.

sudo pip install recaptcha-client

should do it.

--
Mark Sapiro <[hidden email]>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan
------------------------------------------------------
Mailman-Users mailing list [hidden email]
https://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: https://mail.python.org/mailman/options/mailman-users/lists%2Bs9n3h93%40n7.nabble.com
Reply | Threaded
Open this post in threaded view
|

Re: Mailman-2.1.23 and reCAPTCHA

sp2l

-----Original message -----
From: Mark Sapiro
Sent: Sunday, June 4, 2017 1:04 AM
To: [hidden email]
Subject: Re: [Mailman-Users] Mailman-2.1.23 and reCAPTCHA

...


The patch you installed requires the installation of recaptcha-client
<https://pypi.python.org/pypi/recaptcha-client/>.

This is not recaptcha <https://pypi.python.org/pypi/recaptcha/1.0rc1>.

sudo pip install recaptcha-client

should do it.

--
Mark Sapiro <[hidden email]>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan
------------------------------------------------------



Hello Mark.

Thank you for your suggestion,
but apparently this was not the case...

When I ran "pip install recaptcha-client"
I got the following message:

   root@linux:# pip install recaptcha-client
   Requirement already satisfied (use --upgrade to upgrade):
recaptcha-client in /usr/lib/python2.7/dist-packages
   Cleaning up...
   root@linux:#

So, it appears that installing python-recaptcha,
module recaptcha-client got installed too.

Therefore I startet to look at issue from a different point of view.

The error message was:
   admin(4038):    from recaptcha.client import captcha
   admin(4038):    ImportError: No module named recaptcha.client

Looking at the directory tree I noticed the following chain:
/usr / share / pyshared / recaptcha / client

There _IS NEITHER_  recaptcha.client
_NOR_  recaptcha-client  directory.

In patch supplied by this article:
   https://www.dragonsreach.it/2014/05/03/adding-recaptcha-support-to-mailman/

there are twice two lines:

   sys.path.append("/usr/share/pyshared")
   from recaptcha.client import captcha

Changed them to read:

   sys.path.append("/usr/share/pyshared/recaptcha")
   from client import captcha

This way achieved success to have at least
properly displayed and working recaptcha box.

Please navigate to one of test lists to see above:

   http://www.sp2l.ampr.org/mailman/listinfo

After filling the form, satisfying recaptcha requirements
then clicking "Subscribe" I received another error message
in web browser window:

   Bug in Mailman version 2.1.23

   We're sorry, we hit a bug!

   Please inform the webmaster for this site of this problem.
   Printing of traceback and other system information has been explicitly
inhibited,
   but the webmaster can find this information in the Mailman error logs.

Checked mailman error log file and noticed the following:

   Jun 05 20:20:03 2017 admin(23429): @@@@@@@@@@@@@@@@@@@.
   admin(23429): [----- Mailman Version: 2.1.23 -----].
   admin(23429): [----- Traceback ------].
   admin(23429): Traceback (most recent call last):
   admin(23429):   File "/usr/local/mailman/scripts/driver", line 102, in
run_main
   admin(23429):     pkg = __import__('Mailman.Cgi', globals(), locals(),
[scriptname])
   admin(23429):   File "/usr/local/mailman/Mailman/Cgi/subscribe.py", line
149
   admin(23429):     if email == mlist.GetListEmail():
   admin(23429):                                                       ^
   admin(23429): IndentationError: unindent does not match any outer
indentation level


At this point I am simply stucked...
All suggestions, advices are very welcomed.

BTW, should recaptcha box be positioned
at the bottom of browser window?



Best regards.
Tom - SP2L

------------------------------------------------------
Mailman-Users mailing list [hidden email]
https://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: https://mail.python.org/mailman/options/mailman-users/lists%2Bs9n3h93%40n7.nabble.com
Reply | Threaded
Open this post in threaded view
|

Re: Mailman-2.1.23 and reCAPTCHA

Mark Sapiro-3
On 06/05/2017 10:43 AM, sp2l wrote:

> When I ran "pip install recaptcha-client"
> I got the following message:
>
>   root@linux:# pip install recaptcha-client
>   Requirement already satisfied (use --upgrade to upgrade): recaptcha-client in /usr/lib/python2.7/dist-packages
>   Cleaning up...
>   root@linux:#
>
> So, it appears that installing python-recaptcha,
> module recaptcha-client got installed too.
>
> Therefore I startet to look at issue from a different point of view.
>
> The error message was:
>   admin(4038):    from recaptcha.client import captcha
>   admin(4038):    ImportError: No module named recaptcha.client
>
> Looking at the directory tree I noticed the following chain:
> /usr / share / pyshared / recaptcha / client
>
> There _IS NEITHER_  recaptcha.client
> _NOR_  recaptcha-client  directory.


You need to understand how Python imports work. The recaptcha/client
directory contains both __init__.py and captcha.py. Thus the

from recaptcha.client import captcha

statement will import the captcha.py file from recaptcha/client/

This is all as it should be. If the import fails it is because
/usr/share/pyshared/ is not in Python's path. This is not too surprising
as it this would normally be installed in
/usr/local/lib/python2.7/dist-packages/ rather than /usr/share/pyshared/.


> In patch supplied by this article:
>   https://www.dragonsreach.it/2014/05/03/adding-recaptcha-support-to-mailman/
>
> there are twice two lines:
>
>   sys.path.append("/usr/share/pyshared")
>   from recaptcha.client import captcha
>
> Changed them to read:
>
>   sys.path.append("/usr/share/pyshared/recaptcha")
>   from client import captcha
>
> This way achieved success to have at least
> properly displayed and working recaptcha box.


OK. That's an acceptable work-around. Possibly the issue is there is no
__init__.py file in the distributed recaptcha/ directory. Possibly just

touch /usr/share/pyshared/recaptcha/__init__.py

would also enable this.


> Checked mailman error log file and noticed the following:
>
>   Jun 05 20:20:03 2017 admin(23429): @@@@@@@@@@@@@@@@@@@.
>   admin(23429): [----- Mailman Version: 2.1.23 -----].
>   admin(23429): [----- Traceback ------].
>   admin(23429): Traceback (most recent call last):
>   admin(23429):   File "/usr/local/mailman/scripts/driver", line 102, in run_main
>   admin(23429):     pkg = __import__('Mailman.Cgi', globals(), locals(), [scriptname])
>   admin(23429):   File "/usr/local/mailman/Mailman/Cgi/subscribe.py", line 149
>   admin(23429):     if email == mlist.GetListEmail():
>   admin(23429):                                                       ^
>   admin(23429): IndentationError: unindent does not match any outer indentation level


In the process of applying the patch and/or editing the file, you have
broken the formatting of /usr/local/mailman/Mailman/Cgi/subscribe.py

The patched code beginning around line 130 should look like

     remote = os.environ.get('REMOTE_HOST',
                             os.environ.get('REMOTE_ADDR',
                                            'unidentified origin'))

     # recaptcha
     captcha_response = captcha.submit(
         cgidata.getvalue('recaptcha_challenge_field', ""),
         cgidata.getvalue('recaptcha_response_field', ""),
         mm_cfg.RECAPTCHA_PRIVATE_KEY,
         remote,
         )
     if not captcha_response.is_valid:
         results.append(_('Invalid captcha'))

      # Was an attempt made to subscribe the list to itself?
      if email == mlist.GetListEmail():
          syslog('mischief', 'Attempt to self subscribe %s: %s', email,
remote)

The lines

     remote = os.environ.get('REMOTE_HOST',
     # recaptcha
     captcha_response = captcha.submit(
     if not captcha_response.is_valid:
     # Was an attempt made to subscribe the list to itself?
     if email == mlist.GetListEmail():

in the above MUST be indented exactly 4 spaces, no tabs

> At this point I am simply stucked...
> All suggestions, advices are very welcomed.
>
> BTW, should recaptcha box be positioned
> at the bottom of browser window?


Questions such as this should be addressed to the author of the patch.
See <https://wiki.list.org/x/12812344>.

--
Mark Sapiro <[hidden email]>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan
------------------------------------------------------
Mailman-Users mailing list [hidden email]
https://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: https://mail.python.org/mailman/options/mailman-users/lists%2Bs9n3h93%40n7.nabble.com
Reply | Threaded
Open this post in threaded view
|

Re: Mailman-2.1.23 and reCAPTCHA

sp2l
Hello Mark.


First of all I thank you very much for such
complex and self-explanatory elucidation.

Now, I need to say  _NOT GUILTY_  in regards everything
what is beyound control of regular Linux system
user when installing OS from original DVD disc.
I mean for instance, which packages and where
being placed by installation routine.

1. The recaptcha/client directory contained from
     the beginning both __init__.py and captcha.py.
     So, "touch /usr/share/pyshared/recaptcha/__init__.py"
     wasn't necessary.

2. The two directories:
        /usr/share/pyshared/
        /usr/local/lib/python2.7/dist-packages
     were created during system install time.

3. Removed  __one additional__  space character
    before " if not...", thus solving indent issue.


Yet another problem emerged:
"Invalid captcha" message,
regardless of correct response to captcha.

Need to search for solution.


Best regards.

---
Tom - SP2L

Sent from Xperia Z1 with AquaMail
http:/​/​www​.​aqua-mail​.​com



------------------------------------------------------
Mailman-Users mailing list [hidden email]
https://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: https://mail.python.org/mailman/options/mailman-users/lists%2Bs9n3h93%40n7.nabble.com
Reply | Threaded
Open this post in threaded view
|

Re: Mailman-2.1.23 and reCAPTCHA

sp2l
In reply to this post by Mark Sapiro-3
Mark.


Location  /usr/share/pyshared seem to be
specific to Debian as I just checked my old
Debian-7.11 where exactly the same exists.


Best regards.
---
Tom - SP2L

Sent from Xperia Z1 with AquaMail
http:/​/​www​.​aqua-mail​.​com



------------------------------------------------------
Mailman-Users mailing list [hidden email]
https://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: https://mail.python.org/mailman/options/mailman-users/lists%2Bs9n3h93%40n7.nabble.com
Reply | Threaded
Open this post in threaded view
|

Re: Mailman-2.1.23 and reCAPTCHA

Mark Sapiro-3
In reply to this post by sp2l
On 06/06/2017 07:23 AM, SP2L wrote:
>
> 1. The recaptcha/client directory contained from
>     the beginning both __init__.py and captcha.py.
>     So, "touch /usr/share/pyshared/recaptcha/__init__.py"
>     wasn't necessary.


I know that the recaptcha-client package contains
recaptcha/client/__init__.py. I was suggesting that for some unknown
reason, it may also need recaptcha/__init__.py. In order for a directory
to be recognized as a Python module, it must contain a (possibly empty)
__init__.py.


> Yet another problem emerged:
> "Invalid captcha" message,
> regardless of correct response to captcha.
>
> Need to search for solution.


I can't help with that one.

--
Mark Sapiro <[hidden email]>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan
------------------------------------------------------
Mailman-Users mailing list [hidden email]
https://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: https://mail.python.org/mailman/options/mailman-users/lists%2Bs9n3h93%40n7.nabble.com