Commit graph

127 commits

Author SHA1 Message Date
682de14630 Split the code into smaller modules
Introduce modules:
- lacre.transport - for actual delivery via SMTP
- lacre.smime - to take care of S/MIME stuff

Implement lacre.transport.SendFrom class that does a almost exactly the same
thing as the original send_msg function, but without using global variable to
store original message sender.
2023-05-08 22:17:02 +02:00
67e6df17fb Move success flag before 'try' 2023-05-08 22:17:02 +02:00
0da169ae61 Log exceptions from failover delivery 2023-05-08 22:17:02 +02:00
f4e21217c2 [simple-filter] Retry delivery recoding text parts 2023-05-08 22:17:02 +02:00
8a42f3fea1 Improve error-handling for simple filter and test relay 2023-05-08 22:17:02 +02:00
86a3e0031b Adjust gpg-mailgate.py script to use SMTPUTF8 policy 2023-05-08 22:17:02 +02:00
2ac26c09ce Simplify code, improve log entries, add comments 2022-10-22 11:23:17 +02:00
8f8d9dc1b6 Rename mailgate.py to core.py 2022-10-22 11:23:04 +02:00
7849c55d9f Extend the daemon skeleton 2022-10-19 18:36:23 +00:00
b198f0c4f4 Fix logging
First initialise logging, then import lacre.mailgate module.  Otherwise,
module's logging quitely initialises its own root logger that doesn't use
configuration provided by the user.

Also: remove unnecessary "global" keywords.
2022-10-19 18:36:23 +00:00
5ffbbec5f0 Rename sort_recipients to deliver_message, remove unused imports 2022-06-11 21:05:27 +02:00
b627fde510 Move gpg-mailgate.py logic to lacre.mailgate module
gpg-mailgate.py script keeps its role, but only needs to call code defined in
lacre.mailgate.
2022-06-11 21:00:42 +02:00
881a8d1756 Add GnuPG encryption support for addresses with delimiters
If a user registers their key for address alice@example.com but receives a
message sent to alice+something@example.com, this message should be encrypted
as well.

- Implement delimiter support for GnuPG encryption.

- Add E2E test case for a clear text message delivered to an address with
delimiter.

- Fix minor bug: wrong configuration parameter was retrieved when logging
information about enc_domain_keymap being active.
2022-06-08 21:20:58 +02:00
c86c620668 Extract delimiter support, add unit tests
Also: fix recursive call to get_cert_for_email.
2022-06-07 22:14:32 +02:00
251e6d1270 Record execution time and log it
After each execution, log an entry with information about total seconds from
the start to the end of execution and the value returned by
time.process_time() function, which returns:

	sum of the kernel and user-space CPU time

according to the documentation.

This feature can be used to collect stats about Lacre performance.
2022-06-02 23:41:14 +02:00
937046eb17 Use CRLF for line-endings
Mail RFCs use CRLF for line endings and it turns out things may break in
strange ways if only LF is used.
2022-06-02 19:56:32 +02:00
65d2a77486 Don't break Content-Type header with LF - part 2 2022-06-02 19:43:27 +02:00
06abbc0edd Don't break Content-Type header with LF 2022-06-02 19:37:06 +02:00
55b58d25bc Use literal separator '@' in sanitize_case_sense 2022-06-01 23:23:51 +02:00
d3b1717290 Extract PGP/INLINE checks, remove unnecessary byte-check 2022-06-01 23:00:05 +02:00
4c6fdc52ec Check mandatory config early, add tests
Also: extend failover logging configuration with file-based handler to make
sure that the user gets _some_ logs even if they do not configure Lacre at
all.
2022-05-31 22:09:10 +02:00
3bcc1151e5 Add E2E case: a user with a key and PGP/MIME configured
- Add a new test input message for a new test identity, test scenario
  configuration and a test key.

- While retrieving message payload, determine charset based on the
  Content-Type header.  When missing, default to UTF-8.

- Use more comprehensible variables names.

- Adjust logging levels.
2022-05-30 00:49:40 +02:00
11b78ce0fb Adjust log entry levels for severe conditions
When Lacre is misconfigured or can't proceed, report WARNING or even ERROR
level messages.
2022-05-13 21:27:50 +02:00
75ccfb0850 Use logging module
- Replace custom logging code with calls to logging module.
- Use logging.config to provide configuration parameters.

