Commit Graph

1569 Commits

Author SHA1 Message Date
Nicolas Sebrecht 6e837c614d v7.3.4
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2021-08-03 01:07:23 +02:00
Rodolfo García Peñas (kix) 595b814074 ui init is lintian clean
This patch only adds an space between the hash and the first character.

Backported from:
a88a9cf28e

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-08-29 23:23:28 +02:00
Rodolfo García Peñas (kix) 2722234d16 threadutil imports not used
These imports are not used.

Backported from:
a655fa4fc2

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-08-29 23:23:28 +02:00
Rodolfo García Peñas (kix) 3d925b006a Changed wrong comparison equal
Backported from:
e84e932df4

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-08-29 22:54:15 +02:00
Rodolfo García Peñas (kix) c7cb68ad7f Comparison error
Backported from:
75ce6e71f3

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-08-29 22:53:16 +02:00
Reto Schnyder f6935342c2 Fix hooks for IDLE sync
`presynchook` and `postsynchook` for IDLE-triggered syncs were broken by
da69fd8. This fixes them.

Signed-off-by: Reto Schnyder <reto.a.schnyder@bluewin.ch>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-08-22 01:54:48 +02:00
Nicolas Sebrecht 21332efb08 folder: IMAP: fix issue when the response of searchforheaders is the same UID multiple times
When the IMAP server doesn't support the UIDPLUS extension so we fallback on the
internal legacy way of mapping the UID to the uploaded message (with the email
header). If the server responds with 2 UIDs offlineimap doesn't know which one
is correct and reports an error.

If for some reason all the returned UIDs are equals it's very likely fine to
map either one.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Tested-by: https://github.com/mpsq
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/676
2020-07-22 22:31:01 +02:00
Martin Di Paola 8599cab2ab Move out pkg attributes from __init__.py
The setup.py uses the version, author and others attributes as metadata
for the python package.

The setup read them from offlineimap/__init__.py doing an import of the
module first.

Unfortunately the import also try to import all the dependencies of
offlineimap which may not be installed by the time. See #661.

Moving out the attributes in a separated module allows to be imported by
setup.py whitout needing to import the whole offlineimap.

The import of test.OLItest has the same limitation. In this case the
import was delayed until the real test case run is executed avoiding
again loading offlineimap from the begin.

Signed-off-by: Martin Di Paola <martinp.dipaola@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-04-22 15:51:13 +02:00
Nicolas Sebrecht 7531ac4640 v7.3.3
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-04-11 01:09:25 +02:00
Herton R. Krzesinski 6a25f1930c Fix stale gss api authentication security context
Inside __authn_gssapi function, the else clause is never executed
because the return statement in the try section, which means if there is
an error and a reconnect is tried, the authentication will now fail with
due the stale self.gss_vc value. For example, offlineimap will be
stuck after any socket error and unable to reconnect, even if I have a
valid kerberos ticket:

========================================================================
abort: command: FETCH => socket error: <type 'exceptions.IOError'> - Too many read 0

  command: FETCH => socket error: <type 'exceptions.IOError'> - Too many read 0
 GSSAPI authentication failed: AUTHENTICATE command error: BAD ['AUTHENTICATE aborted']. Data: BLMC2 AUTHENTICATE GSSAPI

Enter password for user 'XXX':
========================================================================

You can verify this try..finally behaviour with this slightly modified
example that I copied from python documentation:

>>> def divide(x, y):
...     try:
...         result = x / y
...         return 1
...     except ZeroDivisionError:
...         print("division by zero!")
...     else:
...         print("result is", result)
...     finally:
...         print("executing finally clause")
...
>>> divide(2, 1)
executing finally clause
1
>>>

The else section is never executed with a return inside try.

To fix the issue here, instead of relying on else clause, just clear
gss_vc always inside finally, and we don't need to handle any exception
to set self.gssapi, it can be left False by default and just set to True
after authentication is done.

I'm running with this fix and now offlineimap doesn't stop requiring manual
intervention, and succesfully re-authenticate after errors while fetching
data.

Signed-off-by: Herton R. Krzesinski <herton@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-04-11 01:01:44 +02:00
Frank LENORMAND da69fd81ed export env. variables when running account hooks
This commit allows account hooks (pre/post sync) to access contextual
information:

* `OIMAP_ACCOUNT_NAME`: name of the account being synchronized
* `OIMAP_HOOK_NAME`: name of the hook being run (one of `postsynchook`, `presynchook`)

These variables allow using the same hook program (e.g. a script) for
all account synchronisation operations, and running different commands
depending on the stage of the synchronisation or the target account.

Signed-off-by: Frank LENORMAND <lenormf@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-03-23 23:01:30 +01:00
martin f. krafft 4562b1c5d1 exec() the tunnel command
There is no reason that the shell invoking the tunnel command needs to stay
around. Using `exec` to replace the parent with the tunnel command works just
fine and results in a cleaner process table.

