Skip to content

Commit

Permalink
Make it easier to avoid permission issues when setting up maddy
Browse files Browse the repository at this point in the history
1. Clarify that you need to manually create the user and group
when building from source. ./build.sh does not do that since
it is a packaging tool, not system configuration one.

2. Do not require "go" command to be present when running
./build.sh install. go installation may be user-specific and
unavailable when running with sudo.

3. Ease UMask restrictions. Allow group access.
This allows CLI commands to be run by any user in maddy group.

See #569.
  • Loading branch information
foxcpp committed Jan 21, 2024
1 parent a2f8916 commit 28bdf6d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
21 changes: 17 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,23 @@ install() {
# Attempt to install systemd units only for Linux.
# Check is done using GOOS instead of uname -s to account for possible
# package cross-compilation.
if [ "$(go env GOOS)" = "linux" ]; then
command install -m 0755 -d "${destdir}/${prefix}/lib/systemd/system/"
command install -m 0644 "${builddir}"/systemd/*.service "${destdir}/${prefix}/lib/systemd/system/"
fi
# Though go command might be unavailable if build.sh is run
# with sudo and go installation is user-specific, so fallback
# to using uname -s in the end.
set +e
if command -v go >/dev/null 2>/dev/null; then
set -e
if [ "$(go env GOOS)" = "linux" ]; then
command install -m 0755 -d "${destdir}/${prefix}/lib/systemd/system/"
command install -m 0644 "${builddir}"/systemd/*.service "${destdir}/${prefix}/lib/systemd/system/"
fi
else
set -e
if [ "$(uname -s)" = "Linux" ]; then
command install -m 0755 -d "${destdir}/${prefix}/lib/systemd/system/"
command install -m 0644 "${builddir}"/systemd/*.service "${destdir}/${prefix}/lib/systemd/system/"
fi
fi

if [ -e "${builddir}"/man ]; then
command install -m 0755 -d "${destdir}/${prefix}/share/man/man1/"
Expand Down
5 changes: 3 additions & 2 deletions dist/systemd/maddy.service
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ KillSignal=SIGTERM
AmbientCapabilities=CAP_NET_BIND_SERVICE
CapabilityBoundingSet=CAP_NET_BIND_SERVICE

# Force all files created by maddy to be only readable by it.
UMask=0027
# Force all files created by maddy to be only readable by it
# and maddy group.
UMask=0007

# Bump FD limitations. Even idle mail server can have a lot of FDs open (think
# of idle IMAP connections, especially ones abandoned on the other end and
Expand Down
5 changes: 3 additions & 2 deletions dist/systemd/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ KillSignal=SIGTERM
AmbientCapabilities=CAP_NET_BIND_SERVICE
CapabilityBoundingSet=CAP_NET_BIND_SERVICE

# Force all files created by maddy to be only readable by it.
UMask=0027
# Force all files created by maddy to be only readable by it and
# maddy group.
UMask=0007

# Bump FD limitations. Even idle mail server can have a lot of FDs open (think
# of idle IMAP connections, especially ones abandoned on the other end and
Expand Down
10 changes: 6 additions & 4 deletions docs/tutorials/building-from-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ $ git clone https://github.com/foxcpp/maddy.git
$ cd maddy
```

3. Select the appropriate version to build:
2. Select the appropriate version to build:
```
$ git checkout v0.7.0 # a specific release
$ git checkout master # next bugfix release
$ git checkout dev # next feature release
```

2. Build & install it
3. Build & install it
```
$ ./build.sh
# ./build.sh install
$ sudo ./build.sh install
```

3. Have fun!
4. Finish setup as described in [Setting up](../setting-up) (starting from System configuration).


3 changes: 3 additions & 0 deletions docs/tutorials/setting-up.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ storage account:
$ maddy imap-acct create [email protected]
```

Note: to run `maddy` CLI commands, your user should be in the `maddy`
group. Alternatively, just use `sudo -u maddy`.

That is it. Now you have your first e-mail address. when authenticating using
your e-mail client, do not forget the username is "[email protected]", not
just "postmaster".
Expand Down

0 comments on commit 28bdf6d

Please sign in to comment.