Skip to content

Implement initial support for shared mailboxes.#1643

Closed
matejak wants to merge 3 commits intodocker-mailserver:masterfrom
EnterpriseyIntranet:shared_mailboxes
Closed

Implement initial support for shared mailboxes.#1643
matejak wants to merge 3 commits intodocker-mailserver:masterfrom
EnterpriseyIntranet:shared_mailboxes

Conversation

@matejak
Copy link
Copy Markdown

@matejak matejak commented Oct 8, 2020

This PR aims to evolve into a mergeable implementation of support needed to run docker-mailserver with shared inboxes. See #1625 This PR is a draft, so if you decide to give feedback, go for the big picture - a more thorough feedback will become appropriate as the PR gets polished and tested.

The PR uses following means to implement the functionality:

  • The 10-mail.conf has been split in two - the original 10-mail.conf and 11-shared.conf. The new file contains configuration that has been commented out in the former file. Contents of the file are commented in a specific way that allows for fully automated uncomment in case of automated setup, or for noop in case that the file is persistent and you have edited it manually.

  • New env variables have been added:

    • DOVECOT_NAMESPACE_SEPARATOR - historically, this has not been defined, but you need to define it to use shared inboxes. Slash seems to be a good separator.
    • DOVECOT_ENABLE_INBOX_SHARING - leave blank or set to 0 to disable, anything else means enable.

    If those are left untouched, the newly implemented functionality doesn't change the setup in any way, i.e. the change is backwards-compatible.

  • The startup script substitutes the value of the namespace separator into both new config files, and it uncomments sections of the sharing-related config file if this functionality is requested.

  • A script that facilitates inbox sharing has been introduced - share_inbox.sh