Sent-by: martin f. krafft <madduck@madduck.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-03-22 09:02:41 +01:00
Chris Coleman 84efb45270 Handle [ALREADYEXISTS] and Mailbox already exists!
Make compatible with IMAP servers that give the reason code "[ALREADYEXISTS]"
and IMAP servers that give natural language reason "Mailbox already exists!" by
searching for the two words "already" and "exists" in the exception reason
string.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-02-06 19:10:33 +01:00
Nicolas Sebrecht 564930725e v7.3.2
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-12-17 20:01:18 +01:00
Nicolas Sebrecht 1e4990524e Revert "fix check for unsupported sep character"
This reverts commit 4208fd4a15.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-12-17 19:58:53 +01:00
Nicolas Sebrecht f6e08b8609 v7.3.1
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-12-15 23:51:24 +01:00
Chris Coutinho 403ddf9c1c Additional address for sysloghandler to handle mac
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-10-12 19:58:44 +02:00
Nicolas Sebrecht 4208fd4a15 fix check for unsupported sep character
Introduced by 6b28071 but could not work.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-10-04 00:00:32 +02:00
Nicolas Sebrecht ba4ecea9e4 v7.3.0
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-08-19 19:17:53 +02:00
Nicolas Sebrecht 9c6a1760b4 imaplib2 v2.101
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-18 23:50:29 +02:00
Ilias Tsitsimpis beaaf77a1a Do not use TIMEOUT_MAX for Condition.wait()
On some architectures, using threading.TIMEOUT_MAX for the timeout
parameter can overflow causing Condition.wait() to return immediately.
Instead of relying on TIMEOUT_MAX, remove it and wait forever.

Signed-off-by: Ilias Tsitsimpis <iliastsi@debian.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-18 23:16:04 +02:00
Julien Cristau 0a831b3cab Use SSLContext if available so we send SNI
Fixes https://github.com/imaplib2/imaplib2/issues/5

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-18 23:13:35 +02:00
Nicolas Sebrecht 741b33b455 imaplib2 v2.100
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-18 23:10:21 +02:00
Ben Cotterell 8d5b22bd09 Don't expect trailing space on command completion
While trying to see why I couldn't get my emails from an Exchange server
I found this:

[imap]: 41:31.42 someserver.com handler _put_response(IOMC1 OK)
[imap]: 41:31.42 someserver.com handler unexpected response: 'IOMC1 OK'

And shortly after that the connection was closed. IOMC1 is just the
unique tag for the session.

The pattern looks for the tag, a number, a word like "OK" or something,
*then a space*, then optionally some data.

If the data aren't there it shouldn't be expecting a space.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-18 23:04:26 +02:00
Olivier Mehani 0d5496ba0a implement Happy Eyeballs
This allows OfflineIMAP to not stall on malfunctional IPv6 connections,
and fall-back to a functional IPv4 connection, if faster, as described
in RFC6555.

Signed-off-by: Olivier Mehani <shtrom@ssji.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-10 14:36:53 +02:00
Nicolas Sebrecht 06ed00a211 v7.2.4
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-08 11:32:57 +02:00
Nicolas Sebrecht 801893cc73 make portalocker really optional
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-04-27 14:56:17 +02:00
kimim 2806f40071 use portable locker to support cygwin in Windows
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-04-27 14:37:44 +02:00
Nicolas Sebrecht 0d865c2e36 repository/IMAP: update copyright header date
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-02-27 08:48:59 +01:00
Kyle Altendorf 57a43f5bba mkdir -p alike folder creation
When creating a folder in one command on Gmail you end up with
one tag such as 'x/y/z' instead of three nested tags such as 'z'
inside of 'y' inside of 'x'.  Creating each layer individually
results in the desired nested label structure.

This was tested in a personal transfer of email from a remote
IMAP server to Gmail.

OfflineIMAP/offlineimap#335
OfflineIMAP/offlineimap#598

Signed-off-by: Kyle Altendorf <sda@fstab.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-02-27 08:45:57 +01:00
Nicolas Sebrecht 5c735fd327 v7.2.3
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-02-17 00:31:19 +01:00
Mart Lubbers c9f71b0c64 add checks in curses ui for small windows
addch() and addstr() throw an exception if text has to be printed
outside of the window. This may occur if the terminal is very small.
Such erroneous prints are no-ops now.

