Commit Graph

100 Commits

Author SHA1 Message Date
Guillaume Girol
17fc67eb2e
Merge pull request #255464 from georgyo/postfix-dont-use-file-ownership
nixos/postfix: postalias should not use source file permissions
2023-12-31 15:20:48 +01:00
George Shammas
142d83f90e
nixos/postfix: postalias should not use source file permissions
Our postfix-setup service ensures that the directory is only writable by root.

postalias by default drops permissions to the user of the source file. In the
case of NixOS that file is in the nix store and thus always owned by root and
everything works.

The problem is that when using a nixos-container with user namespaces (`-U`)
then the nix store is owned by nobody/nogroup, and postfix-setup.service will be
unable to create or modify `aliases.db`.

Since the file would otherwise be owned by root, we should tell postfix to not
assume the user and permissions of the `aliases` file by setting -o and -p

From postalias(1)

> -o Do not release root privileges when processing a non-root input file. By
> default, postalias(1) drops root privileges and runs as the source file owner
> instead.

> -p Do not inherit the file access permissions from the input file when
> creating a new file. Instead, create a new file with default access
> permissions (mode 0644).
2023-09-16 08:22:45 -04:00
Tom Fitzhenry
dd1b3b077a nixos/postfix: add systemd hardening directives
Inspired by
a9ccc48242/mail-mta/postfix/files/postfix.service

This decreases the systemd-analyze exposure level from UNSAFE to MEDIUM:

```
$ systemd-analyze security --offline=true postfix-hardened.service | grep Overall
→ Overall exposure level for postfix-hardened.service: 6.2 MEDIUM 😐

$ systemd-analyze security --offline=true postfix-original.service | grep Overall
→ Overall exposure level for postfix-original.service: 9.6 UNSAFE 😨
```
2023-09-16 06:37:00 +10:00
Felix Buehler
327b0cff7a treewide: use more lib.optionalString 2023-04-07 13:38:33 +02:00
Stefan Frijters
11fa179533
nixos/postfix: restrict inet_protocols to ipv4 when ipv6 is disabled
In the previous state, postfix would still try to use IPv6 addresses,
even when it is disabled in the global networking config.

Cf. https://www.postfix.org/postconf.5.html:

  With Postfix 2.8 and earlier the default is "ipv4". For backwards compatibility with these releases,
  the Postfix 2.9 and later upgrade procedure appends an explicit "inet_protocols = ipv4" setting to
  main.cf when no explicit setting is present.
  This compatibility workaround will be phased out as IPv6 deployment becomes more common.

  inet_protocols = ipv4
  inet_protocols = all (DEFAULT)
  inet_protocols = ipv6
  inet_protocols = ipv4, ipv6

