Qualify user names

This commit is contained in:
John Boehr 2017-11-09 14:17:03 -08:00
parent bbca0bd678
commit f372754052
No known key found for this signature in database
GPG key ID: 73B8EFB60708F699
7 changed files with 30 additions and 23 deletions

View file

@ -14,10 +14,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
{ config }:
{ config, lib }:
let
cfg = config.mailserver;
inherit (lib.strings) stringToCharacters;
in
{
# cert :: PATH
@ -37,4 +38,10 @@ in
else if cfg.certificateScheme == 3
then "/var/lib/acme/mailserver/key.pem"
else throw "Error: Certificate Scheme must be in { 1, 2, 3 }";
# appends cfg.domain to argument if it does not contain "@"
qualifyUser = user: (
if (builtins.any (c: c == "@") (stringToCharacters user))
then user
else "${user}@${cfg.domain}");
}