Signed-off-by: Mart Lubbers <mart@martlubbers.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/595
2019-02-13 16:32:02 +01:00
Nicolas Sebrecht 137130fbd0 v7.2.2
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-12-22 18:46:34 +01:00
Robbie Harwood 096aa07650 Handle empty token with complete GSSAPI context
This fixes a potential traceback when we try to unwrap(None).

Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-12-14 21:28:30 +01:00
Nicolas Sebrecht a51064e83a maxage: always compute the remote cache list for min_uid
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/581
Tested-by: https://github.com/ianbrody
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-12-11 09:29:37 +01:00
Frode Aannevik 8692799e65 Fix expired oauth2_access_token
Use `expires_in` from the oauth2 response
to reset the oauth2_access_token before
it expires

divides the `expires_in` by 2 to ensure
the access_token is cleared before it
expires

ref: https://github.com/OfflineIMAP/offlineimap/issues/536

Signed-off-by: Frode Aannevik <frode.aa@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-11-18 21:07:54 +01:00
Philippe Loctaux af3a35ae30 offlineimap/utilis/distro.py: identation fix
Fixed a indentation style.

Signed-off-by: Philippe Loctaux <loctauxphilippe@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-08-17 18:49:04 +02:00
Philippe Loctaux 761e10e8b1 Add Archlinux to list of supported distros
There is a bug with `platform.linux_distribution()`, which returns an
empty value on Archlinux with python2.

This bug is fixed in python3, but *will not* be fixed in python2.

This patch fixes that issue with a dirty hack: on archlinux, there is a
file that can be used to detect an archlinux machine. that file is
`/etc/arch-release`. if the file exists, then the OS variable will be
set to "linux-arch".

You can learn more about that issue on the python bug platform:
https://bugs.python.org/issue20454

Signed-off-by: Philippe Loctaux <loctauxphilippe@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-08-17 18:49:04 +02:00
Nicolas Sebrecht d9301254ff fix dates in copyright lines
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-08-13 01:15:01 +02:00
Philippe Loctaux 2890dec37f Added ssl certfile on osx for openssl pacakge on homebrew
A certfile was already specified for osx but only with MacPorts,
this patch adds the certfile given with the package `openssl` with
homebrew.

You can get more info with the command `brew info openssl` on osx with
homebrew and openssl installed.

Signed-off-by: Philippe Loctaux <loctauxphilippe@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-08-10 12:48:17 +02:00
Philippe Loctaux 7af4728d62 Add Archlinux to list of supported distros
get_os_name returns linux-arch on Archlinux, so add a line for linux-arch to __DEF_OS_LOCATIONS.

Signed-off-by: Philippe Loctaux <loctauxphilippe@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-08-10 12:42:29 +02:00
Benedikt Heine ce9a1981c1 Chain tls_level and ssl_version only if ssl is enabled
If the tls_level is set to a cipherset other than tls_compat, the
ssl cipherset has to get specified extra, if ssl is used.

But if the user explicitly disabled SSL, and set tls_level to anything
else than tls_compat required the user to explicitly set ssl_version,
which is contradicting.

Signed-off-by: Benedikt Heine <bebe@bebehei.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-07-02 18:44:08 +02:00
Benedikt Heine d3ba837900 Fix typo in exception message
Signed-off-by: Benedikt Heine <bebe@bebehei.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-07-02 18:44:08 +02:00
Carnë Draug c9005cd4ff Check if username is provided before trying plain authentication.
If the username value is not provided on the configuration file, then
username if of NoneType and NULL.join will bomb since Nones can't be
joined with strings.  So check if username is empty and raise an
exception if so.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/558
Signed-off-by: David Miguel Susano Pinto <carandraug+dev@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-06-16 15:17:35 +02:00
Carnë Draug 5f9474e10d Print username instead of accountname when asking for password
When asking for a password interactively, the username is never
displayed which may hide problems (typos on the configuration, or
issues on offlineimap parsing of the config file).  The hostname,
port, and account name are already displayed when establishing the
connection.  When asking for password, the account name is displayed
again.  Change it to display the username.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/558
Signed-off-by: David Miguel Susano Pinto <carandraug+dev@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-06-16 15:17:35 +02:00
Nicolas Sebrecht 11313a9b9c v7.2.1
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-06-16 15:08:07 +02:00
Nicolas Sebrecht b5ffa1c163 imapserver: fix copyright line
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-06-07 18:39:08 +02:00
Robbie Harwood 17cfb63db6 Pass username through in GSSAPI connections
Fix bug in GSSAPI auth where the username was not being negotiated.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/541
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Tested-by: Frank Lenormand <lenormf@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-06-07 18:36:58 +02:00
Nicolas Sebrecht fc61c6fd30 Gmail: allow parenthesis in labels
Reported-by Heinrich Hartmann <Heinrich@HeinrichHartmann.com>
Tested-by Heinrich Hartmann <Heinrich@HeinrichHartmann.com>
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/545
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-05-18 02:10:56 +02:00
Nicolas Sebrecht 356bd0b78f Merge branch 'fingerprint-colons' into next
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-05-15 00:41:22 +02:00