To make Lacre's logging more flexible, use fileConfig from logging.config to
set up all parameters.  If the configuration file is missing, use dictConfig
with hardcoded reasonable defaults.
2022-05-06 19:39:56 +02:00
baf7954270 Use list booleanness instead of comparing with empty list 2022-05-06 19:39:56 +02:00
031c7234f6 Reorder top-level expressions 2022-05-06 19:39:56 +02:00
d90b50f7e7 Extract config, separate logging, split into smaller functions
- Move configuration-processing code to a separate module (lacre.config) and
  provide a simple API to access configuration parameters.
- Prepare to use builtin logging module to log diagnostic data.
- Rework the configuration-processing file to make it cleaner.
- Log additional information while processing configuration.
- Reorder functions.
2022-05-06 19:39:56 +02:00
59b932abaa Remove support for decrypting emails 2022-03-08 22:42:13 +01:00
c4927d2722 Avoid unnecessary list creation 2022-02-06 00:29:35 +01:00
1e7d33c1df Handle bytes properly
Fix bytes sequences handling after auto-migration.
2022-01-10 18:21:53 +01:00
b2a01c15b0 Fix auto-migrated code
- Use b'' (byte strings) where appropriate.

- Fix indentation.

- Replace python2.x references with python3.x.
2022-01-10 18:21:40 +01:00
5f02223ec7 Perform automatic migration to Python 3.x
Use lib2to3 automatic migration tool provided by Python 2.x to convert
codebase to new idioms.

Command line:

find . -type f -name '*.py' \
    -exec python2.7 -m lib2to3 \
    -f all -f idioms -f buffer -f set_literal -f ws_comma -w \
    '{}' '+'
2022-01-10 18:21:20 +01:00
7a063a91b8 Polish E2E testing script and make it configurable 2021-11-09 21:25:41 +01:00
Mukesh Sai Kumar
0b92307b23
Added starttls support for SMTP 2019-05-24 23:20:34 +05:30
TheGreatGooo
29f902b27c Fix bug
Content type not passed to encrypted submime causing bug where is only html is sent for example, the email client will not decode the html before displaying the email.
2017-09-09 11:53:00 -04:00
TheGreatGooo
ba0953a372 Update gpg-mailgate.py
decode payload before encryption
2016-04-21 10:29:22 -04:00
TheGreatGooo
bb4d267785 Update gpg-mailgate.py
fixed issue with Content-Transfer-Encoding during encryption
2016-04-20 20:44:56 -04:00
fkrone
24cfe01d95 Fixing stupid bug with non existing variable. Copy & paste fail. Finding a default key for recipient in domain keymap crashed mailgate. 2015-06-04 19:04:27 +02:00
fkrone
0de0d6a1b1 Critical bugfix: Under some circumstances a mail which should be encrypted with PGP/MIME was not encrypted if at least one attachment ot the body itself contained the PGP-tags. 2015-06-04 16:45:22 +02:00
fkrone
4b7a187ac3 Forgot to change this value from a debug one to the real value 2015-05-29 23:15:05 +02:00
fkrone
11f70fb241 Added possibility to define a regex for finding recipients to decrypt for and also adding possibility to use default keys for domain ranges 2015-05-29 23:13:05 +02:00
fkrone
5fdbabc3b3 Disable PGP/INLINE decryption by default. It does work, however, it has some drawbacks (e.g. content type for files getting lost). 2015-05-25 22:49:42 +02:00
fkrone
2c0e342e5e Support for decrypting PGP encrypted mails. However, it has some drawbacks and might cause some security issues. So before using it please read carefully through the installation instructions. 2015-05-25 20:24:37 +02:00
fkrone
6a7dda969b Bugfix: The mailgate crashes with certain settings when mail is delivered locally 2015-05-25 00:28:55 +02:00
fkrone
4283c7ef4d Prefere keys in keymap over keys in keyring. Could be useful if you have a recipient with two keys. 2015-03-29 18:16:58 +02:00
fkrone
dbb65bbf7f Bugfix: Missed return code for failed PGP encryption in log message 2015-03-16 14:58:01 +01:00
fkrone
600b57e6ef Bugfix: Handle multipart messages and especially nested multipart messages correct and not mess up them 2015-03-14 21:52:33 +01:00
fkrone
46730ba8e6 Bugfix: Avoid nested encryptions of any kind 2015-03-02 21:01:05 +01:00
fkrone
a766a9bd4a Refactored code (and also optimizing code).
Changes while refactoring: The gateway now handles mail addresses case sensitivity compitable to RFC 2821 as default.
2015-03-02 13:13:30 +01:00
fkrone
7934dc00db Little bugfix for PGP/INLINE: Make it working again by stop calling non existing method
Bugfix for PGP/MIME: Make it compatible to RFC 3156 (MIME Security with OpenPGP) when using mails with attachments
2015-02-22 14:19:11 +01:00