So setting it to 'all' conditionally does not help, as we are now on version 3.x.
2023-02-03 11:29:24 +01:00
figsoda
6bb0dbf91f nixos: fix typos 2022-12-17 19:31:14 -05:00
pennae
515c4727fa nixos/*: md-"convert" empty descriptions
for some reason these are not picked up properly by nix-doc-munge, so
we'll do this instead.
2022-08-31 16:32:54 +02:00
pennae
9547123258 nixos/*: convert internal option descriptions to MD
we'll have to do it eventually, may as well be now.
2022-08-31 16:32:54 +02:00
pennae
6039648c50 nixos/*: automatically convert option docs 2022-08-19 22:40:58 +02:00
pennae
b51f8036c2 nixos/*: use properly indented strings for option docs
using regular strings works well for docbook because docbook is not as
whitespace-sensitive as markdown. markdown would render all of these as
code blocks when given the chance.
2022-08-19 22:40:58 +02:00
pennae
087472b1e5 nixos/*: automatically convert option docs 2022-08-06 20:39:12 +02:00
pennae
423545fe48 nixos/*: normalize manpage references to single-line form
now nix-doc-munge will not introduce whitespace changes when it replaces
manpage references with the MD equivalent.

no change to the manpage, changes to the HTML manual are whitespace only.
2022-08-05 18:34:50 +02:00
pennae
2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00
Alyssa Ross
27530ba856
nixos/postfix: make postfix-setup RemainAfterExit
Otherwise, it wouldn't get restarted when a new system configuration
was activatad, so the Postfix configuration wouldn't be updated.

Fixes: fb2fa1b50f ("nixos/postfix: pull setup into its own unit")
2022-05-22 10:33:22 +00:00
Alyssa Ross
fb2fa1b50f
nixos/postfix: pull setup into its own unit
Consider a service that generates postfix lookup tables with
postmap(1), like Mailman.  It needs the Postfix configuration file to
exist, but Postfix qmgr needs all the lookup tables its configured
with to exist before it starts.  So the service that runs postmap
needs to run after the Postfix configuration and directory structure
is generated, but before Postfix itself is started.  To enable this,
we split Postfix into two units: a oneshot unit that sets up the
configuration, and a longrun unit that supervises the Postfix
daemons.  The postmap services can then be inserted in between these
two units.
2022-04-05 10:24:34 +00:00
Travis Athougies
82037871bb
nixos/postfix: Use better types for submissionOptions and submissionsOptions (#138205) 2021-11-12 17:28:39 +01:00
Michele Guerini Rocco
e99b3f242c
Merge pull request #140359 from rnhmjoj/setgid-nobody
nixos: make setgid wrappers root-owned
2021-10-06 08:36:35 +02:00
Naïm Favier
2ddc335e6f
nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
rnhmjoj
31790c81dc
nixos: make setgid wrappers root-owned 2021-10-03 11:44:57 +02:00
V
cc49c13a6b nixos/postfix: Fix virtual alias manpage section
virtual(8) is for virtual mailboxes, not aliases.
2021-09-27 06:39:27 +02:00
rnhmjoj
8f76a6eefc
nixos: add implict security.wrappers options
This is to keep the same permissions/setuid/setgid as before the change
in security.wrappers defaults.
2021-09-13 13:48:13 +02:00
Ben Siraphob
b63a54f81c
Merge pull request #110742 from siraben/deprecate-fold 2021-07-27 15:13:31 +07:00
Luke Granger-Brown
649672e76e nixos/postfix: fix compatibility level
Postfix has started outputting an error on startup that it can't parse
the compatibility level 9999.

Instead, just set the compatibility level to be identical to the current
version, which seems to be the (new) intent for the compatibility level.
2021-05-02 21:49:33 +00:00
Alyssa Ross
d45fc07bc2 nixos/postfix: add services.postfix.canonical opt
This mirrors the services.postfix.transport and
services.postfix.virtual options we already have.
2021-04-11 00:31:12 +00:00
Fritz Otlinghaus
8de8e40d64
nixos/postfix: add types (#111426) 2021-01-31 13:52:46 +01:00
Ben Siraphob
1c2a2b0a08 treewide: fold -> foldr 2021-01-26 10:57:07 +07:00
Alyssa Ross
011d073393 nixos/postfix: deprecate services.postfix.useDane
Now that smtp_tls_security_level is using mkDefault, and therefore can
be overridden, there's no need for an option for overriding it to a
specific value.
2021-01-14 10:24:31 +00:00
Alyssa Ross
9ed5ee909b nixos/postfix: allow custom smtp_tls_security_level
I run Postfix on my workstation as a smarthost, where it only ever
talks to my SMTP server.  Because I know it'll only ever connect to
this server, and because I know this server supports TLS, I'd like to
set smtp_tls_security_level to "encrypt" so Postfix won't fall back to
an unencrypted connection.
2021-01-14 10:24:31 +00:00
Marc 'risson' Schmitt
27dacb8b4b
nixos/postfix: fix masterCf type
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
2020-12-10 18:49:05 +01:00
Viktor Kleen
6216c843ed
nixos/postfix: make postfix.enableSmtp work again
This fixes issue #104715.
2020-11-23 23:46:06 +00:00
Matt McHenry
a45f1453eb postfix: add useDane config option 2020-08-12 21:18:36 -04:00
lewo
9534da25bf
Merge pull request #90115 from asbachb/postfix-tls
postfix: Replaced config key by recommendation and introduced usage of system trust store
2020-07-09 20:29:49 +02:00
Eric Wolf
8af58eda12
postfix: Add submissions option for postfix and test (#91691)
RFC 8314 suggests, for end user submission of
mails, SMTP over TLS on port 465 should be used.

Closes #91690
2020-07-06 03:37:56 +02:00
Benjamin Asbach
632104e5a4 postfix: deprecated sslCACert in favour of tlsTrustedAuthorities
`sslCACert` was used for trust store of client and server certificates. Since `smtpd_tls_ask_ccert` defaults to no the setup of `smtpd_tls_CApath` was removed.

>By default (see smtpd_tls_ask_ccert), client certificates are not requested, and smtpd_tls_CApath should remain empty.
see http://www.postfix.org/postconf.5.html#smtpd_tls_CAfile
2020-07-05 14:53:34 +02:00
Benjamin Asbach
9d697837f0 postfix: used recommended configuration key to enable tls
> With Postfix 2.3 and later use smtp_tls_security_level instead.

http://www.postfix.org/postconf.5.html#smtp_use_tls
2020-07-05 14:50:40 +02:00
Dominik Xaver Hörl
c10d82358f treewide: add types to boolean / enable options or make use of mkEnableOption 2020-04-27 09:32:01 +02:00
Jan Tojnar
e85b34c484
tree-wide: fix more warning related to loaOf deprecation 2020-01-11 08:09:56 +01:00
Milan Pässler
2a31a6a412 tree-wide: fix errors and warning related to loaOf deprecation 2020-01-07 06:23:28 +01:00
rnhmjoj
1d61efb7f1 treewide: use attrs instead of list for types.loaOf options 2020-01-06 10:39:18 -05:00
Alyssa Ross
7813c249ef
nixos/postfix: add missing setgid wrapper
This is basically an alias for a special case of postqueue, which
already has a setgid wrapper.  Would be silly to allow postqueue -p
but not mailq.
2019-11-13 15:31:32 +00:00
Vladimír Čunát
f21211ebfe
Merge branch 'master' into staging 2019-09-02 23:25:24 +02:00
Silvan Mosberger
478e7184f8
nixos/modules: Remove all usages of types.string
And replace them with a more appropriate type

Also fix up some minor module problems along the way
2019-08-31 18:19:00 +02:00
Peter Simons
eedf3dc6e2 nixos/mailman: decouple the mailman module from the postfix module
https://github.com/NixOS/nixpkgs/pull/67708#discussion_r319579987 suggested
that simply appending the necessary maps to the appropriate attributes in
services.postfix.config gets the job done; we don't special support in the
postfix module to accomplish that.
2019-08-30 18:44:47 +02:00
Peter Simons
c1c1ce7221 mailman: add NixOS module to install and deploy the mailing list server 2019-08-29 20:29:35 +02:00
volth
35d68ef143 treewide: remove redundant quotes 2019-08-26 21:40:19 +00:00
Silvan Mosberger
88bb9fa403
nixos/modules: Replace all nested types.either's with types.oneOf's 2019-08-08 23:35:52 +02:00
Peter Simons
59bacaca3d nixos: add 'localRecipients' config option for Postfix
The new option services.postfix.localRecipients allows
configuring the postfix option 'local_recipient_maps'. When
set to a list of user names (or patterns), that map
effectively replaces the lookup in the system's user
database that's used by default to determine which local
users are valid.

This option is useful to explicitly set local users that are
allowed to receive e-mail from the outside world. For local
injection i.e. via the 'sendmail' command this option has no
effect.
2019-07-15 17:36:20 +02:00
Jörg Thalheim
91ddc9d27f
postfix: add setgid wrapper for postqueue/postdrop
Both postqueue[1] and postdrop[2] implement a subset of administration
task that are supposed to be run unprivileged users
and require the setgid bit to full-fill this task.

[1] http://www.postfix.org/postqueue.1.html
[2] http://www.postfix.org/postdrop.1.html
2018-10-15 13:14:41 +01:00
Florian Klink
fff5923686 nixos/modules: users.(extraUsers|extraGroup->users|group) 2018-06-30 03:02:58 +02:00
Bjørn Forsman
d84f18e288 nixos/postfix: document that *Alias options support comma separated values
For the longest time I thought there could be only one rootAlias.
2018-02-18 13:04:08 +01:00