[GH-ISSUE #107] Unable to logout when webmail enabled but not configured #93

Closed
opened 2026-02-27 11:10:02 +03:00 by kerem · 2 comments
Owner

Originally created by @tonioo on GitHub (Dec 4, 2013).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/107

Originally assigned to: @tonioo on GitHub.

Originally created by Florent Dionisi on 2010-11-26T14:35:37Z

When webmail is enabled on a brand new mailbox, but not yet configured, you can logon to the modoboa admin but can not logout.

It Seems like webmail is trying to connect to an IMAP server. But it fails as it is not yet configured. See traces beelow.

[Errno 111] Connection refused

# /home/florent/modoboa/../modoboa/extensions/webmail/lib.py in login

 171. def login(self, user, passwd):
 172. import imaplib
 173. try:
 174. secured = parameters.get_admin("IMAP_SECURED")
 175. if secured == "yes":
 176. self.m = imaplib.IMAP4_SSL(self.address, self.port)
 177. else:

 178. self.m = imaplib.IMAP4(self.address, self.port) ...

 179. except (imaplib.IMAP4.error, ssl.SSLError), error:
 180. return False, _("Connection to IMAP server failed, check your configuration")
 181. try:
 182. self.m.login(user, passwd)
 183. except (imaplib.IMAP4.error, ssl.SSLError), error:
 184. return False, _("Authentication failed, check your configuration")

▶ Local vars
Variable    Value
imaplib     

passwd  
'aze1dsq'
secured     
'no'
self    

user    
u'florent@dionisi.fr'
# /usr/lib/python2.6/imaplib.py in +init+

 156. self.untagged_responses = {} # {typ: [data, ...], ...}
 157. self.continuation_response = _ # Last continuation response
 158. self.is_readonly = False # READ-ONLY desired state
 159. self.tagnum = 0
 160.
 161. # Open socket to server.
162.

 163. self.open(host, port) ...

 164.
 165. # Create unique tag for this session,
 166. # and compile tagged response matcher.
 167.
 168. self.tagpre = Int2AP(random.randint(4096, 65535))
 169. self.tagre = re.compile(r'(?P'

▶ Local vars
Variable    Value
host    
'127.0.0.1'
port    
143
self    

# /usr/lib/python2.6/imaplib.py in open

 222. """Setup connection to remote server on "host:port"
 223. (default: localhost:standard IMAP4 port).
 224. This connection will be used by the routines:
 225. read, readline, send, shutdown.
 226. """
 227. self.host = host
 228. self.port = port

 229. self.sock = socket.create_connection((host, port)) ...

 230. self.file = self.sock.makefile('rb')
 231.
 232.
 233. def read(self, size):
 234. """Read 'size' bytes from remote."""
 235. return self.file.read(size)

▶ Local vars
Variable    Value
host    
'127.0.0.1'
port    
143
self    

# /usr/lib/python2.6/socket.py in create_connection

 554. sock.connect(sa)
 555. return sock
 556.
 557. except error, msg:
 558. if sock is not None:
 559. sock.close()
560.

 561. raise error, msg ...

▼ Local vars
Variable    Value
address     
('127.0.0.1', 143)
af  
2
canonname   
_
host    
'127.0.0.1'
msg     
error(111, 'Connection refused')
port    
143
proto   
6
res     
(2, 1, 6, _, ('127.0.0.1', 143))
sa  
('127.0.0.1', 143)
sock    

socktype    
1
timeout     
Originally created by @tonioo on GitHub (Dec 4, 2013). Original GitHub issue: https://github.com/modoboa/modoboa/issues/107 Originally assigned to: @tonioo on GitHub. **Originally created by Florent Dionisi on 2010-11-26T14:35:37Z** When webmail is enabled on a brand new mailbox, but not yet configured, you can logon to the modoboa admin but can not logout. It Seems like webmail is trying to connect to an IMAP server. But it fails as it is not yet configured. See traces beelow. <pre> [Errno 111] Connection refused # /home/florent/modoboa/../modoboa/extensions/webmail/lib.py in login 171. def login(self, user, passwd): 172. import imaplib 173. try: 174. secured = parameters.get_admin("IMAP_SECURED") 175. if secured == "yes": 176. self.m = imaplib.IMAP4_SSL(self.address, self.port) 177. else: 178. self.m = imaplib.IMAP4(self.address, self.port) ... 179. except (imaplib.IMAP4.error, ssl.SSLError), error: 180. return False, _("Connection to IMAP server failed, check your configuration") 181. try: 182. self.m.login(user, passwd) 183. except (imaplib.IMAP4.error, ssl.SSLError), error: 184. return False, _("Authentication failed, check your configuration") ▶ Local vars Variable Value imaplib <module 'imaplib' from '/usr/lib/python2.6/imaplib.pyc'> passwd 'aze1dsq' secured 'no' self <modoboa.extensions.webmail.lib.IMAPconnector object at 0x1b89090> user u'florent@dionisi.fr' # /usr/lib/python2.6/imaplib.py in +init+ 156. self.untagged_responses = {} # {typ: [data, ...], ...} 157. self.continuation_response = _ # Last continuation response 158. self.is_readonly = False # READ-ONLY desired state 159. self.tagnum = 0 160. 161. # Open socket to server. 162. 163. self.open(host, port) ... 164. 165. # Create unique tag for this session, 166. # and compile tagged response matcher. 167. 168. self.tagpre = Int2AP(random.randint(4096, 65535)) 169. self.tagre = re.compile(r'(?P<tag>' ▶ Local vars Variable Value host '127.0.0.1' port 143 self <imaplib.IMAP4 instance at 0x1d85b00> # /usr/lib/python2.6/imaplib.py in open 222. """Setup connection to remote server on "host:port" 223. (default: localhost:standard IMAP4 port). 224. This connection will be used by the routines: 225. read, readline, send, shutdown. 226. """ 227. self.host = host 228. self.port = port 229. self.sock = socket.create_connection((host, port)) ... 230. self.file = self.sock.makefile('rb') 231. 232. 233. def read(self, size): 234. """Read 'size' bytes from remote.""" 235. return self.file.read(size) ▶ Local vars Variable Value host '127.0.0.1' port 143 self <imaplib.IMAP4 instance at 0x1d85b00> # /usr/lib/python2.6/socket.py in create_connection 554. sock.connect(sa) 555. return sock 556. 557. except error, msg: 558. if sock is not None: 559. sock.close() 560. 561. raise error, msg ... ▼ Local vars Variable Value address ('127.0.0.1', 143) af 2 canonname _ host '127.0.0.1' msg error(111, 'Connection refused') port 143 proto 6 res (2, 1, 6, _, ('127.0.0.1', 143)) sa ('127.0.0.1', 143) sock <socket._socketobject object at 0x1d937c0> socktype 1 timeout <object object at 0x7ff3f80500e0> </pre>
kerem 2026-02-27 11:10:02 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@tonioo commented on GitHub (Dec 4, 2013):

Posted by Florent Dionisi on 2010-11-26T14:55:04Z

Furthermore, trying to logout anyway, if once disable wemail, he will get the following error :
*
NotDefined at /accounts/logout/

Application 'webmail' and/or parameter 'SECRET_KEY' not defined* :

Environment:
Request Method: GET
Request URL: http://localhost:8000/accounts/logout/
Django Version: 1.2.3
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'south',
 'modoboa',
 'modoboa.lib',
 'modoboa.admin',
 'modoboa.userprefs',
 'modoboa.extensions.postfix_autoreply',
 'modoboa.extensions.webmail',
 'modoboa.extensions.stats',
 'modoboa.extensions.amavis_quarantine']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'modoboa.lib.middleware.ExtControlMiddleware')