Steps that the user is supposed to take:

  • Define sharing dictionaries - that could be maybe outsourced to a variable as well, but I don't have the expertise to propose this ATM. It is enough to have this snippet in dovecot.cf:

    plugin {
     acl_shared_dict = file:/var/mail/dictionary/dict-acl
    }
    
  • Share inboxes by executing the script in the container (or calling the container's doveadm directly), e.g.

    docker-compose exec mail /usr/local/bin/share_inbox.sh office alice lookup read write write-seen
    
  • Make the sharing config file persistent, and customize it (optional).

Anyway, if you configure the inbox that can access shared inboxes with Thunderbird, you will be able to subscribe to inboxes that are shared to you.

@matejak matejak changed the title Implemented initial support for shared mailboxes. Implement initial support for shared mailboxes. Oct 8, 2020
@georglauterbach
Copy link
Copy Markdown
Member

georglauterbach commented Oct 9, 2020

Great work. I'm looking forward to merging this when it's done!

PS: Be aware that there are two tests in particular which will fail for no apparent reason. This is 260 login and a quota test. At the moment, you'll need to re-trigger the tests with another push. This is being worked on in another PR.

PPS: Please also note this feature in the features list in the README

@padrino121
Copy link
Copy Markdown

Great feature addition! I just jumped in to see if I could work this addition as well..

@matejak
Copy link
Copy Markdown
Author

matejak commented Oct 12, 2020

The first version of this PR was broken, but it should work now.

@matejak matejak marked this pull request as ready for review October 15, 2020 14:19
@georglauterbach
Copy link
Copy Markdown
Member

georglauterbach commented Oct 15, 2020

@matejak Not sure why, but the build / test is somehow completely broken!? :D

@matejak
Copy link
Copy Markdown
Author

matejak commented Oct 15, 2020

Local build worked for me, but I think that those checks require config files to be valid even before start-mailserver.sh is executed.

Copy link
Copy Markdown
Member

@georglauterbach georglauterbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me

Comment thread target/start-mailserver.sh Outdated
Comment thread target/share_inbox.sh Outdated
Comment thread target/start-mailserver.sh Outdated
Comment thread target/start-mailserver.sh Outdated
Comment thread target/start-mailserver.sh Outdated
@georglauterbach
Copy link
Copy Markdown
Member

What's the current status on this PR? Checks are failing.

@matejak
Copy link
Copy Markdown
Author

matejak commented Nov 2, 2020

Could you help me to pinpoint what's wrong? I am pretty sure that it is possible to build the image defined by the PR and to run it, and I was unable to spot what went wrong in my last modification.

@georglauterbach
Copy link
Copy Markdown
Member

I think I can. Could you provide a dummy commit (please change the README line where is says Why was this image was created? to Why this image was created.)

This test (not ok 253 checking quota: warn message received when quota exceeded) is known to be unstable.

@georglauterbach
Copy link
Copy Markdown
Member

@casperklein you think all is good here? @erik-wramner ?

I think this looks fine.

@georglauterbach
Copy link
Copy Markdown
Member

Alright, this PR looks fine. If we receive a review from @erik-wramner this can be merged into latest and will effectively be on stable in ~2 weeks.

@georglauterbach
Copy link
Copy Markdown
Member

It just occured to me (because of the label I set). I cannot see any tests. But I think this feature could be tested. I'm sorry to bother you again @matejak, but could you provide some?

PS: The conflct is due to a commit I put on master and can easily be resolved by just using the current master

@matejak
Copy link
Copy Markdown
Author

matejak commented Nov 5, 2020

... I cannot see any tests. ... could you provide some?

I would love to, but I will need some help from you how to get started. Is there some kind of documentation on how to write tests, and is there a "closest test" that could be used as a starting point?

@georglauterbach
Copy link
Copy Markdown
Member

georglauterbach commented Nov 5, 2020

I've not yet written any tests myself, just altered them. But I guess I can provide you with a starting point:

  1. Tests are located under test/ as .bats files
  2. These are executed one after another in the test stage:
tests:
	./test/bats/bin/bats test/*.bats
  1. Therefore you can just create a new file for the shared mailboxes and name it appropriately
  2. You can then have a look at all the other files
  3. All files follow a simple scheme:
load 'test_helper/common'

function setup() {
    run_setup_file_if_necessary
}

function teardown() {
    run_teardown_file_if_necessary
}

function setup_file() {
    local PRIVATE_CONFIG
    PRIVATE_CONFIG="$(duplicate_config_for_container .)"
    docker run -d --name mail_pop3 \
		-v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \
		-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
		-e ENABLE_POP3=1 \
		-e DMS_DEBUG=0 \
		-h mail.my-domain.com -t "${NAME}"

    wait_for_finished_setup_in_container mail_pop3
}

function teardown_file() {
    docker rm -f mail_pop3
}

@test "first" {
  skip 'this test must come first to reliably identify when to run setup_file'
}

#
# pop
#

@test "checking pop: server is ready" {
  run docker exec mail_pop3 /bin/bash -c "nc -w 1 0.0.0.0 110 | grep '+OK'"
  assert_success
}

...

@test "last" {
  skip 'this test is only there to reliably mark the end for the teardown_file'
}

where you can start a Container if you need one, remove it afterwards. The first and last test are markers, you could just copy-paste them if you like.

  1. In between are the tests, annotated with @test '<NAME>' {...
  2. There you can write the unit-tests with Bash
  3. The BATS (Bash Automated Testing System) will allow you to use special functions evaluating, i.e. success, failure, etc.
  4. If you need a special one, just look at the other test files: You will most likely find what you need there when looking for BATS helper

I will mention @martin-schulze-vireso here so he can read this as well. He might provide you with more information if I missed something:)

I think it's best if you just have a look at some test files in the beginning. As they are named in relation to what they are testing, you will most likely find one closely related to this topic. I would have to guess, but I'd start with test/mail_pop3.bats.

There is this "special case" with test/tests.bats. This is worked on mostly by @martin-schulze-vireso (He's improving the test system - that's why I referenced him). This file is very large (which it shouldn't be), but you might find some interesting tests related to Dovecot there as well.

PS EDIT: I have also removed the version 7.2 label and favor of the 7.3 as we have no hurry.

@georglauterbach georglauterbach added this to the 7.3-stable milestone Nov 5, 2020
@martin-schulze-vireso
Copy link
Copy Markdown
Contributor

I will mention @martin-schulze-vireso here so he can read this as well. He might provide you with more information if I missed something:)

I have nothing to add here. :)

There is this "special case" with test/tests.bats. This is worked on mostly by @martin-schulze-vireso (He's improving the test system - that's why I referenced him). This file is very large (which it shouldn't be), but you might find some interesting tests related to Dovecot there as well.

I did not really call dibs on that one. However, I concur that we should strive to get it smaller, so if there is no need to add to this file we should avoid it.

@georglauterbach
Copy link
Copy Markdown
Member

What's the status on this PR?

@erik-wramner
Copy link
Copy Markdown
Contributor

I approved it, but it seems to be waiting for tests?

@georglauterbach
Copy link
Copy Markdown
Member

I approved it, but it seems to be waiting for tests?

It is - I'm waiting on the authors response :)

@matejak
Copy link
Copy Markdown
Author

matejak commented Dec 13, 2020

Please bear with me, I am still interested, and I put high hopes into the X-mas break :-)

@georglauterbach
Copy link
Copy Markdown
Member

Closed due to migration to docker-mailserver/docker-mailserver. Please re-open over there :D

@georglauterbach
Copy link
Copy Markdown
Member

@matejak Since the old repository was merged, this could be re-opened. But there would be merge conflicts. Could you re-implement your changes from the current state of master. There was an issue that wanted this to be re-opened (#1777) but I can't because of the conflicts. I had forgotten this PR existed, sorry, because there was no activity for a long time.

Do we see a new PR from you? :)

@funktionierbar
Copy link
Copy Markdown

I would love to see this issue re-activated.

@georglauterbach
Copy link
Copy Markdown
Member

georglauterbach commented Feb 14, 2023

I would love to see this issue re-activated.

It's a PR, not an issue 😉 There have been too many changes since this was closed I'm afraid. I'd like to see the changes from this PR being applied to the current master; hence, this PR will not be re-opened. But we're not against introducing this change; please just open another PR. @funktionierbar you will also probably need to do this yourself or ask @matejak to help you / re-apply the changes himself; maintainers are currently working on others parts and they will not have time to implement this.

PS: There are already many many changes for the next major release (v12.0.0), so this may not be going into v12.0.0 (for which we already have a rough time frame too). We're currently waiting on reviews and we still need to refactor some tests, then we can release v12. So, unless the work for this is done this week and a new PR ready to be reviewed, the changes will go into v12.1.0 or later.

@polarathene
Copy link
Copy Markdown
Member

A feature request was raised, a contributor is interested in reviving this PR 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for shared mailboxes

8 participants