Commit Graph

563 Commits

Author SHA1 Message Date
Georg Lauterbach 3b8059f2da
make setup.sh completely non-interactive (#2201)
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2021-09-21 08:51:59 +02:00
Brennan Kinney f4f0e4ef61
tests: Refactored bounced spam test + Introduce common container setup template (#2198)
* fix: Spam bounced test copy/paste typo
* tests(docs): Expand inline documentation

Should assist maintainers like myself that are not yet familiar with this functionality, saving some time :)

* Refactor bounced test + Introduce initial container template

DRY'd up the test and extracted a common init pattern for other tests to adopt in future.

The test does not need to run distinct containers at once, so a common name is fine, although the `init_with_defaults()` method could be given an arg to add a suffix: `init_with_defaults "_${BATS_TEST_NUMBER}"` which could be called in `setup()` for tests that can benefit from being run in parallel.

Often it seems the containers only need the bare minimum config such as accounts provided to actually make the container happy to perform a test, so sharing a `:ro` config mount is fine, or in future this could be better addressed.

---

The test would fail if the test cases requiring smtp access ran before postfix was ready (_only a few seconds after setup scripts announce being done_). Added the wait condition for smtp, took a while to track that failure down.
2021-09-20 19:35:03 +12:00
Brennan Kinney c851f5b6aa
fix: Remove `mkcert.sh` usage + `_setup_ssl` refactor. (#2196)
* chore(refactor): DRY up the `_setup_ssl` method

- `/etc/postfix/ssl` was a bit misleading in usage here. As a maintainer (of my own contribution!) I was confused why only `/etc/postfix/ssl` was referenced and not `/etc/dovecot/ssl`.
- The postfix specific path is unnecessary, dovecot was referencing it via it's config, the same can be done from postfix to a generic DMS specific config location instead.
- This location is defined and created early as `/etc/dms/tls` (with var `DMS_TLS_PATH`). All usage of `/etc/postfix/ssl` has been replaced, making it easier to grok. Several `mkdir` commands related to this have been dropped as a result.

- Likewise, a related `TMP_DMS_TLS_PATH` var provides a reference to the config volume path `/tmp/docker-mailserver` which is used for conditions on presently hard-coded paths.

- Other values that benefit from being DRY have been lifted up into vars. Definitely easier to follow now and makes some further opportunities clearer to tackle in a future refactor.

- `chmod` has been updated where appropriate. Public key/cert is acceptable to have as readable by non-root users (644). The custom type with single fullchain file was not root accessible only, but should as it contains a private key.
- That said, the security benefit can be a bit moot due to source files that were copied remain present, the user would be responsible to ensure similar permissions on their source files.

- I've not touched LetsEncrypt section as I don't have time to investigate into that yet (not familiar with that portion).

---

* chore: Remove mkcert logic and dovecot cert

- No longer serving a purpose.
- Our own TLS startup script handles a variety of cert scenarios, while the dropped code was always generating a self-signed cert and persisting an unused cert regardless with `ONE_DIR=1`.
- To avoid similar issues that DH params had with doveadm validating filepath values in the SSL config, the default dummy values match postfix pointing to "snakeoil" cert. That serves the same purpose as mkcert was covering in the image.
- Bonus, no more hassle with differing mkcert target paths for users replacing our supplied Dovecot with the latest community edition.

---

* Error handling for SSL_TYPE

- Added a panic utility to exit early when SSL_TYPE conditions are misconfigured.
- Some info text had order of key/cert occurrence swapped to be consistent with key then cert.
- Some existing comments moved and rephrased.
- Additional comments added.
- `-f` test for cert files instead of `-e` (true also for directories/devices/symlinks).
- _notify messages lifted out of conditionals so that they always output when the case is hit.
- ~~Empty SSL_TYPE collapsed into catch all panic, while it's contents is now mapped to a new 'disabled' value.~~

---

* Use sedfile + improve sed expressions + update case style

- Uses sedfile when appropriate (file change intentional, not optional match/check).
- sed expressions modified to be DRY and reduce escaping via `-r` flag (acceptable if actual text content contains no `?`,`+`,`()` or `{}` characters, [otherwise they must be escaped](https://www.gnu.org/software/sed/manual/html_node/Extended-regexps.html)).
- sed captures anything matched between the parenthesis`()` and inserts it via `\1` as part of the replacement.

- case statements adopt the `(` prefix, adopting recent shell style for consistency.

---

* Refactor SSL_TYPE=disabled

- Postfix is also disabled now.
- Included heavy inline documentation reference for maintainers.
- Dropped an obsolete postfix config option 'use_tls' on the relayhost function, it was replaced by 'security_level'.

---

* I'm a friggin' sed wizard now

- The `modern` TLS_LEVEL is the default values for the configs they modify. As such, `sedfile` outputs an "Error" which isn't an actual concern, back to regular `sed`.

- I realized that multiple edits for the same file can all be done at once via `-e` (assuming other sed options are the same for each operation), and that `g` suffix is global scope for single line match, not whole file (default as sed iterates through individual lines).

- Some postfix replacements have `smtp` and `smtpd` lines, collapsed into a single `smtpd?` instead now that I know sed better.

---

* tests(fix): Tests that require SSL/TLS to pass

- SSL_TYPE=snakeoil added as temporary workaround.

- nmap tests are being dropped. These were added about 4-5 years ago, I have since made these redundant with the `testssl.sh` tests.
- Additionally the `--link` option is deprecated and IIRC these grades were a bit misleading when I initially used nmap in my own TLS cipher suite update PRs in the past.
- The removed SSL test is already handled in mail_ssl_manual.bats

ldap test:
- Replace `--link` alias option with `--network` and alias assignment.
- Parameterized some values and added the `SSL_TYPE` to resolve the starttls test failure.

privacy test:
- Also needed `SSL_TYPE` to pass the starttls test.

`tests.bats` had another starttls test for imap:
- Workaround for now is to give the main test container `SSL_TYPE=snakeoil`.

---

* Remove the expired lets-encrypt cert

This expired in March 2021. It was originally required when first added back in 2016 as LetsEncrypt was fairly new and not as broadly accepted into OS trust stores.

No longer the case today.

---

* chore: Housekeeping

Not required for this PR branch, little bit of tidying up while working on these two test files.

- privacy test copied over content when extracted from `tests.bats` that isn't relevant.
- ldap test was not as easy to identify the source of DOVECOT_TLS. Added comment to make the prefix connection to `configomat.sh` and `.ext` files more easier to find.
- Additionally converted the two localhost FQDN to vars.

---

* Default SSL_TYPE becomes `''` (aka equivalent to desired `disabled` case)

- This is to prevent other tests from failing by hitting the panic catchall case.
- More ideal would be adjusting tests to default to `disabled`, rather than treating `disabled` as an empty / unset SSL_TYPE value.

---

* Add inline documentation for `dms_panic`

- This could later be better formatted and placed into contributor docs.

Panic with kill (shutdown) not exit (errex):
- `kill 1` from `_shutdown` will send SIGTERM signal to PID 1 (init process).
- `exit 1` within the `start-mailserver.sh` init scripts context, will just exit the initialization script leaving the container running when it shouldn't.

The two previous `_shutdown` methods can benefit from using `dms_panic` wrapper instead to standardize on panic messages.
2021-09-20 00:31:11 +12:00
Brennan Kinney 08cd4d3371
fix: Enable DH parameters (ffdhe4096) by default (#2192)
This feature was originally introduced by the PR: https://github.com/docker-mailserver/docker-mailserver/pull/1463

- Assign default DH params to use via Dockerfile build instead of copy and update at runtime.
- Parameterized service names and paths.
- Refactor postfix and dovecot dh methods to wrap shared dh logic
- I don't see any value in checking the alternative service for dh params file to copy over, so that's now dropped too.
- Another conditional check is dropped and the default fallback message for existing DH params file is no longer relevant.
- Improved the remaining `_notify` messages. Collapsing the warning into a single logged message also seemed relevant.
- There is no apparent need for special handling with `ONE_DIR=1`. Dropped it.

- Refactor DH params  tests
- Combine custom and default DH param tests into single test file
- docs: Add instructions to use custom DH params

There is no official documented support for custom DH parameters. As no guarantee is provided, this is considered an internal change, not a breaking one.
2021-09-15 20:28:04 +12:00
Nathan Pierce be35d9bef1
Lock file create and remove improvements (#2183)
* changed the locking function to better support multiple servers running at once and sharing the same config

* helper function testing now runs inside of container

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2021-09-13 20:09:01 +12:00
Georg Lauterbach c7e4981945
Move setup process via script into container (#2174)
Decoupling setup process from `setup.sh` script by introducing a setup script _inside_ the container that coordinates the setup process.

**This is not a breaking change**. This way, we do not have to keep track of versions of `setup.sh`.

This change brings the additional benefit for Kubernetes users to be able to make use of `setup` now, without the need for `setup.sh`.

---

* move setup process into container; setup.sh versioning not needed anymore

* add tilde functionality to docs

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
Co-authored-by: Casper <casperklein@users.noreply.github.com>
2021-09-12 11:29:02 +12:00
Nathan Pierce c267d8a990
HOSTNAME and DOMAINNAME setting improvements (#2175)
Centralize the collection of the HOSTNAME and DOMAINAME so that it's predictable and uniform across the various scripts (using the helper). Ensure it supports the various configurations users can have (both subdomain and without subdomain, override and no override).

---

* using _obtain_hostname_and_domainname helper + covers when not a subdomain
doc: OVERRIDE_HOSTNAME takes priority

* added tests for non-subdomain hostname + further improvements

* moved SRS DOMAINANME tests into hostname test file + Allowing DOMAINNAME ENV to override what would be automatically set

---

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2021-09-12 02:20:16 +12:00
Georg Lauterbach 8e91251d8c
follow up on #2177 with @polarathene's suggestions (#2180) 2021-09-12 00:43:42 +12:00
Georg Lauterbach 88773262d8
Skip non-deterministic tests until they've been debugged (#2177) 2021-09-11 11:30:01 +02:00
Nathan Pierce 0da66ccb34
setup.sh: docker_container first, then fall back to docker_image (#2134)
* docker_container first, then fall back to docker_image
+ test changes to support
+ test change to wait for smtp port to fix flakey tests since https://github.com/docker-mailserver/docker-mailserver/pull/2104

* quick fix

* Update setup.sh

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
Co-authored-by: Casper <casperklein@users.noreply.github.com>
2021-09-06 10:13:12 +00:00
Nathan Pierce dff7e428c0 Revert "check-for-changes: performance improvements + wait for settle (#2104)"
This reverts commit 232d463b81.
2021-08-28 19:16:34 -04:00
Nathan Pierce 232d463b81
check-for-changes: performance improvements + wait for settle (#2104) 2021-08-16 09:21:29 +02:00
Nathan Pierce 0e40f733f3
upgrading bats to 1.4.1 (#2095) 2021-07-25 18:58:33 +02:00
Nathan Pierce 5becce8064
chore(scripts): Removing flock so NFS works (#1980)
Co-authored-by: Casper <casperklein@users.noreply.github.com>
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2021-06-15 14:03:41 +02:00
Georg Lauterbach e7b88d865b
cleaned up >/dev/nulls in Dockerfile and replaced em dashes with normal dashes (#2024) 2021-06-08 13:20:20 +12:00
Nathan Pierce 543bd8b16b
MacOS linting & testing support + docs (#2001) 2021-06-07 14:58:34 +02:00
Georg Lauterbach abdf681d02
chore(ci): Linting Improved (#2000) 2021-06-01 18:12:17 +02:00
Moritz Marquardt 66bc157c1d
fix!: Allow protocol in SASLAUTHD_LDAP_SERVER & adjust SASLAUTHD_LDAP_ default values (#1989)
* fix: make sure the SASLAUTHD_LDAP_HOST/PROTO logic makes sense and use LDAP_SERVER_HOST as a fallback (#1983)

* chore(docs): document changes to LDAP/SASLAUTHD as of #1983

* fix!: apply default value modifications suggested in #1983

https://github.com/docker-mailserver/docker-mailserver/issues/1983#issuecomment-844848224

* chore(test): Test SASLAUTHD_LDAP_SERVER with protocol and ..._SSL=0, as well as with default bind credentials

Note that there are currently no regression tests for this as there's only one setup_file, so that would require big changes to the testing methodology.

* refactor!: completely remove SASLAUTHD_LDAP_SSL and SASLAUTHD_LDAP_PROTO

Co-authored-by: Georg Lauterbach <44545919+aendeavor@users.noreply.github.com>
Co-authored-by: Frederic Werner <20406381+wernerfred@users.noreply.github.com>
2021-05-22 22:52:56 +02:00
Georg Lauterbach 75e74e4a19
introduce F2B v0.11 (#1965) 2021-05-15 11:11:10 +02:00
Georg Lauterbach 04e98dc49f
introduce variable to control Amavis' loglevel (#1947) 2021-05-06 23:51:45 +02:00
Moritz Marquardt 94b5ac49c1
fix!: use dovecot's LDAP uris option instead of hosts (#1901)
* Use dovecot's LDAP uris option instead of hosts (fixes #1510)

* Clean up variables & environment documentation for #1901

Co-authored-by: Frederic Werner <20406381+wernerfred@users.noreply.github.com>
Co-authored-by: Georg Lauterbach <44545919+aendeavor@users.noreply.github.com>
2021-04-19 09:02:03 +02:00
Casper f7836c8b1a
Fail2Ban block behaviour (#1914)
* new default: block IP on all ports

* introduce FAIL2BAN_BLOCKTYPE

* fix test

* tests added

* test added

* test blocktype drop

* merged two tests
2021-04-18 12:55:43 +02:00
Moritz Marquardt 271d94a37e
Add LDAP_QUERY_FILTER_SENDERS setting for spoof protection with LDAP (#1902) 2021-04-17 22:40:19 +02:00
Casper dea9bca900
Enhance setup.sh email list (#1898)
* add quota and aliases to output

* shellcheck fixes

* fix test

Co-authored-by: Georg Lauterbach <44545919+aendeavor@users.noreply.github.com>
2021-04-12 15:18:15 +02:00
Casper ba0f9199b7
fail2ban cleanup (#1895) 2021-04-11 15:33:39 +00:00
Georg Lauterbach 0fa5c1ef9d
revamping the notify function (#1836) 2021-02-24 17:28:59 +01:00
Georg Lauterbach c881facbd2
start-mailserver.sh split (#1820)
* splitting start-mailserver.sh

* refactoring part 2

* refactored setup-stack.sh
* stzarted adjusting target/bin/*.sh to use new usage format

* corrected lowercase-uppercase test error

* better handling of .bashrc variable export

* linting tests and fix for default assignements

* last stylistic changes and rebase
2021-02-23 20:03:01 +01:00
Andreas Perhab 9df60f62ce linting: use local scripts to remove sudo need
install linting tools locally to remove the need for
sudo curling scripts and installing them for all users
2021-02-23 14:45:06 +01:00
Brennan Kinney d02ebc922c
Dual certificate support (eg ECDSA with RSA fallback) (#1801)
* feat: Change Postfix smtpd_tls key and cert files to chain_files

Since Postfix 3.4, `smtpd_tls_cert_file` and `smtpd_tls_key_file` have been deprecated in favor of `smtpd_tls_chain_files` which supports a list of values where a single or sequence of file paths provide a private key followed by it's certificate chain.

* feat: Dual certificate support

`smtpd_tls_chain_files` allows for multiple key+cert bundles so that you can provide different key types, such as ECDSA and RSA.

To maintain compatibility with the current CERT/KEY ENV vars only a 2nd certificate is supported.

Since Dovecot 2.2.31 a related feature is also available, but it is limited to only providing one alternative certificate via separate cert and key settings.

---

This feature enables support for multiple certificates, eg for serving modern ECDSA certs with RSA as fallback.

* chore: Refactor variable names to meet style guide

Improved some comments too.

* chore: Have function definitions respect style guide

* chore: Minor edits to comments

* chore: Expand on comments for maintenance, alert of insecure config

When `SSL_TYPE` isn't properly setup, we're still offering SSL connections but not warning in logs about the insecurity of such, or why a misconfiguration may have occurred.

This commit more clearly communicates to the user that they should look into the issue before considering deploying to production.

The `TODO` comments communicate to any future maintainer to consider treating these improper configs as disabling TLS instead.

* fix: Use `snakeoil` cert

I mistakenly thought this was placeholder text, which broke some tests. This adds the two files in the correct order (private key followed by cert/chain), to fix that issue.

* fix: Disable alt cert for Dovecot if necessary

Certain scenarios may persist state of previously configured alt cert via ENV vars that are removed from a future run. If the config is not reset to original immutable state, this will correctly disable the config from using alt cert unintentionally.

* fix: Satisfy ShellCheck lint

By switching from string var to array / list expansion, this better stores the extracted result and applies it in a manner that ShellCheck linting approves, removing the need to disable the rule.

* feat: Support dual cert test

Few tweaks to the test script allows re-purposing it for covering dual cert support as well.

* chore: Rearranged cert and key lines

A little reorganization, mostly placing private key ahead of related cert lines.

* chore: Refactor `_set_certificate`

This should make the parameters a little less confusing.

Previously was 3 parameters, but the Postfix parameter (1st) may look like two variables if you don't pay attention to the surrounding quotes; while the Dovecot parameters (2nd + 3rd) would have an opposing order. There was also a variant where the `FULLKEYCHAIN` var was passed in three times.

Now it's two params, with the 2nd param as an optional one. If the 2nd param is provided, then the two params are in the order of private key then certificate, otherwise if only a single parameter it's a single PEM file with the full cert chain and private key bundled.

This avoids implying that Postfix and Dovecot might use different files.

* chore: Document current state of `SSL_TYPE` logic better

Inlined for the benefit of anyone else maintaining this section if I'm unable to address the concerns within my own time.

* docs: ENV vars

`TLS_LEVEL=old` isn't in the codebase anymore, not likely to be relevant to retain.

No point in documenting what is considered invalid / unsupported config value in the first place for `SSL_TYPE`.

`SSL_TYPE=manual` was missing documentation for both related file path ENV vars, they've been added along with their alt fallback variants.

* chore: Update Dovecot LMTP SSL test config

Not sure how relevant this is, the file isn't complete sync with the main dovecot `10-ssl.conf` config, adding the support just in case.

* chore: Rename `FULLKEYCHAIN` to avoid confusion

There doesn't appear to be a standardized name for this type of file bundle, and `keychain` may be misleading (fullkeychain often provides macOS keychain  results on search engines).

Opting for a more explicit `KEY_WITH_FULLCHAIN` name instead.

* fix: Invalid var name

`_set_certificate` refactor commit accidentally changed a var name and committed that breaking the dual cert support (thanks tests!).

* test: Refactor `mail_ssl_manual.bats`

Proper test return values instead of `wc -l` based checking.

Tests with dual cert support active, tests that feature (to better detect failure case.

Third test case was unable to verify new self-signed certificate, added new certs signed with self-signed root CA.

Adjusted openssl `CApath` parameter to use `CAfile` instead as `letsencrypt` cert was replaced thus CA cert is missing from the system trust store.

* test: Properly check for files in `mail_ssl_manual.bats`

Fixes lint error.

Also realized I was accidentally asserting a file exists in the test environment, not within the container.

Resolved that and also added an additional test case to ensure the ENV var files are valid when passed in, in the event a change misconfigures them and that the issue is identified earlier.

* chore: Apply PR review feedback

Better format some strings that had mixed quotes when they weren't necessary.

Additionally DRYed up the config path for Postfix and Dovecot within the `_setup_ssl` method.

Co-authored-by: Georg Lauterbach <infrastructure@itbsd.com>
2021-02-21 23:43:41 +01:00
Astro a7ecb0ea8b
feat/enable custom dkim selector (#1811)
* let dkim generator accept selector as parameter

* test dkim-generator with selector parameter

* fix: correct name of domain argument in usage

* fix: adapt command to new syntax

* tests: use different quotes

* tests: use different quotes

* tests: remove domains that were never added

* style: change test name

* refactor: dkim setup

* style: remove trailing whitespace

* tests: remove test of removed dummy file

Co-authored-by: Frederic Werner <20406381+wernerfred@users.noreply.github.com>
2021-02-21 22:05:35 +01:00
Frederic Werner d182d65377
fix: dkim help message test (#1817) 2021-02-18 22:55:17 +01:00
Georg Lauterbach d221c585c2
inform about proper `setup.sh` usage between versions 2021-02-18 14:01:01 +01:00
Georg Lauterbach f3f38db0f9
adjust test to use new script output from openDKIM 2021-02-18 13:11:45 +01:00
Georg Lauterbach 27f6ad73cf
re-write setup.sh's help message to use the new style (#1814) 2021-02-18 11:09:29 +01:00
Georg Lauterbach 1005bb3b09
Provide complete refactoring of openDKIM script (#1812)
* provide complete refactoring of openDKIM usage and tests

* fix leftover linting errors

* correct defualt key size and README usage

* provide independent order for arguments

* added `config` and adjusted usage information

* fixing shift in setup.sh

* adjust usage information to use new style and rename script

* use updated argument keysize instead of size
2021-02-18 10:29:34 +01:00
Brennan Kinney 432f96b3a6
Use best practice cipher suites for 2021 (#1802)
Update cipherlist to sync with OWASP B and Mozilla Intermediate
2021-02-18 10:24:34 +01:00
Ask Bjørn Hansen 4a3735bced
Support extra user_attributes in accounts configuration (#1792)
This allows you to add for example

    |userdb_mail=mbox:~/mail:INBOX=~/inbox

 to the end of an account to have a different mailbox configuration.
2021-02-07 19:02:09 +01:00
Ask Bjørn Hansen 14eaaa17e1 Remove confusing and unused clear.postfix-accounts.cf test config file 2021-02-06 06:25:29 -08:00
Georg Lauterbach 931eab0541
removing bl.spamcop.net for 8.0.1 2021-01-31 16:05:05 +01:00
Casper 70267d89e5
Replace $_ in error trap (#1776) 2021-01-28 14:50:28 +01:00
Georg Lauterbach cc7138e28f
minor adjustments before release 8.0.0 2021-01-27 18:42:39 +01:00
William Desportes 4616894fbf
Allow manual domains for dkim generator (#1753)
* Allow manual domains for dkim generator

* Document the DKIM manual mode

* Remove unnecessary quotes

* updating default value usage and "" in [[ ]]

* Change parameter expansion

* Add test for manual dkim domains

* Remove obsolete script

* Add manual dkim mode to usage

* Move manual dkim guide into quickstart section

* Cover case that key for domain already exists

* Set default dkim key size to 4096

Co-authored-by: Frederic Werner <20406381+wernerfred@users.noreply.github.com>
Co-authored-by: Georg Lauterbach <44545919+aendeavor@users.noreply.github.com>
2021-01-27 14:09:24 +01:00
Georg Lauterbach 324ee8eb85
Improve logging significantly – color is back! (#1758)
* improve logging significantly
* now defaulting to warn
* final adjustments
* correcting not-escaped $ in sed
2021-01-22 10:03:31 +01:00
Georg Lauterbach 221d4ce187
adjusting links & misc 2021-01-19 09:27:01 +01:00
Georg Lauterbach dba291dc43
Introducing the repository secret (#18)
* fixes #17
* corrections and adjustments
2021-01-18 20:51:56 +01:00
brainkiller 061fe12aa7
Solve Fetchmail imap idle issue (#10)
* Migrate PR#1730 from tomav/docker-mailserver repo to new
docker-mailserver/docker-mailserver repo
* Resolved review comments
* Moved counter increment to have consistency between fetchmail process
and fetchmail config files
* Added tests for new fetchmail option

Co-authored-by: Georg Lauterbach <44545919+aendeavor@users.noreply.github.com>
2021-01-17 10:39:09 +01:00
Georg Lauterbach 189e5376cc
Final Migration Step (#6)
* first migration steps
  * altered issue templates
  * altered README
  * removed .travis.yml
* adjusting registry & repository, Dockerfile and compose.env
* Close stale issues automatically
* Integrated CI with Github Actions (#3)
* feat: integrated ci with github actions
* fix: use secrets for docker org and update image
* docs: clarify why we use -t if no tty exists
* fix: correct remaining references to old repo
chore: prettier automatically updated markdown as well
* fix: hardcode docker org
* change testing image to just testing
* ci: add armv7 as a supported platform
* finished migration steps
* corrected linting in build-push action
* corrected linting in build-push action (2)
* minor preps for PR
* correcting push on pull request and minor details
* adjusted workflows to adhere closer to @wernerfred's diagram
* minor patches
* adjusting Dockerfile's installation of base packages
* adjusting schedule for stale issue action
* reverting license text
* improving CONTRIBUTING.md PR text
* Update CONTRIBUTING.md
* a bigger patch at the end
  * moved all scripts into one directory under target/scripts/
  * moved the quota-warning.sh script into target/scripts/ and removed empty directory /target/dovecot/scripts
  * minor fixes here and there
  * adjusted workflows for use a fully qualified name (i.e. docker.io/...)
  * improved on the Dockerfile layer count
  * corrected local tests - now they (actually) work (fine)!
  * corrected start-mailserver.sh to make use of defaults consistently
  * removed very old, deprecated variables (actually only one)
* various smaller improvements in the end
* last commit before merging #6
* rearranging variables to use alphabetic order

Co-authored-by: casperklein <casperklein@users.noreply.github.com>
Co-authored-by: Nick Pappas <radicand@users.noreply.github.com>
Co-authored-by: William Desportes <williamdes@wdes.fr>
2021-01-16 10:16:05 +01:00
William Desportes 7765d4a6b3
Fix shebangs 2021-01-02 14:49:35 +01:00
Georg Lauterbach 59ba34cb4b
corrected lint.sh 2020-12-22 20:07:08 +01:00
Georg Lauterbach d9e4b89415
Merge pull request #1703 from BrandonSchmitt/acme-fixes
Small fixes for extracting certs from the acme.json file
2020-12-11 12:53:04 +01:00
Georg Lauterbach 31f593eee9
correcting lint.sh to properly use exit instead of return 2020-12-10 10:51:33 +01:00
Brandon Schmitt 6251f898ea
Fix error in python script extracting certs from the acme.json file if there are sections with null values as certs
Signed-off-by: Brandon Schmitt <Brandon.Schmitt@live.de>
2020-12-06 20:30:20 +01:00
Georg Lauterbach 2c65b0c260
use wait_for_smtp function instead of sleep 2020-11-06 14:11:42 +01:00
Georg Lauterbach ed7106b04d
housekeeping 2020-11-06 14:04:23 +01:00
Georg Lauterbach 9ce719213b
first refactoring fr *.bats according to shellcheck 2020-11-05 19:15:28 +01:00
Georg Lauterbach 46998dd816
preparation to include *.bats into shellcheck 2020-11-05 13:47:52 +01:00
Georg Lauterbach 5365e7f0f8
fixes #1677 2020-11-05 11:41:18 +01:00
Martin Schulze 6a9e5c0b62 Fix parallel development error: Use correct filename 2020-10-28 14:39:42 +01:00
Georg Lauterbach f0105f6d47
Merge pull request #1613 from martin-schulze-vireso/feature/extract_even_more_tests 2020-10-28 11:16:15 +01:00
Georg Lauterbach da8171388f
Complete Refactor for `target/bin` (#1654)
* documentation and script updates trying to fix #1647
* preparations for refactoring target/bin/
* complete refactor for target/bin/
* changing script output slightly
* outsourcing functions in `bin-helper.sh`
* re-wrote linting to allow for proper shellcheck -x execution
* show explanation for shellcheck ignore
* adding some more information
2020-10-21 18:16:32 +02:00
Martin Schulze 0015c62303 Fix linter issue 2020-10-20 15:02:31 +02:00
Martin Schulze 5cce70b3a9 Fix timing dependent failures 2020-10-20 14:14:04 +02:00
Martin Schulze 2de5c52b83 Fix nameclash in config names 2020-10-20 12:05:40 +02:00
Martin Schulze 0453240098 Catch errors on config duplication command 2020-10-20 09:33:47 +02:00
Martin Schulze 5884f866d3 Fix duplicate configuration name clashes 2020-10-20 09:33:14 +02:00
Martin Schulze 1ac5245f04 Add missing file 2020-10-20 01:05:01 +02:00
Martin Schulze 7bdac2a910 Add tests for remaining test_helper functions 2020-10-20 00:50:19 +02:00
Martin Schulze 9471ce7346 Fix errors due to trying to send emails too early
when clamav has not fully come up yet
2020-10-19 23:34:39 +02:00
Martin Schulze 7ae4a73d3b Fix tests failing when emails are not yet delivered 2020-10-19 23:33:54 +02:00
Georg Lauterbach b948e01d39
re-trigger
wget through exception in the last test
2020-10-19 15:23:42 +02:00
Georg Lauterbach 3720dbafc0
removed `local VAR=$(...)` assignments 2020-10-19 15:19:34 +02:00
Georg Lauterbach ab1da1e3f3
small changes in common.bash 2020-10-19 14:10:32 +02:00
Georg Lauterbach 3f5c518950
mostly `pwd` replacements and introduction of local keywords 2020-10-19 13:13:42 +02:00
Georg Lauterbach 0d219800ff
replacing all occurences of `private_config` with the uppercase variable 2020-10-19 12:15:44 +02:00
Georg Lauterbach a3acedaf19
fixing NAME 2020-10-19 12:12:13 +02:00
Georg Lauterbach 0da7ee0c1d
{} and uppercase 2020-10-18 15:44:01 +02:00
Martin Schulze 5030e8278c Add tests for test/common.bash 2020-10-18 03:11:10 +02:00
Martin Schulze 7fb13c18cd Reinstane required (empty) folder
this is needed to make test
"checking accounts: user3 should have been added to /tmp/docker-mailserver/postfix-accounts.cf even when that file does not exist"
pass
2020-10-18 02:25:03 +02:00
Martin Schulze 88fbe0dbd3 Fix shellcheck errors on tests.bats 2020-10-18 02:24:26 +02:00
Martin Schulze e2bca5f850 Always use ${} 2020-10-18 02:08:11 +02:00
Martin Schulze f47f85598d Fix trailing slash in path 2020-10-17 23:24:39 +02:00
Martin Schulze 13963747b8 Fix missing newline at the end of file 2020-10-17 23:24:23 +02:00
Martin Schulze 80bfc422a2 Reduce code duplication 2020-10-17 02:04:33 +02:00
Martin Schulze 7530aea9f5 Don't use an extra moint for subdir 2020-10-17 02:04:33 +02:00
Martin Schulze 96b3fd726a Fix wait_for_service not working/hanging 2020-10-17 02:04:33 +02:00
Martin Schulze c6c6fb708c Avoid running tests while the services restart due to changes 2020-10-17 02:04:33 +02:00
Martin Schulze 05deaa3196 Move common functions into common.bash 2020-10-17 02:03:11 +02:00
Martin Schulze 53b930448d Fix shellcheck issues 2020-10-17 02:03:11 +02:00
Martin Schulze 0d4eb08de8 Add missing accounts 2020-10-17 02:03:11 +02:00
Martin Schulze e1d0fcfe01 Improve output in failure cases 2020-10-17 02:03:11 +02:00
Martin Schulze a90e043e45 Fix failing tests due to old paths 2020-10-17 02:03:11 +02:00
Martin Schulze ca3ebc6c40 Improve error messages on problems 2020-10-17 02:03:11 +02:00
Martin Schulze 40dd3ae985 Implement and use run_until_success_or_timeout 2020-10-17 02:03:11 +02:00
Martin Schulze a477040abb Allow for seamless switching between old and new bats versions 2020-10-17 02:03:11 +02:00
Martin Schulze ef80c6b2a3 Add setup/teardown marker tests 2020-10-17 02:03:11 +02:00
Martin Schulze 0eb5bd0db9 Add --fatal-tests for early out in container waits 2020-10-17 02:02:46 +02:00
Martin Schulze 97806859b6 Fix private_config_path creating the wrong folder 2020-10-17 02:02:46 +02:00
Martin Schulze 5fef8a5b78 Give each container their own private config folder 2020-10-17 02:02:46 +02:00
Martin Schulze 190f4961c0 Move mail container creation into tests file 2020-10-17 02:02:46 +02:00
Martin Schulze 9c285db520 Extract mail_override_hostname into own test file 2020-10-17 02:02:46 +02:00
Martin Schulze 06b137e5a8 Extract container mail_smtponly_without_config into test 2020-10-17 02:02:46 +02:00
Martin Schulze ad0be553d8 Extract SRS DOMAINNAME tests/container into own file 2020-10-17 02:02:46 +02:00
Martin Schulze d38ff4c122 Extrract disabled clamav tests into own file 2020-10-17 02:02:46 +02:00
Georg Lauterbach ed6e3ebd30
Outsourced linting tests into its own file (#1636)
* outsourced linting tests into its own file
* trigger rebuild
* added SCRIPT variable to setup.sh
* trigger rebuild again
* major test rewrite
* outsourced `hadolint` too
* rewrote some parts of the linting logic due to a logic bug
* adjusted TravisCI
* corrected .bats test line
* corrected logging in linting tests
* updated `hadolint`
2020-10-04 19:34:15 +02:00
Georg Lauterbach a0791ef457
formatting files according to standard (#1619)
* added EditorConfig linting
* adding `eclint` as Travis script target
* re-adjusted .pem files to have a newline
2020-09-24 14:54:21 +02:00
mwnx 42352a3259 Update relayhost_map with virtual accounts too
Previously, only postfix-relaymap.cf and postfix-accounts.cf would be
used to populate the relayhost_map file.

Now, also use postfix-virtual.cf when present. To me, there is nothing
absurd about sending mail "From:" a virtual account (or more
specifically its domain) so it makes sense that when a $RELAY_HOST is
defined it should be used for virtual accounts as well.
2020-08-28 15:03:51 +02:00
mwnx 1286a1266b Fix/refactor relayhost_map update when dynamically adding account
check-for-changes.sh did not have a special case to handle lines in
postfix-relaymap.cf consisting of only a domain (indicating that said
domain should never be relayed). This case is handled by
start-mailserver.sh so when such a line existed, things would work well
until a config file update was detected by check-for-changes.sh. After
that, the generated relayhost_map file would be corrupted.

Fixed by factoring a 'populate_relayhost_map' function out of
start-mailserver.sh and into helper_functions.sh and reusing it in
check-for-changes.sh.

Note: There are certainly quite a few more pieces of code that could be
refactored in a similar fashion.

Note2: check-for-changes.sh would previously never update the
relayhost_map file when $ENABLE_LDAP was set to 1. I don't think this
was intended —there is after all no such condition in
start-mailserver.sh— and so this condition no longer applies.
2020-08-28 15:03:51 +02:00
mwnx 2a70f33a4b Fix checksum race condition in check-for-changes.sh
If a change to one of the tracked files happened soon after (<1 second?)
a previously detected change, it could end up going undetected. In
particular, this could cause integration tests to fail (see next
commits).

Fixed by computing the new checksum file _before_ checking for changes.
2020-08-28 14:57:43 +02:00
Michael Sprauer 119dbd664c revert nonsens changes 2020-07-14 15:23:36 +02:00
Michael Sprauer d61a8cd9c0 letsencrypt & traefik wildcard support
set SSL_DOMAIN=*.example.com to extract a wildcard certificate from traefiks acme.json store
2020-07-13 22:58:17 +02:00
Michael Sprauer 32c732e276 certificates from acme.json
Will extract certificates from acme.json as written by traefik for usage in dovecot and postfix.
Also watches acme.json for changes. For this to work the file has to be mounted/present at `/etc/letsencrypt/acme.json`
2020-06-30 22:43:22 +02:00
Michael Sprauer 989f691281 fix tests with space in path 2020-06-30 22:34:26 +02:00
Nicholas Pepper 1b659a5574 Modified letsencrypt support to add domain name checking in addition to
hostname checking.  Added necessary tests and renamed original manual
ssl test to a name that supports adding the other SSL tests.
2020-05-15 04:52:26 +00:00
youtous c65ffb44a1
test postfix inet 2020-05-09 22:42:56 +02:00
youtous d0f7257333
support comments in .cf files 2020-05-06 22:59:55 +02:00
youtous 30262128f4
raise a warning when SPAMASSASSIN_SPAM_TO_INBOX isn't explicitly defined 2020-05-03 10:33:50 +02:00
youtous 15dd63d566
add test case no move to Junk 2020-05-03 10:33:28 +02:00
youtous d829905cf7
init spams to junk 2020-05-03 10:33:28 +02:00
youtous 0c838706d0
Option to disable dovecot quota 2020-05-01 23:42:21 +02:00
youtous d45e6b1c22
#fix 1478 2020-04-30 12:47:12 +02:00
youtous 80bd3a8c85
Update test/mail_dhparams_manual_not_one_dir.bats
Co-Authored-By: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2020-04-27 10:42:47 +02:00
youtous 3e3f5d557b
Update test/mail_dhparams_manual_one_dir.bats
Co-Authored-By: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2020-04-27 10:42:39 +02:00
youtous 27cbdeeb6a
Update test/mail_dhparams_default.bats
Co-Authored-By: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2020-04-27 10:42:24 +02:00
youtous e680c349b1
test wait setup for // containers 2020-04-27 10:28:24 +02:00
youtous 149a10272c
improve dhe tests documentation 2020-04-27 09:57:36 +02:00
youtous dff7355fa9
fix #1459 2020-04-26 23:07:34 +02:00
youtous 4d031f73e3
test dhparams ONE_DIR both cases 2020-04-26 22:25:48 +02:00
youtous 47fac2706f
use ffdhe4096 for DHE params
use by default ffdhe4096 for DHE params 


use by default ffdhe4096 for DHE params
2020-04-26 22:23:51 +02:00
youtous f60de0c66e
init tests cases ffdhe4096 2020-04-26 22:23:51 +02:00
youtous bdcf5e0cf1
fix send mail test quota
fix quota warning test: wait for postfix to be UP


increase postfix restart delay
2020-04-24 19:03:27 +02:00
youtous 2e149b74c2
fix async quota tests 2020-04-24 17:03:09 +02:00
youtous 04de46dc41
test quota reached 2020-04-24 15:53:44 +02:00
youtous 2527ebfaf2
added dovecot quota feature
add postfix service quota check


check-for-changes on quotas


setquota command


fix checkforchanges quota


addquota verify user exists


add setquota in setup.sh


merging addquota into setquota


test quota commands


add ldap tests for dovecot quota


fix smtp only quota postfix rules


test postfix conf


add quota test integration


add quota exceeded test


add wait analyze


fix tests


fix setup typo


add test fixes


fix error output


wip


update startup rules


fix setup


fix setup tests


fix output commands


remove quota on remove user


try to fix sync limit mails


check if file exists


fix path


change used quota user


fix post size


check if quota file exists


update tests


configure virtualmailbox limit for dovecot


last fix


fix quota expr


relax dovecot tests


auto create dovecot-quotas


fix dovecot apply quota test


wip quota warning


trying to fix get dovadm quota


dovecot applies fix


fix quota warning lda path


test count mail on quota


fix quota warning permissiosn


fix test
2020-04-24 14:56:15 +02:00
Erik Wramner dde6acd1a1 Search in rotated logs and limit to RelayedInbound 2020-01-26 21:05:24 +01:00
Erik Wramner f342151b80 Fixed several amavis tests and removed commented code 2020-01-26 16:39:58 +01:00
Erik Wramner 42ccae2642 Test stop with a less central container than mail 2020-01-26 08:36:31 +01:00
Erik Wramner 27d66cf11f Restored test removed by accident 2020-01-22 19:11:59 +01:00
Erik Wramner 881ac71601 Show delivered mails with more details in test 2020-01-20 21:59:34 +01:00
Erik Wramner 1c73290ba0 Show found and expected decoders in test 2020-01-19 09:20:50 +01:00
Erik Wramner a66b2bff0c Make test result easier to evaluate 2020-01-18 21:01:24 +01:00
Erik Wramner 2ad667209c
Merge pull request #1323 from ap-wtioit/master-remove_tty_necessity
fix: dont use TTY in docker if not present, rem TTY necessity in tests
2019-11-13 09:59:01 +01:00
Andreas Perhab bbab4ef3fc fix: fix test setup.sh debug fetchmail on wildcard domains
on hosts that belong to wildcard domains pop3.example.com might
 actually resolve to pop3.example.com.[mydomain.com] and give a valid ip
 the return code of fetchmail then no longer is 11 (dns failure) but
 something else (2 for socket error in our case)

to make sure we always get return code 11 we use the domain name
pop3.example.com. that is not allowed to be resolved to a subdomain.
2019-11-12 15:35:03 +01:00
Andreas Perhab d8be2bd3cc fix: dont use TTY in docker if not present, rem TTY necessity in tests
Gitlab CI has not TTY present and TTY is not really required for
automated testing
2019-11-12 09:32:27 +01:00
Erik Wramner c882d95deb
Merge pull request #1284 from vortex852456/master
Added optional file user-patches.sh for own patches without recompiling
2019-11-09 15:13:06 +01:00
Sebastian Kaiser 37540509dc - test for user-patches.sh 2019-11-08 02:22:33 +01:00
Germain Masse d764d89ea9 Test for DOVECOT_MAILBOX_FORMAT 2019-11-04 15:49:29 +00:00
Germain Masse fa167a9e51 Test special-use folders are available in IMAP 2019-11-01 20:04:37 +00:00
Germain Masse e465e659ad Remove unnecessary maildir folders creation 2019-11-01 20:04:37 +00:00
vortex852456 34f52c6ad0
only "assert_success" for user-patches.sh check 2019-10-31 09:51:40 +01:00
Vortex def8400c17 added default "user-patches.sh" to the first container "mail" 2019-10-31 09:01:44 +01:00
Vortex 437d3b74cc added test for "checking configuration: user-patches.sh executed" - should fail with this commit 2019-10-31 02:38:45 +01:00
Felix Bartels 7ff9764285
Provide version information through labels (#1256)
* Provide version information through labels

Can be retrieved by calling e.g. `docker inspect -f {{.Config.Labels}} tvial/docker-mailserver:testing`

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* add build hook so that Docker Hub can work with the build args

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* remove obsolete build-no-cache

build args invalidate build cache already

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* adapt travis file

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* shellcheck

Signed-off-by: Felix Bartels <felix@host-consultants.de>
2019-10-23 11:22:23 +02:00
Germain Masse b34a79310a Privacy test email no more tagged as SPAM. ClamAV and SA disabled to avoid time-out on low perf system 2019-10-14 13:25:44 +00:00
Martin Schulze e2bbf12524 Tests fx: Also wait for smtp port 2019-10-08 23:39:04 +02:00
Martin Schulze 604a65024e Tests: extract mail_privacy into own .bats file 2019-10-08 23:11:27 +02:00
Martin Schulze 533ac7ed29 Tests: extract mail_pop3 into own .bats file 2019-10-08 22:24:05 +02:00
Martin Schulze 81fd83525c Tests: extract mail_smtponly into own .bats file 2019-10-08 22:15:27 +02:00
Martin Schulze 56f47db0f2 Tests: Extract mail_fail2ban into own .bats file 2019-10-08 22:03:56 +02:00
Martin Schulze d05255cb04 Tests: Extract mail_fetchmail into own .bats file 2019-10-08 21:45:05 +02:00
Martin Schulze a03c741e1b Extract mail_manual_ssl into own .bats file 2019-10-08 21:36:13 +02:00
Martin Schulze d3e2dfe3ba Move mail_with_ldap into its own .bats file 2019-10-08 21:31:56 +02:00
Martin Schulze d9a48878c9 Print last 10 log lines on container setup timeout 2019-09-12 00:43:44 +02:00
Martin Schulze 3f9dd4180a Fix setup_file marker logic 2019-09-12 00:42:04 +02:00
Martin Schulze a20f2c4199 Add pregenerated test/config dh params 2019-09-12 00:42:04 +02:00
Erik Wramner ca821fa51a
Merge pull request #1259 from martin-schulze-vireso/bugfix/no_error_printed_on_timeout
Fix missing error output from timeout
2019-09-11 14:04:04 +02:00
Martin Schulze 3513944d0a Skip all tests of file after failed setup_file 2019-09-11 01:01:51 +02:00
Martin Schulze 8e6152ff2f Fix missing error output from timeout
The exits would prevent the printing code from running
2019-09-11 00:02:16 +02:00
Erik Wramner 8f23cb7b35 Adjust wait for tests as they often fail 2019-09-05 21:35:23 +02:00
Martin Schulze 596563ae64 Make failed test output more readable 2019-08-21 21:16:39 +02:00
Martin Schulze bfc4f5693e Don't use run in repeat_until_success_or_timeout
it overwrites the return code of its command
2019-08-17 21:23:48 +02:00
Martin Schulze a933ef27ac Fix polling with pipes 2019-08-17 20:58:33 +02:00
Martin Schulze 43ae814776 Extract mail_with_imap into its own test file 2019-08-17 20:58:33 +02:00
Martin Schulze 9019b98394 Extract mail_postscreen into own test file 2019-08-17 20:58:33 +02:00
Martin Schulze 3b728848bb Extract mail_lmtp_ip into own test file 2019-08-17 20:58:33 +02:00
Martin Schulze 82ab286291 Extract mail_undef_spam_subject into own test file 2019-08-17 20:58:33 +02:00
Martin Schulze 5be2fdc3cd Use correct container name 2019-08-17 20:58:33 +02:00
Martin Schulze 9d90df7064 Fix integer check 2019-08-17 20:58:33 +02:00
Martin Schulze 85fa5d242f Fix setup/teardown_file to work in full suite run
The previous mechanism would only run them once for the whole suite
2019-08-17 20:58:33 +02:00
Martin Schulze d8956d3b29 Extract mail_with_postgrey into own test files 2019-08-17 20:58:33 +02:00
Martin Schulze fcddf578d2 Extract mail with relay tests into own file 2019-08-17 20:58:33 +02:00
Martin Schulze db160bd977 Extract default relay host test
centralize common test variables and functions
2019-08-17 20:58:33 +02:00
Erik Wramner bf773cc8b7 Use assert_output for better diagnostics of failures 2019-08-16 12:02:23 +02:00
Felix Bartels 1ba0991d80
Fix linting errors reported by hadolint (#1211)
* Fix linting errors reported by hadolint
* use full path for folders when listing contents
* add linting task to makefile
2019-08-13 11:41:38 +02:00
Erik Wramner 5ebb8614a2
Merge pull request #1220 from erik-wramner/dhparam_on_start
Generate dhparam and dovecot cert on start
2019-08-12 22:00:31 +02:00
Felix Bartels a7408b73e0 Do not remove dh*.pem as they do not exist at this point in time
Signed-off-by: Felix Bartels <felix@host-consultants.de>
2019-08-12 19:31:24 +02:00
Erik Wramner f5dac6e71c Disable SMTPUTF8 as Dovecot can't handle it 2019-08-11 17:14:00 +02:00
Erik Wramner c9bd3f3e83 Added sleep to test that keeps failing randomly 2019-08-10 08:34:18 +02:00
Erik Wramner fc8d684994 Generate dhparams at startup, not build 2019-08-09 22:13:50 +02:00
Martin Schulze 41dfe43c71 Remove code duplication 2019-08-07 22:03:17 +02:00
Martin Schulze d712a29baf Check for PERMIT_DOCKER correct postfix settings 2019-08-07 21:45:52 +02:00
Martin Schulze fcce47a392 WIP: actually test PERMIT_DOCKER=connected-networks
also showcase timeouts and makefile integration
2019-08-07 02:24:56 +02:00
Felix Bartels 83b4cda0bf update bats to latest version 2019-08-05 21:40:09 +02:00
Erik Wramner 41921f82aa
Merge pull request #1205 from j-marz/opendkim_nameserver
set Nameservers in opendkim.conf at start-up
2019-08-04 18:54:08 +02:00
j-marz 2f0e516d42 added test to check for nameservers in opendkim.conf 2019-08-04 20:29:39 +10:00
Martin Schulze 9c1a5d76af Fix tests for PERMIT_DOCKER=connected-networks 2019-08-03 20:49:10 +02:00
Martin Schulze 234632913e Add PERMIT_DOCKER=connected-networks 2019-08-02 15:05:00 +02:00
Erik Wramner d6861881ab Parse logs to ensure changes are processed 2019-08-01 15:24:47 +02:00
Erik Wramner 21c89b3364 Added TODO as per code review and removed one sleep 2019-07-31 12:59:49 +02:00
Erik Wramner b23a7ddc1c Added newline as suggested in code review 2019-07-31 10:43:12 +02:00
Erik Wramner 311bdfa1ba Keep checksum file outside shared/mounted area 2019-07-30 16:10:51 +02:00
Erik Wramner f849b46462 Moved test files and mounted read-only 2019-07-30 16:10:51 +02:00
Erik Wramner e47c73f789 Wait and retry if pre-defined user login fails 2019-07-30 16:10:51 +02:00
Erik Wramner 1f298e3a76 Wait and retry if added user fails to login in tests 2019-07-30 16:10:51 +02:00
Erik Wramner 7299be1284 Split tests to find out why they fail 2019-07-30 16:10:51 +02:00
jjtt a3724fa91d Support for setting relayhost in main.cf (#1104)
* Added DEFAULT_RELAY_HOST setting
* If set this value will be used as the relayhost in /etc/postfix/maincf causing all mail to be delivered using this relay host
* Test for default relay host setting
2019-01-19 11:10:31 +01:00
Daniel Panteleit cc56b4f89e Calling supervisord directly instead of via shell (Closes: #1047, #1074) 2018-11-04 20:23:50 +01:00
millerjason 53a344a056 Support for additional postgrey options (Close: #998, #999, #1046)
* addnl postgrey whitelist support. closes #998, closes #999.

	modified:   Dockerfile
	modified:   Makefile
	modified:   README.md
	modified:   docker-compose.elk.yml.dist
	modified:   docker-compose.yml.dist
	modified:   target/start-mailserver.sh
	modified:   target/supervisor/conf.d/supervisor-app.conf
	new file:   test/config/whitelist_recipients
	new file:   test/nc_templates/postgrey_whitelist_local.txt
	new file:   test/nc_templates/postgrey_whitelist_recipients.txt
	modified:   test/tests.bats

* match existing indent convention

	modified:   target/start-mailserver.sh

* ISSUE-999: add support for header_checks

	modified:   Dockerfile
	modified:   target/postfix/main.cf

* ISSUE-999: add empty header_check file

	new file:   target/postfix/header_checks.pcre
2018-11-01 19:32:36 +01:00
James d518a9fc1d DOMAINNAME can fail to be set in postsrsd-wrapper.sh (#989)
* DOMAINNAME can fail to be set in postsrsd-wrapper.sh

if the container doesn’t have a proper hostname, postsrsd will fail to start
because SRS_DOMAIN is empty. Make a best effort to figure out the domain name
and provide a way to set one if needed.
2018-06-19 08:17:32 +02:00
ixeft 60656aec49 Report sender (#965)
* added REPORT_SENDER env variable to the container.
* integration test for REPORT_SENDER
* added tests for default REPORT_SENDER
2018-05-01 19:57:31 +02:00
magnus anderssen c1118af66d Support for detecting running container mount (#884)
This modification proposes to support the running configured mounted
volume for configuration.

This removes the need to pass a path from the command line when the
container is running and configured in another way that yours.
2018-04-28 10:27:42 +02:00
Paul Adams ea848eb86f Deliver root mail (#952)
* Configure delivery of root's mail to postmaster
* Tests for delivery of root mail
* add missing email template
2018-04-23 20:35:33 +02:00
17Halbe 59ce9d03f0 Testfixes & more (#942)
* fixed useless updatetest, made updatemailuser and addmailuser setup.sh compliant.
* changed documentation
2018-04-08 16:12:41 +02:00
Paul Adams a564cca0e5 set postmaster address to a sensible default (#938, #939, #940) 2018-04-05 19:04:55 +02:00
17Halbe cc7c1f8804 Introducing global filters. (#934)
* Introducing global filters
* added optional after.dovecot.sieve/before.dovecot.sieve files
* added global filter test
2018-04-05 18:54:01 +02:00
Pierre-Yves Rofes 137d623171 Ensure that the account contains a @ (#923, #924)
* Ensure that the provided username actually contains a domain
* Update README.md to be consistent with addmailuser script
* Add a test to check if the username includes the domain
2018-04-04 18:59:28 +02:00
17Halbe 2e06228b10 Password creation fix (#908, #914)
* fix password with spaces is stripped to first word
2018-04-02 16:55:54 +02:00
Paul Adams f28e9843ce Implementation of multi-domain relay hosts (#922, #926)
* Add new configuration for multi-domain relay hosts (#922)
 * Creates new environment variables (replacing existing AWS_SES variables)
 * Optionally allows more advanced setups using config files
* Update relay hosts during change detection (#922)
* Add helper scripts for adding relay hosts and per-domain auth
* Allow the possibility to deliver some mail directly
* adding a domain with no destination will exclude it from the
  relayhost_map and so Postfix will attempt to deliver the mail directly
* tests for setup.sh script
* tests for relay host configuration
* these tests cover the code in `start-mailserver.sh` dealing with both
  the env vars and the configuration files
2018-04-02 10:45:58 +02:00
17Halbe a7589aa353 test/config backup & restore (#907)
* backup and restore of test/config folder as done for the regular config folder as well.
* permissions fix
* preserving permissions and ownership
* new backup rule
2018-03-21 19:55:41 +01:00
17Halbe ee4b434a5c Restore userdb for tests (#913) 2018-03-20 08:17:24 +01:00
17Halbe f682dfc15d fixed delalias, added additional tests (Closes: #909) 2018-03-19 20:26:10 +01:00
17Halbe 2167108ec0 introducing ENABLE_SRS env variable (Closes: #906, #852)
* making postsrsd optional
* added tests, added documentation
2018-03-18 20:15:06 +01:00
akmet a420b15370 Adding daily mail review from Issue 839 (#881)
* Added dependencies, binary, startup configuration
* Added env variable to dist files/readme
* send summary after each logrotate, added env variable for mail/logrotate interval
* remove mail.log from rsyslogs logrotate
* rotate mail.log when no email is set
* Added documentation for POSTFIX_LOGROTATE_INTERVAL
* Removed interval option, since its not being tested for.
* changed test to force logrotate to rotate fixed logrotate config
* readded setup_environment, made logrotate_setup being called everytime
* changed documentation for new variable names - again
* Did Documentation, added a default recipient, added test for default config.
* layout fix
* changed variable names apposite the documentation
2018-03-18 19:52:28 +01:00
akmet ad40c00546 Backup config folder while testing (#901)
* Backup whole config while testing
2018-03-16 18:52:49 +01:00
17Halbe 570237232c Delmailuser (Closes: #878)
* delmailuser:
  + added multiple address deletion
  + added alias deletion
  + added maildir deletion (upon confirmation)
  + introduced optional "assume yes" argument
* updated addalias,delalias,delmailuser,updatemailuser and added modified tests
* added config check and repair to start-mailserver for old postfix-virtual.cf files
2018-03-14 20:00:38 +01:00
17Halbe a73692cc9f Added reject_authenticated_sender_login_mismatch (#872)
* added reject_authenticated_sender_login_mismatch handling including tests
* removed obsolete reject_sender_login_mismatch
* introduced SPOOF_PROTECTION env variable, tests, documentation and missing documentation for TLS_LEVEL
* added missing email template
2018-03-07 19:33:43 +01:00
Marek Walczak 253c8faef6 Dkim key size - Addon (#871)
* added Tests
2018-03-03 09:20:23 +01:00
Alexander Elbracht d9502ab6e7 Implement undef option for SA_SPAM_SUBJECT (#767)
* Implement undef option for SA_SPAM_SUBJECT in amavis config
* Add test for undef spam subject
2018-03-02 22:38:57 +01:00
Andreas Gerstmayr 2687469f38 update postmaster_address in dovecot config according to POSTMASTER_ADDRESS env var (#866)
* update postmaster_address in dovecot config according to POSTMASTER_ADDRESS env var
* tests: add another test for postmaster_address with default settings
2018-02-27 20:44:45 +01:00
Marek Walczak c36e878d76 Nist tls (#831)
* remove two ciphers according to https://www.htbridge.com/ssl/ (NIST, HIPAA)
* added a switch via an environment variable to choose between modern and intermediate ciphers
2018-02-22 08:36:12 +01:00
17Halbe 5e09074d58 postscreen implementation altered (#846)
* new setup.sh function, new tests, new script and some minor updates to main.cf
* fix for missing files
* removed obsolete test-files
* restart postfix if neccessary.
* see pr  #845
* fixed typo
* fixed branchmixup
* changed postfix reload command & changed to operate on container instead of image
* reload postfix only on adding new restriction
* main.cf is only changed when user is added.
 - Postfix reload changed
 - working on container instead of image now in setup.sh
 - added cleanup after tests
* moved cleanup to makefile
2018-02-18 13:29:43 +01:00
17Halbe b08c9b42ed moved fail2ban function from setup.sh to own file (#837)
* moved fail2ban function out of setup.sh
2018-02-13 08:31:12 +01:00
17Halbe 5394a505b9 Restrict access (Closes #452, #816)
new setup.sh function, new tests, new script
2018-02-07 21:33:07 +01:00
Jurek Barth e1e4542390 Fix: Add SRS to fix SPF issues on redirect #611 (#814)
* add srs support

* change autorestart behavior

* this may work now

* make postsrsd’s own wrapper file

* fix dockerfile formatting

* fixing tests
2018-02-06 08:11:57 +01:00
17Halbe 3b7fc5930c Introducing Postscreen (#799)
* Introduced Postscreen

cheaper, earlier and simpler blocking of zombies/spambots.
From http://postfix.cs.utah.edu/POSTSCREEN_README.html :
As a first layer, postscreen(8) blocks connections from zombies and other spambots that are responsible for about 90% of all spam. It is implemented as a single process to make this defense as cheap as possible.

Things we need to consider:

 - Do we need a whitelist/backlist file? (http://postfix.cs.utah.edu/postconf.5.html#postscreen_access_list)
   - Via introducing an optional config/postfix-access.cidr
   - The only permanent whitelisting I could imagine are monitoring services(which might (still?) behave weird/hastely) or blacklisting backup servers(since no traffic should be coming from them anyway)
 - Do we need deep inspections? They are desireable, but these tests are expensive: a good client must disconnect after it passes the test, before it can talk to a real Postfix SMTP server. Considered tests are:
   - postscreen_bare_newline_enable (http://postfix.cs.utah.edu/postconf.5.html#postscreen_bare_newline_action)
   - postscreen_non_smtp_command_enable (http://postfix.cs.utah.edu/postconf.5.html#postscreen_non_smtp_command_action)
   - postscreen_pipelining_enable (http://postfix.cs.utah.edu/postconf.5.html#postscreen_pipelining_action)
- Do we need to make the blacklisting via dnsblocking configurable? It's currently set and weighted as follows, where a score of 3 results in blocking, a score of -1 results in whitelisting:
   (*: adds the specified weight to the SMTP client's DNSBL score. Specify a negative number for whitelisting.)
   (http://postfix.cs.utah.edu/postconf.5.html#postscreen_dnsbl_sites)
   - zen.spamhaus.org*3
   - bl.mailspike.net
   - b.barracudacentral.org*2
   - bl.spameatingmonkey.net
   - bl.spamcop.net
   - dnsbl.sorbs.net
   - psbl.surriel.com
   - list.dnswl.org=127.0.[0..255].0*-2
   - list.dnswl.org=127.0.[0..255].1*-3
   - list.dnswl.org=127.0.[0..255].[2..3]*-4
- What to do when blacklisting? I currently set it to drop. We could
   - ignore: Ignore the failure of this test. Allow other tests to complete. Repeat this test the next time the client connects. This option is useful for testing and collecting statistics without blocking mail.
   - enforce: Allow other tests to complete. Reject attempts to deliver mail with a 550 SMTP reply, and log the helo/sender/recipient information. Repeat this test the next time the client connects.
   - drop: Drop the connection immediately with a 521 SMTP reply. Repeat this test the next time the client connects.

In the end I think we could drop postgrey support. Postscreen replaces postgrey in its entirety, while being more selective and not delaying mail. Especially if we consider using the deep inspection options of postscreen.

Hope that wasn't too much to read! ;)

* main.cf got misformatted..
Don't know how, should be ok now.

* fixed malformatted main.cf & repaired master.cf

* reenabled rbl stuff.. It's cached, therefore doesn't hurt

* fixed tests

* added tests, repaired tests, added info, introduced new Variable POSTSCREEN_ACTION, fixes
2018-02-04 21:31:08 +01:00
Marek Walczak b4b19e76b7 Stretch backport (#813)
* install dovecot from backports

* dovecot 2.2.33 has a slightly different TLS-configuration than 2.2.27

* want to have both images a the same time

* make use of the /etc/dovecot/ssl as mkcert.sh (2.2.33) is using that folder for certs.
2018-02-04 21:27:47 +01:00
17Halbe c2f4220016 fail2ban handling integrated in setup.sh (#797)
* fail2ban handling integrated in setup.sh

- calling \"./setup debug fail2ban\" lists all iptable chains whith blocked IPs (like: Banned in dovecot: 91.200.12.164
										       Banned in postfix-sasl: 91.200.12.164)
- calling \"./setup debug fail2ban unban xxx.xxx.xxx.xxx [yyy.yyy.yyy.yyy ...]\" unbans/removes those IPs from all jails.
- calling \"./setup debug fail2ban unban\" (without an IP) gives an descriptive error: (You need to specify an IP address. Run "./setup.sh debug fail2ban" to get a list of banned IP addresses.)

* disable_vrfy_command: (#798)

Prevents Spammers from collecting existing mail-addresses by probing the mailserver for them.

* Added support for Dovecot and Postfix LDAP TLS (#800)

* Allow setup of LDAP STARTTLS for Dovecot and Postfix

* Added tests for TLS config override

* Add missing Postfix TLS options

* Added missing new line at the end of the file

* Added STARTTLS tests for Postfix config

* tests added
and made the script output look more shiny.

* setup.sh enhancements
2018-01-31 22:25:29 +01:00
Mathieu Brunot d270fcdd40 Added support for Dovecot and Postfix LDAP TLS (#800)
* Allow setup of LDAP STARTTLS for Dovecot and Postfix

* Added tests for TLS config override

* Add missing Postfix TLS options

* Added missing new line at the end of the file

* Added STARTTLS tests for Postfix config
2018-01-25 22:38:41 +01:00
Marek Walczak 49b3867c1b debian stretch slim (#784)
* Switch to stretch-slim as base image.
 - first step correct the testdata, as newer packages are more strict
about the mail-structure.

* Switch to stretch-slim: correcting the test-environment and the build
 - add missing build-step to make
 - clean the userdb aswell
 - use timeout of netcat, as postgrey would not close the connection
 - there is 2 extra mail-logs -> assert_output 5
 - cosmetic: use "" instead of ''

* Switch to stretch-slim:
new image:
 - smaller size
 - 0 CVEs compared to 11 CVEs in ubuntu 16.04 Image
better backport situation
 - postfix 3.1.6 vs 3.1.0
 - fail2ban 0.9.6 vs 0.9.3
 ...
changes needed because of stretch-slim:
- add missing gnupg and iproute2 package
- remove non-free rar, unrar-free should do
- rsyslog does not add syslog user and has different conf-structure
- pyzor command discover was deprecated and is missing in the new
stretch package

- dovecot does not know SSLv2 anymore. removed because of warnings in
log

- iptables does not know imap3, IMAP working group chose imap2 in favor
of imap3

* Switch to debian stretch slim:
SSLv2 seems to be a not known protocol anymore - good!

* switch to debian stretch slim:
make this test more stable. there might be more than only one mail.log
(mail.info, mail.warn, ...)

* switch to debian stretc slim:
 new openssl 1.1.0 needs stronger ciphers, removed some weekers ones.
Please, look through the new list of cipher! this needs to be done in
another commit for all other SSL/TLS-Endpoints aswell.

* Switch to debian stretch slim:
let our server pre-empt the cipher list.
Did a read through, wwwDOTpostfixDOTorg/FORWARD_SECRECY_READMEDOThtml
and
wwwDOTpostfixDOTorg/TLS_READMEDOThtml

* Switch to debian stretch slim: lets give this openssl-based test a new and independent but identical container.  many other test on the main 'mail' container might interfere here.

* Switch to debian stretch slim: remove unused lines
2017-12-31 12:33:48 +01:00
Marek Walczak d62ea049e6 Add ability to override fail2ban.conf with fail2ban.local values. (#769)
* Add ability to override fail2ban.conf with fail2ban.local values.
2017-12-07 19:27:31 +01:00
kamuri 420e7741a1 Check for account changes and reload (Closes: #552)
Restart the daemons when changes are made to 'postfix-account.cf' and/or 'postfix-virtual.cf'
2017-10-10 08:15:18 +02:00
Hannu Shemeikka 984537526a New command: generate-dkim-domain
This command can be used for generating DKIM key for a domain,
which is not included in any configuration files. For example,
when using SQL database for transport maps.
2017-09-09 23:35:26 +03:00
Johan Smits 4cb8f4d4ae Improve the privacy of the client by removing sensitive details 2017-09-07 19:29:50 +02:00
Johan Smits 0fe86e796b Listen also on the ssl port 465 for clients (#709) 2017-09-07 18:08:25 +02:00
Johan Smits 9978bccbb6 Also test on the submission port if the login is succesful (#685)
Fixed location so that opendkim is happy with the correct
file location
2017-08-19 10:32:47 +02:00
Johan Smits 04904e77c4 Also search on the domain name for the virtual domain name in the ldap (Solves: #638) (#642)
Added test to check email delivery for a other domain then the primary
of the mailserver.
2017-08-19 10:32:00 +02:00
Johan Smits 9e7959fafe Issue 631 run services with supervisor (#676)
* installed supervisor. Still need to set tasks to run in foreground.

* setting programs to run in foreground

* seems to work now

* cleanup

* final fixes

* tests

* show startup output on stdout

* set Dovecot config files before starting it

* make all processes log to console

* Use the supervisor as the main process. The start-mailserver is started
from the supervisord and then this process triggers others.

Defined some default variable in the Dockerfile. In order for
supervisored to build the command lines the ENV variable need to be set.
Therefore the defaults are defined.

Some processes are not single processes like postfix and fail2ban and
they have a wrapper. The wrapper takes care of proper shutdown and checking
if the process is running or not. Supervisored will restart the wrapping
script if the process is gone.

Increased some delays between tests because sometimes they where to short
for all containers to be running.

* Remove obsolete comments, reset timeout value to old one, added new lines

* Add more time for analyzing the emails.

Sometimes it fails the tests and gives a wrong state about
the test. During testing 40 seconds was the safe value.
2017-08-07 17:39:40 +02:00
Johan Smits 8b19d54218 Expand the decoders for amavis (Resolves: #659) (#677)
Use the guidelines from Ubuntu and added some more.
Added a test to ensure the number of decoders are present.
Guideline: https://help.ubuntu.com/community/PostfixAmavisNew
2017-08-07 17:37:16 +02:00
Daniel Panteleit 60afbe1d16 Disable logrotate and cron job for updating clamav if clamav is disabled (fixes #660) (#667) 2017-07-23 21:31:41 +02:00
alinmear 21fb3f3c86 Fix ldap related critical Problems (#644)
* Fix Dovecot Ldap Problems
* Fix typo within DEFAULT_VARS Definitions
* Fix wrong ldap hosts value within the bats test
* Fix override_config for strings containing &
* Fix erroneous removal of an conditional within the postfix override function
* Renamed Test 129, to be clear that this belongs to ldap
* Fix mail_with_ldap setting dn pass explicit
* Add 3 env variables for ldap: LDAP_QUERY_FILTER_{USER,GROUP,ALIAS}
* Update README.md
2017-07-03 13:16:15 +02:00
Alexander Elbracht 5a86193dbf Environment variable for amavis subject tag (#596)
* Environment variable for spam subject tag
* Add SA_SPAM_SUBJECT to readme
* Add integration tests for spam subject tag
* Fix overwrite environment variable in config file
2017-06-23 21:50:01 +02:00