Traceback:
File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "/home/florent/modoboa/../modoboa/auth/views.py" in dologout
  41.     events.raiseEvent("UserLogout", request=request)
File "/home/florent/modoboa/../modoboa/lib/events.py" in raiseEvent
  67.         callback(**kwargs)
File "/home/florent/modoboa/../modoboa/extensions/webmail/main.py" in userlogout
  99.                       password=kwargs[[request"]session["password]])
File "/home/florent/modoboa/../modoboa/extensions/webmail/lib.py" in +call+
  137.             kwargs[[password"] = decrypt(kwargs["password]])
File "/home/florent/modoboa/../modoboa/extensions/webmail/lib.py" in decrypt
  630.     obj = AES.new(parameters.get_admin("SECRET_KEY"), AES.MODE_ECB)
File "/home/florent/modoboa/../modoboa/lib/parameters.py" in get_admin
  106.     +is_defined(app, "A", name)
File "/home/florent/modoboa/../modoboa/lib/parameters.py" in +is_defined
  34.         raise [[NotDefined]](app, name)
Exception Type: [[NotDefined]] at /accounts/logout/
Exception Value: Application 'webmail' and/or parameter 'SECRET_KEY' not defined
<!-- gh-comment-id:29813540 --> @tonioo commented on GitHub (Dec 4, 2013): **Posted by Florent Dionisi on 2010-11-26T14:55:04Z** Furthermore, trying to logout anyway, if once disable wemail, he will get the following error : * [[NotDefined]] at /accounts/logout/ Application 'webmail' and/or parameter 'SECRET_KEY' not defined\* : <pre> Environment: Request Method: GET Request URL: http://localhost:8000/accounts/logout/ Django Version: 1.2.3 Python Version: 2.6.6 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'south', 'modoboa', 'modoboa.lib', 'modoboa.admin', 'modoboa.userprefs', 'modoboa.extensions.postfix_autoreply', 'modoboa.extensions.webmail', 'modoboa.extensions.stats', 'modoboa.extensions.amavis_quarantine'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'modoboa.lib.middleware.ExtControlMiddleware') Traceback: File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response 100. response = callback(request, *callback_args, **callback_kwargs) File "/home/florent/modoboa/../modoboa/auth/views.py" in dologout 41. events.raiseEvent("UserLogout", request=request) File "/home/florent/modoboa/../modoboa/lib/events.py" in raiseEvent 67. callback(**kwargs) File "/home/florent/modoboa/../modoboa/extensions/webmail/main.py" in userlogout 99. password=kwargs[[request"]session["password]]) File "/home/florent/modoboa/../modoboa/extensions/webmail/lib.py" in +call+ 137. kwargs[[password"] = decrypt(kwargs["password]]) File "/home/florent/modoboa/../modoboa/extensions/webmail/lib.py" in decrypt 630. obj = AES.new(parameters.get_admin("SECRET_KEY"), AES.MODE_ECB) File "/home/florent/modoboa/../modoboa/lib/parameters.py" in get_admin 106. +is_defined(app, "A", name) File "/home/florent/modoboa/../modoboa/lib/parameters.py" in +is_defined 34. raise [[NotDefined]](app, name) Exception Type: [[NotDefined]] at /accounts/logout/ Exception Value: Application 'webmail' and/or parameter 'SECRET_KEY' not defined </pre>
Author
Owner

@tonioo commented on GitHub (Dec 4, 2013):

Posted by Redmine Admin on 2010-11-27T09:34:23Z

In [f748088c704aca2f8691293a9efac742a865e58b]:

#!CommitTicketReference repository="" revision="f748088c704aca2f8691293a9efac742a865e58b"
fixed #93
On [[UserLogout]], the webmail extension tries to get an IMAPconnector object (which tries to connect with an IMAP server). When the configuration is invalid, this operation fails.
Catching exceptions on strategic places has solved the problems.
<!-- gh-comment-id:29813543 --> @tonioo commented on GitHub (Dec 4, 2013): **Posted by Redmine Admin on 2010-11-27T09:34:23Z** In [f748088c704aca2f8691293a9efac742a865e58b]: <pre> #!CommitTicketReference repository="" revision="f748088c704aca2f8691293a9efac742a865e58b" fixed #93 On [[UserLogout]], the webmail extension tries to get an IMAPconnector object (which tries to connect with an IMAP server). When the configuration is invalid, this operation fails. Catching exceptions on strategic places has solved the problems. </pre>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#93
No description provided.