mirror of
https://github.com/mjl-/mox.git
synced 2025-07-10 06:34:40 +03:00
change mox to start as root, bind to network sockets, then drop to regular unprivileged mox user
makes it easier to run on bsd's, where you cannot (easily?) let non-root users bind to ports <1024. starting as root also paves the way for future improvements with privilege separation. unfortunately, this requires changes to how you start mox. though mox will help by automatically fix up dir/file permissions/ownership. if you start mox from the systemd unit file, you should update it so it starts as root and adds a few additional capabilities: # first update the mox binary, then, as root: ./mox config printservice >mox.service systemctl daemon-reload systemctl restart mox journalctl -f -u mox & # you should see mox start up, with messages about fixing permissions on dirs/files. if you used the recommended config/ and data/ directory, in a directory just for mox, and with the mox user called "mox", this should be enough. if you don't want mox to modify dir/file permissions, set "NoFixPermissions: true" in mox.conf. if you named the mox user something else than mox, e.g. "_mox", add "User: _mox" to mox.conf. if you created a shared service user as originally suggested, you may want to get rid of that as it is no longer useful and may get in the way. e.g. if you had /home/service/mox with a "service" user, that service user can no longer access any files: only mox and root can. this also adds scripts for building mox docker images for alpine-supported platforms. the "restart" subcommand has been removed. it wasn't all that useful and got in the way. and another change: when adding a domain while mtasts isn't enabled, don't add the per-domain mtasts config, as it would cause failure to add the domain. based on report from setting up mox on openbsd from mteege. and based on issue #3. thanks for the feedback!
This commit is contained in:
@ -43,11 +43,15 @@ func TestDeliver(t *testing.T) {
|
||||
mox.Shutdown, mox.ShutdownCancel = context.WithCancel(context.Background())
|
||||
|
||||
// Remove state.
|
||||
os.RemoveAll("testdata/integration/run")
|
||||
os.MkdirAll("testdata/integration/run", 0750)
|
||||
os.RemoveAll("testdata/integration/data")
|
||||
os.MkdirAll("testdata/integration/data", 0750)
|
||||
|
||||
// Cleanup afterwards, these are owned by root, annoying to have around due to
|
||||
// permission errors.
|
||||
defer os.RemoveAll("testdata/integration/data")
|
||||
|
||||
// Load mox config.
|
||||
mox.ConfigStaticPath = "testdata/integration/mox.conf"
|
||||
mox.ConfigStaticPath = "testdata/integration/config/mox.conf"
|
||||
filepath.Join(filepath.Dir(mox.ConfigStaticPath), "domains.conf")
|
||||
if errs := mox.LoadConfig(mox.Context); len(errs) > 0 {
|
||||
t.Fatalf("loading mox config: %v", errs)
|
||||
@ -69,14 +73,15 @@ func TestDeliver(t *testing.T) {
|
||||
createAccount("moxtest3@mox3.example", "pass1234")
|
||||
|
||||
// Start mox.
|
||||
mtastsdbRefresher := false
|
||||
err := start(mtastsdbRefresher)
|
||||
const mtastsdbRefresher = false
|
||||
const skipForkExec = true
|
||||
err := start(mtastsdbRefresher, skipForkExec)
|
||||
tcheck(t, err, "starting mox")
|
||||
|
||||
// todo: we should probably hook store.Comm to get updates.
|
||||
latestMsgID := func(username string) int64 {
|
||||
// We open the account index database created by mox for the test user. And we keep looking for the email we sent.
|
||||
dbpath := fmt.Sprintf("testdata/integration/run/accounts/%s/index.db", username)
|
||||
dbpath := fmt.Sprintf("testdata/integration/data/accounts/%s/index.db", username)
|
||||
db, err := bstore.Open(dbpath, &bstore.Options{Timeout: 3 * time.Second}, store.Message{}, store.Recipient{}, store.Mailbox{}, store.Password{})
|
||||
if err != nil && errors.Is(err, bolt.ErrTimeout) {
|
||||
log.Printf("db open timeout (normal delay for new sender with account and db file kept open)")
|
||||
|
Reference in New Issue
Block a user