summary refs log tree commit diff
path: root/nixos/modules/services/mail
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2017-09-17 03:11:01 +0200
committeraszlig <aszlig@redmoonstudios.org>2017-09-17 04:57:20 +0200
commit3ba2095a42af1caa2b9a22cd2d3a0b24f72ccda8 (patch)
tree68b60d5042c77acd2a4113d61b5c1324361bc5df /nixos/modules/services/mail
parent222e18698a5a6b92085d7ed1b307e74878a00c8e (diff)
downloadnixlib-3ba2095a42af1caa2b9a22cd2d3a0b24f72ccda8.tar
nixlib-3ba2095a42af1caa2b9a22cd2d3a0b24f72ccda8.tar.gz
nixlib-3ba2095a42af1caa2b9a22cd2d3a0b24f72ccda8.tar.bz2
nixlib-3ba2095a42af1caa2b9a22cd2d3a0b24f72ccda8.tar.lz
nixlib-3ba2095a42af1caa2b9a22cd2d3a0b24f72ccda8.tar.xz
nixlib-3ba2095a42af1caa2b9a22cd2d3a0b24f72ccda8.tar.zst
nixlib-3ba2095a42af1caa2b9a22cd2d3a0b24f72ccda8.zip
nixos/dovecot: Fix createMailUser implementation
This option got introduced in 7904499542814b8a4d04fce8dc7ca8c383c083e7
and it didn't check whether mailUser and mailGroup are null, which they
are by default.

Now we're only creating the user if createMailUser is set in conjunction
with mailUser and the group if mailGroup is set as well.

I've added a NixOS VM test so that we can verify whether dovecot works
without any additional options set, so it serves as a regression test
for issue #29466 and other issues that might come up with future changes
to the Dovecot service.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Fixes: #29466
Cc: @qknight, @abbradar, @ixmatus, @siddharthist
Diffstat (limited to 'nixos/modules/services/mail')
-rw-r--r--nixos/modules/services/mail/dovecot.nix13
1 files changed, 8 insertions, 5 deletions
diff --git a/nixos/modules/services/mail/dovecot.nix b/nixos/modules/services/mail/dovecot.nix
index 135d3b277378..6057acc531a3 100644
--- a/nixos/modules/services/mail/dovecot.nix
+++ b/nixos/modules/services/mail/dovecot.nix
@@ -9,6 +9,8 @@ let
   baseDir = "/run/dovecot2";
   stateDir = "/var/lib/dovecot";
 
+  canCreateMailUserGroup = cfg.mailUser != null && cfg.mailGroup != null;
+
   dovecotConf = concatStrings [
     ''
       base_dir = ${baseDir}
@@ -314,17 +316,18 @@ in
            description = "Dovecot user";
            group = cfg.group;
          }
-      ++ optional cfg.createMailUser
-         { name = cfg.mailUser;
-           description = "Virtual Mail User";
+      ++ optional (cfg.createMailUser && cfg.mailUser != null)
+         ({ name = cfg.mailUser;
+            description = "Virtual Mail User";
+         } // optionalAttrs (cfg.mailGroup != null) {
            group = cfg.mailGroup;
-         };
+         });
 
     users.extraGroups = optional (cfg.group == "dovecot2")
       { name = "dovecot2";
         gid = config.ids.gids.dovecot2;
       }
-    ++ optional cfg.createMailUser
+    ++ optional (cfg.createMailUser && cfg.mailGroup != null)
       { name = cfg.mailGroup;
       };