Skip to content

Commit 28bdf6d

Browse files
committed
Make it easier to avoid permission issues when setting up maddy
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.
1 parent a2f8916 commit 28bdf6d

File tree

5 files changed

+32
-12
lines changed

5 files changed

+32
-12
lines changed

build.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,23 @@ install() {
146146
# Attempt to install systemd units only for Linux.
147147
# Check is done using GOOS instead of uname -s to account for possible
148148
# package cross-compilation.
149-
if [ "$(go env GOOS)" = "linux" ]; then
150-
command install -m 0755 -d "${destdir}/${prefix}/lib/systemd/system/"
151-
command install -m 0644 "${builddir}"/systemd/*.service "${destdir}/${prefix}/lib/systemd/system/"
152-
fi
149+
# Though go command might be unavailable if build.sh is run
150+
# with sudo and go installation is user-specific, so fallback
151+
# to using uname -s in the end.
152+
set +e
153+
if command -v go >/dev/null 2>/dev/null; then
154+
set -e
155+
if [ "$(go env GOOS)" = "linux" ]; then
156+
command install -m 0755 -d "${destdir}/${prefix}/lib/systemd/system/"
157+
command install -m 0644 "${builddir}"/systemd/*.service "${destdir}/${prefix}/lib/systemd/system/"
158+
fi
159+
else
160+
set -e
161+
if [ "$(uname -s)" = "Linux" ]; then
162+
command install -m 0755 -d "${destdir}/${prefix}/lib/systemd/system/"
163+
command install -m 0644 "${builddir}"/systemd/*.service "${destdir}/${prefix}/lib/systemd/system/"
164+
fi
165+
fi
153166

154167
if [ -e "${builddir}"/man ]; then
155168
command install -m 0755 -d "${destdir}/${prefix}/share/man/man1/"

dist/systemd/maddy.service

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ KillSignal=SIGTERM
5454
AmbientCapabilities=CAP_NET_BIND_SERVICE
5555
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
5656

57-
# Force all files created by maddy to be only readable by it.
58-
UMask=0027
57+
# Force all files created by maddy to be only readable by it
58+
# and maddy group.
59+
UMask=0007
5960

6061
# Bump FD limitations. Even idle mail server can have a lot of FDs open (think
6162
# of idle IMAP connections, especially ones abandoned on the other end and

dist/systemd/maddy@.service

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ KillSignal=SIGTERM
5050
AmbientCapabilities=CAP_NET_BIND_SERVICE
5151
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
5252

53-
# Force all files created by maddy to be only readable by it.
54-
UMask=0027
53+
# Force all files created by maddy to be only readable by it and
54+
# maddy group.
55+
UMask=0007
5556

5657
# Bump FD limitations. Even idle mail server can have a lot of FDs open (think
5758
# of idle IMAP connections, especially ones abandoned on the other end and

docs/tutorials/building-from-source.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,19 @@ $ git clone https://github.com/foxcpp/maddy.git
3434
$ cd maddy
3535
```
3636

37-
3. Select the appropriate version to build:
37+
2. Select the appropriate version to build:
3838
```
3939
$ git checkout v0.7.0 # a specific release
4040
$ git checkout master # next bugfix release
4141
$ git checkout dev # next feature release
4242
```
4343

44-
2. Build & install it
44+
3. Build & install it
4545
```
4646
$ ./build.sh
47-
# ./build.sh install
47+
$ sudo ./build.sh install
4848
```
4949

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

docs/tutorials/setting-up.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ storage account:
246246
$ maddy imap-acct create postmaster@example.org
247247
```
248248
249+
Note: to run `maddy` CLI commands, your user should be in the `maddy`
250+
group. Alternatively, just use `sudo -u maddy`.
251+
249252
That is it. Now you have your first e-mail address. when authenticating using
250253
your e-mail client, do not forget the username is "postmaster@example.org", not
251254
just "postmaster".

0 commit comments

Comments
 (0)