initial commit

This commit is contained in:
muppeth 2021-07-19 07:03:05 +02:00
parent 5fd6796f03
commit e1565437e7
Signed by: muppeth
GPG Key ID: 0EBC7B9848D04031
13 changed files with 346 additions and 9 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.vagrant
.vagrant/*
*log

22
LICENSE
View File

@ -1,9 +1,19 @@
MIT License
MIT License Copyright (c) 2021 "Stichting Disroot.org"
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

11
Playbooks/lacre.yml Normal file
View File

@ -0,0 +1,11 @@
---
- hosts: lacre
roles:
# - role: mailserver
# tags:
# - postfix
- role: lacre
vars_files:
- ../defaults/main.yml

2
README.MD Normal file
View File

@ -0,0 +1,2 @@
**WIP**
Role that deploys, configures and upgrades GPG Lacre.

View File

@ -1,3 +0,0 @@
# lacre
Role that deploys lacre.io e2e mailbox encryption

18
Vagrantfile vendored Normal file
View File

@ -0,0 +1,18 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
#config.ssh.insert_key = false
config.vm.define "lacre" do |lacre|
lacre.vm.box = "generic/debian10"
lacre.vm.provider :libvirt do |libvirt|
libvirt.memory = 256
end
lacre.vm.network "private_network", ip: "192.168.33.13"
end
end

45
defaults/main.yml Normal file
View File

@ -0,0 +1,45 @@
---
lacre_repo: 'https://git.disroot.org/Disroot/gpg-lacre.git'
lacre_version: 'master'
lacre_app_dir: '/opt/gpg-lacre'
lacre_username: 'lacre'
lacre_group: 'lacre'
lacre_homedir: '/var/gpgmailgate/'
#lacre_
lacre_apt:
- 'python-m2crypto'
- 'git'
- 'gnupg'
lacre_set_content_filter: 'true'
#config file
lacre_add_header: 'yes'
lacre_enc_keymap_only: 'no'
lacre_dec_keymap_only: 'no'
lacre_failsave_dec: 'yes'
lacre_mime_conversion: 'yes'
lacre_mail_case_insensitive: 'no'
lacre_no_inline_dec: 'yes'
lacre_dec_regex: 'None'
lacre_keyhome: '/var/gpgmailgate/.gnupg'
lacre_cert_path: '/var/gpgmailgate/smime'
lacre_register_email: 'register@example.org'
lacre_mail_templates: '/var/gpgmailgate/register_templates'
lacre_webpanel_url: 'http://example.org'
lacre_notification_email: 'gpg-mailgate@example.org'
lacre_mail_templates: '/var/gpgmailgate/cron_templates'
lacre_verbose: 'yes'
lacre_relay: '127.0.0.1'
lacre_port: '10028'
lacre_enc_port: '25'
lacre_starttls: 'no'
lacre_db_enabled: 'no'
lacre_db_name: 'gpgmw'
lacre_db_host: 'localhost'
lacre_db_username: 'user'
lacre_db_password: 'password'
#mailserver vars
postfix_header_checks: 'false'
postfix_body_checks: 'false'
postfix_rbl_whitelist: 'false'
postfix_postgrey_deploy: 'false'

36
tasks/configure.yml Normal file
View File

@ -0,0 +1,36 @@
---
- name: '[LACRE] - Configure lacre'
template:
src: 'etc/gpg-mailgate.conf.j2'
dest: '/etc/gpg-mailgate.conf'
owner: root
group: root
mode: 0644
- name: '[LACRE] - Add lacre config to postfix'
blockinfile:
dest: '/etc/postfix/master.cf'
backup: yes
marker: '# {mark} LACRE config block (Ansible)'
block: |
gpg-mailgate unix - n n - - pipe
flags= user=lacre argv={{ lacre_app_dir }}/gpg-mailgate.py ${recipient}
127.0.0.1:10028 inet n - n - 10 smtpd
-o content_filter=
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
- name: '[LACRE] - Replace content_filter setting in postfix'
replace:
path: '/etc/postfix/main.cf'
regexp: 'content_filter = .*'
replace: 'content_filter = gpg-mailgate'
when: lacre_set_content_filter == 'true'

10
tasks/git.yml Normal file
View File

@ -0,0 +1,10 @@
---
- name: '[GIT] - Clone lacre to /opt'
git:
repo: '{{ lacre_repo }}'
dest: '{{ lacre_app_dir }}'
force: yes
update: yes
version: "{{ lacre_version }}"

34
tasks/install.yml Normal file
View File

@ -0,0 +1,34 @@
---
- name: '[APT] - Install dependencies'
apt:
name: "{{ lacre_apt }}"
update_cache: yes
- name: '[Install] - Make sure gpgmailgate home exists'
file:
path: '{{ lacre_homedir }}'
state: directory
owner: '{{ lacre_username }}'
group: '{{ lacre_group }}'
- name: '[Install] - Make sure gpgmailgate .gnupg dir exists'
file:
path: '{{ lacre_homedir }}/.gnupg'
state: directory
owner: '{{ lacre_username }}'
group: '{{ lacre_group }}'
- name: '[Install] - Make sure gpgmailgate smime dir exists'
file:
path: '{{ lacre_homedir }}/smime'
state: directory
owner: '{{ lacre_username }}'
group: '{{ lacre_group }}'
- name: '[Install] - Link GnuPG direcotry to global python modules'
file:
src: '{{ lacre_app_dir }}/GnuPG'
dest: '/usr/local/lib/python2.7/dist-packages/GnuPG'
state: link

14
tasks/main.yml Normal file
View File

@ -0,0 +1,14 @@
---
- name: 'Clone / Update repository'
include: git.yml
- name: 'Create user'
include: user.yml
- name: 'Install Lacre'
include: install.yml
- name: 'Configure Lacre'
include: configure.yml

21
tasks/user.yml Normal file
View File

@ -0,0 +1,21 @@
---
- name: '[USER] - Add group'
group:
name: '{{ lacre_group }}'
state: present
- name: '[USER] - Add user'
user:
name: '{{ lacre_username }}'
shell: '/sbin/nologin'
group: '{{ lacre_group }}'
state: present
- name: '[USER] - Change ownership to etherpad user'
file:
path: '{{ lacre_app_dir }}'
owner: '{{ lacre_username }}'
group: '{{ lacre_group }}'
state: directory
recurse: yes

View File

@ -0,0 +1,136 @@
[default]
# Whether gpg-mailgate should add a header after it has processed an email
# This may be useful for debugging purposes
add_header = {{ lacre_add_header }}
# Whether we should only encrypt emails if they are explicitly defined in
# the key mappings below ([enc_keymap] section)
# This means gpg-mailgate won't automatically detect PGP recipients for encrypting
enc_keymap_only = {{ lacre_enc_keymap_only }}
# Whether we should only decrypt emails if they are explicitly defined in
# the key mappings below ([dec_keymap] section)
# This means gpg-mailgate won't automatically detect PGP recipients for decrypting
dec_keymap_only = {{ lacre_dec_keymap_only }}
# If dec_keymap_only is set to yes and recipients have private keys present for decrypting
# but are not on in the keymap, this can cause that mails for them will be
# encrypted. Set this to no if you want this behaviour.
failsave_dec = {{ lacre_failsave_dec }}
# Convert encrypted text/plain email to MIME-attached encrypt style.
# (Default is to use older inline-style PGP encoding.)
mime_conversion = {{ lacre_mime_conversion }}
# RFC 2821 defines that the user part (User@domain.tld) of a mail address should be treated case sensitive.
# However, in the real world this is ignored very often. This option disables the RFC 2821
# compatibility so both the user part and the domain part are treated case insensitive.
# Disabling the compatibility is more convenient to users. So if you know that your
# recipients all ignore the RFC you could this to yes.
mail_case_insensitive = {{ lacre_mail_case_insensitive }}
# This setting disables PGP/INLINE decryption completely. However,
# PGP/MIME encrypted mails will still be decrypted if possible. PGP/INLINE
# decryption has to be seen as experimental and could have some negative
# side effects. So if you want to take the risk set this to no.
no_inline_dec = {{ lacre_no_inline_dec }}
# Here you can define a regex for which the gateway should try to decrypt mails.
# It could be used to define that decryption should be used for a wider range of
# mail addresses e.g. a whole domain. No key is needed here. It is even active if
# dec_keymap is set to yes. If this feature should be disabled, don't leave it blank.
# Set it to None. For further regex information please have a look at
# https://docs.python.org/2/library/re.html
dec_regex = {{ lacre_dec_regex }}
[gpg]
# the directory where gpg-mailgate public keys are stored
# (see INSTALL for details)
keyhome = {{ lacre_keyhome }}
[smime]
# the directory for the S/MIME certificate files
cert_path = {{ lacre_cert_path }}
[mailregister]
# settings for the register-handler
register_email = {{ lacre_register_email }}
mail_templates = {{ lacre_mail_templates }}
# URL to webpanel. The server should be able to reach it
webpanel_url = {{ lacre_webpanel_url }}
[cron]
# settings for the gpgmw cron job
send_email = yes
notification_email = {{ lacre_notification_email }}
mail_templates = {{ lacre_mail_templates }}
[logging]
# For logging to syslog. 'file = syslog', otherwise use path to the file.
file = syslog
verbose = {{ lacre_verbose }}
[relay]
# the relay settings to use for Postfix
# gpg-mailgate will submit email to this relay after it is done processing
# unless you alter the default Postfix configuration, you won't have to modify this
host = {{ lacre_relay }}
port = {{ lacre_port }}
# This is the default port of postfix. It is used to send some
# mails through the GPG-Mailgate so they are encrypted
enc_port = {{ lacre_enc_port }}
# Set this option to yes to use TLS for SMTP Servers which require TLS.
starttls = {{ lacre_starttls }}
[database]
# uncomment the settings below if you want
# to read keys from a gpg-mailgate-web database
enabled = {{ lacre_db_enabled }}
name = {{ lacre_db_name }}
host = {{ lacre_db_host }}
username = {{ lacre_db_username }}
password = {{ lacre_db_password }}
[enc_keymap]
# You can find these by running the following command:
# gpg --list-keys --keyid-format long user@example.com
# Which will return output similar to:
# pub 1024D/AAAAAAAAAAAAAAAA 2007-10-22
# uid Joe User <user@example.com>
# sub 2048g/BBBBBBBBBBBBBBBB 2007-10-22
# You want the AAAAAAAAAAAAAAAA not BBBBBBBBBBBBBBBB.
#you@domain.tld = 12345678
[enc_domain_keymap]
# This seems to be similar to the [enc_keymap] section. However, you
# can define default keys for a domain here. Entries in the enc_keymap
# and individual keys stored on the system have a higher priority than
# the default keys specified here.
#
#
# You can find these by running the following command:
# gpg --list-keys --keyid-format long user@example.com
# Which will return output similar to:
# pub 1024D/AAAAAAAAAAAAAAAA 2007-10-22
# uid Joe User <user@example.com>
# sub 2048g/BBBBBBBBBBBBBBBB 2007-10-22
# You want the AAAAAAAAAAAAAAAA not BBBBBBBBBBBBBBBB.
#domain.tld = 12345678
[dec_keymap]
# You can find these by running the following command:
# gpg --list-secret-keys --keyid-format long user@example.com
# Which will return output similar to:
# sec 1024D/AAAAAAAAAAAAAAAA 2007-10-22
# uid Joe User <user@example.com>
# ssb 2048g/BBBBBBBBBBBBBBBB 2007-10-22
# You want the AAAAAAAAAAAAAAAA not BBBBBBBBBBBBBBBB.
#you@domain.tld = 12345678
[pgp_style]
# Here a PGP style (inline or PGP/MIME) could be defined for recipients.
# This overwrites the setting mime_conversion for the defined recipients.
# Valid entries are inline and mime
# If an entry is not valid, the setting mime_conversion is used as fallback.
#you@domian.tld = mime