From e1565437e7aed48685093acf21245973b583bbd5 Mon Sep 17 00:00:00 2001 From: muppeth Date: Mon, 19 Jul 2021 07:03:05 +0200 Subject: [PATCH 1/4] initial commit --- .gitignore | 3 + LICENSE | 22 +++-- Playbooks/lacre.yml | 11 +++ README.MD | 2 + README.md | 3 - Vagrantfile | 18 ++++ defaults/main.yml | 45 ++++++++++ tasks/configure.yml | 36 ++++++++ tasks/git.yml | 10 +++ tasks/install.yml | 34 ++++++++ tasks/main.yml | 14 +++ tasks/user.yml | 21 +++++ templates/etc/gpg-mailgate.conf.j2 | 136 +++++++++++++++++++++++++++++ 13 files changed, 346 insertions(+), 9 deletions(-) create mode 100644 .gitignore create mode 100644 Playbooks/lacre.yml create mode 100644 README.MD delete mode 100644 README.md create mode 100644 Vagrantfile create mode 100644 defaults/main.yml create mode 100644 tasks/configure.yml create mode 100644 tasks/git.yml create mode 100644 tasks/install.yml create mode 100644 tasks/main.yml create mode 100644 tasks/user.yml create mode 100644 templates/etc/gpg-mailgate.conf.j2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b58d1f6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vagrant +.vagrant/* +*log diff --git a/LICENSE b/LICENSE index 2071b23..d745f27 100644 --- a/LICENSE +++ b/LICENSE @@ -1,9 +1,19 @@ -MIT License +MIT License Copyright (c) 2021 "Stichting Disroot.org" -Copyright (c) +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. diff --git a/Playbooks/lacre.yml b/Playbooks/lacre.yml new file mode 100644 index 0000000..b8f8d7b --- /dev/null +++ b/Playbooks/lacre.yml @@ -0,0 +1,11 @@ +--- + +- hosts: lacre + roles: + # - role: mailserver + # tags: + # - postfix + - role: lacre + + vars_files: + - ../defaults/main.yml diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..666dede --- /dev/null +++ b/README.MD @@ -0,0 +1,2 @@ +**WIP** +Role that deploys, configures and upgrades GPG Lacre. diff --git a/README.md b/README.md deleted file mode 100644 index b539440..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# lacre - -Role that deploys lacre.io e2e mailbox encryption \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..20bae83 --- /dev/null +++ b/Vagrantfile @@ -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 diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..5587a6c --- /dev/null +++ b/defaults/main.yml @@ -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' diff --git a/tasks/configure.yml b/tasks/configure.yml new file mode 100644 index 0000000..b37c19b --- /dev/null +++ b/tasks/configure.yml @@ -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' + diff --git a/tasks/git.yml b/tasks/git.yml new file mode 100644 index 0000000..2fa5ef1 --- /dev/null +++ b/tasks/git.yml @@ -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 }}" + diff --git a/tasks/install.yml b/tasks/install.yml new file mode 100644 index 0000000..08cc752 --- /dev/null +++ b/tasks/install.yml @@ -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 + diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..73997cd --- /dev/null +++ b/tasks/main.yml @@ -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 + diff --git a/tasks/user.yml b/tasks/user.yml new file mode 100644 index 0000000..e9f2726 --- /dev/null +++ b/tasks/user.yml @@ -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 diff --git a/templates/etc/gpg-mailgate.conf.j2 b/templates/etc/gpg-mailgate.conf.j2 new file mode 100644 index 0000000..003fb0e --- /dev/null +++ b/templates/etc/gpg-mailgate.conf.j2 @@ -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 +# 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 +# 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 +# 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 -- 2.30.2 From ed0b8e16a5143e7977af18272aeaddab3b5c14a6 Mon Sep 17 00:00:00 2001 From: muppeth Date: Mon, 6 Sep 2021 11:47:12 +0200 Subject: [PATCH 2/4] fixed postfix master --- tasks/configure.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tasks/configure.yml b/tasks/configure.yml index b37c19b..a7e1c2d 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -15,17 +15,17 @@ marker: '# {mark} LACRE config block (Ansible)' block: | gpg-mailgate unix - n n - - pipe - flags= user=lacre argv={{ lacre_app_dir }}/gpg-mailgate.py ${recipient} + 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 + -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: -- 2.30.2 From a72adba7a92ad1d7b783cd73ba396f3dd2aabe12 Mon Sep 17 00:00:00 2001 From: muppeth Date: Mon, 21 Mar 2022 21:21:02 +0100 Subject: [PATCH 3/4] added web frontend; py3 update --- Playbooks/lacre.yml | 8 +- defaults/main.yml | 158 +++++++++++++++++++++++++++++++++++++++- tasks/frontend.yml | 66 +++++++++++++++++ tasks/install.yml | 2 +- tasks/main.yml | 3 + templates/config.php.j2 | 121 ++++++++++++++++++++++++++++++ 6 files changed, 351 insertions(+), 7 deletions(-) create mode 100644 tasks/frontend.yml create mode 100644 templates/config.php.j2 diff --git a/Playbooks/lacre.yml b/Playbooks/lacre.yml index b8f8d7b..ca87c87 100644 --- a/Playbooks/lacre.yml +++ b/Playbooks/lacre.yml @@ -2,10 +2,10 @@ - hosts: lacre roles: - # - role: mailserver - # tags: - # - postfix - - role: lacre + - mariadb + - nginx + - gpg-lacre + - php-fpm vars_files: - ../defaults/main.yml diff --git a/defaults/main.yml b/defaults/main.yml index 5587a6c..1589c1a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,13 +1,14 @@ --- +lacre_pything_version: '3.9' lacre_repo: 'https://git.disroot.org/Disroot/gpg-lacre.git' -lacre_version: 'master' +lacre_version: 'php_update' lacre_app_dir: '/opt/gpg-lacre' lacre_username: 'lacre' lacre_group: 'lacre' lacre_homedir: '/var/gpgmailgate/' #lacre_ lacre_apt: - - 'python-m2crypto' + - 'python3-m2crypto' - 'git' - 'gnupg' lacre_set_content_filter: 'true' @@ -38,8 +39,161 @@ lacre_db_host: 'localhost' lacre_db_username: 'user' lacre_db_password: 'password' +#lacre webgate +lacre_cron: 'true' +lacre_webgate_deploy: 'true' +lacre_webgate_apt: + - 'python3-markdown' + - 'python3-mysqldb' +lacre_webgate_webroot: '/var/www/' +lacre_webgate_user: 'www-data' +lacre_webgate_group: 'www-data' +lacre_webgate_email_web: 'admin@example.com' +lacre_webgate_email_from: 'gpg-mailgate-web@example.com' +lacre_webgate_email_subject_requestpgp: 'Confirm your email address' +lacre_webgate_site_url: 'http://example.com/gpgmw' +lacre_webgate_site_title: 'PGP key management' +lacre_webgate_language: 'english' +lacre_webgate_debug: 'enable' +lacre_webgate_mail_smtp: 'false' +lacre_webgate_smtp_host: 'localhost' +lacre_webgate_smtp_port: '25' +lacre_webgate_smtp_username: 'gpgmw' +lacre_webgate_smtp_password: '' +lacre_webgate_pgpverify: 'false' +lacre_webgate_pgpverify_tmpdir: '/tmp' +lacre_webgate_pgpverify_allowblank: 'true' +lacre_webgate_lock_time: '10' +lacre_webgate_lock_retrycount: '3' +lacre_webgate_lock_cooldown: '900' +lacre_webgate_lock_reset: '300' +lacre_webgate_locktime_max: '3600' + + + + + + #mailserver vars postfix_header_checks: 'false' postfix_body_checks: 'false' postfix_rbl_whitelist: 'false' postfix_postgrey_deploy: 'false' + +#php +install_php: 'true' +php_version: '7.4' +php_pkgs: + - 'php{{ php_version }}-fpm' + - 'php{{ php_version }}-mysql' +nginx_vhosts: + - name: 'example.org' + template: 'basephp' + proto: 'http' + listen: '80' + root: 'gpg-mailgate-web/public_html' + index: 'index.php' + use_access_log: 'true' + use_error_log: 'true' + nginx_error_log_level: 'warn' + upstream_params: + - 'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' + - 'fastcgi_index index.php;' + - 'include /etc/nginx/fastcgi_params;' + - 'fastcgi_pass unix:{{ pool_listen }};' + state: 'enable' + letsencrypt: 'false' + +nginx_default_vhost_ssl: 'example.org' +nginx_default_vhost: 'example.org' + +#mariadb +# MARIADB CONFIG +mariadb_root_password: 'changeme' +mariadb_default_config: + - name: 'client' + config: + - port = {{mariadb_client_port}} + - socket = /var/run/mysqld/mysqld.sock + - default-character-set = utf8mb4 + - name: 'mysqld_safe' + config: + - safe_socket = /var/run/mysqld/mysqld.sock + - safe_nice = 0 + - name: 'mysqld' + config: + - user = mysql + - pid_file = /var/run/mysqld/mysqld.pid + - socket = /var/run/mysqld/mysqld.sock + - port = 3306 + - basedir = /usr + - datadir = "{{mariadb_datadir}}" + - tmpdir = /tmp + - init_connect ='SET collation_connection = utf8mb4_unicode_ci' + - init_connect ='SET NAMES utf8mb4' + - character-set-server = utf8mb4 + - collation-server = utf8mb4_unicode_ci + - skip_external_locking = True + - bind_address = {{ lacre_db_host }} + - key_buffer = 16M + - max_allowed_packet = 16M + - thread_stack = 192K + - thread_cache_size = 16 + - myisam_recover = BACKUP + - max_connections = 1000 + - query_cache_limit = 1M + - query_cache_size = 16M + - general_log_file = /var/log/mysql/mysql.log + - general_log = 0 + - slow_query_log = 1 + - slow_query_log_file = /var/log/mysql/mysql-slow.log + - long_query_time = 1 + - log_queries_not_using_indexes = False + - default_storage_engine = InnoDB + - innodb_buffer_pool_size = 1024M + - innodb_log_file_size = 128M + - innodb_log_buffer_size = 8M + - innodb_thread_concurrency = 64 + - innodb_read_io_threads = 16 + - innodb_write_io_threads = 16 + - innodb_file_per_table = 1 + - innodb_open_files = 400 + - innodb_io_capacity = 600 + - innodb_lock_wait_timeout = 60 + - innodb_flush_method = O_DIRECT + - innodb_doublewrite = 0 + - innodb_use_native_aio = 0 + - innodb_large_prefix = on + - server_id = 1 + - log_bin = /var/log/mysql/mysql-bin.log + - expire_logs_days = 2 + - max_binlog_size = 10M + - binlog_format = row + - query_cache_type = 1 + - query_cache_limit = 256K + - query_cache_min_res_unit = 2k + - query_cache_size = 300M + - tmp_table_size= 64M + - max_heap_table_size= 64M + + + - name: 'mysqldump' + config: + - quick + #- quotes-names + - max_allowed_packet = 16M + - name: 'isamchk' + config: + - key_buffer = 16M + +mariadb_databases: + - name: '{{ lacre_db_name }}' + collation: 'utf8mb4_unicode_ci' + encoding: 'utf8mb4' + +mariadb_users: + - name: '{{ lacre_db_username }}' + host: '{{ lacre_db_host }}' + password: '{{ lacre_db_password }}' + priv: '{{ lacre_db_name }}.*:ALL' + diff --git a/tasks/frontend.yml b/tasks/frontend.yml new file mode 100644 index 0000000..bb81742 --- /dev/null +++ b/tasks/frontend.yml @@ -0,0 +1,66 @@ +--- + +- name: '[Webgate] - Install dependencies' + apt: + name: "{{ lacre_webgate_apt }}" + +- name: '[Webgate] - Copy files to webdir' + copy: + remote_src: true + src: "{{ lacre_app_dir }}/gpg-mailgate-web/public_html" + dest: "{{ lacre_webgate_webroot }}/gpg-mailgate-web" + owner: "{{ lacre_webgate_user }}" + group: "{{ lacre_webgate_group }}" + +- name: '[Webgate] - Import sql schema' + mysql_db: + state: import + name: "{{ lacre_db_name }}" + login_host: "{{ lacre_db_host }}" + login_user: "{{ lacre_db_username }}" + login_password: "{{ lacre_db_password }}" + target: "{{ lacre_app_dir }}/gpg-mailgate-web/schema.sql" + +- name: 'Webgate] - Deploy config' + template: + src: 'config.php.j2' + dest: "{{ lacre_webgate_webroot }}/gpg-mailgate-web/public_html/config.php" + owner: "{{ lacre_webgate_user }}" + group: "{{ lacre_webgate_group }}" + +- name: '[Webgate] - Create email template dir' + file: + path: "{{ lacre_homedir }}/cron-templates" + state: directory + owner: "{{ lacre_username }}" + group: "{{ lacre_group }}" + +- name: '[Webgate] - Copy templates to template dir' + copy: + remote_src: true + src: "{{ lacre_app_dir }}/cron_templates" + dest: "{{ lacre_homedir }}/cron-templates" + owner: "{{ lacre_username }}" + group: "{{ lacre_group }}" + +- name: '[Webgate] - Deploy cron.py' + copy: + remote_src: true + src: "{{ lacre_app_dir }}/gpg-mailgate-web/cron.py" + dest: '/usr/local/bin/gpgmw-cron.py' + owner: "{{ lacre_username }}" + group: "{{ lacre_group }}" + mode: a+x + +- name: '[Webgate] - Set cron' + cron: + name: "Webgate cronjob" + state: present + minute: "*/3" + hour: "*" + day: "*" + month: "*" + weekday: "*" + user: "{{ lacre_username }}" + job: '/usr/local/bin/gpgmw-cron.py > /dev/null' + when: lacre_cron == 'true' diff --git a/tasks/install.yml b/tasks/install.yml index 08cc752..a19861f 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -29,6 +29,6 @@ - name: '[Install] - Link GnuPG direcotry to global python modules' file: src: '{{ lacre_app_dir }}/GnuPG' - dest: '/usr/local/lib/python2.7/dist-packages/GnuPG' + dest: '/usr/local/lib/python{{ lacre_pything_version }}/dist-packages/GnuPG' state: link diff --git a/tasks/main.yml b/tasks/main.yml index 73997cd..5983a4c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -12,3 +12,6 @@ - name: 'Configure Lacre' include: configure.yml +- name: 'Deploy frontend' + include: frontend.yml + diff --git a/templates/config.php.j2 b/templates/config.php.j2 new file mode 100644 index 0000000..ca35011 --- /dev/null +++ b/templates/config.php.j2 @@ -0,0 +1,121 @@ +. + +*/ + +// +// GENERAL SITE SETTINGS +// + +//web team contact +// this email address will be displayed if there is a database error +$config['email_web'] = '{{ lacre_webgate_email_web }}'; + +//address to send emails from +$config['email_from'] = '{{ lacre_webgate_email_from }}'; + +//this will be used as the subject when a user requests to add a PGP key +$config['email_subject_requestpgp'] = '{{ lacre_webgate_email_subject_requestpgp }}'; + +//site URL, without trailing slash +$config['site_url'] = '{{ lacre_webgate_site_url }}'; + + +//title of the website (displayed on home page) +$config['site_title'] = '{{ lacre_webgate_site_title }}'; + +//language file to use (see language subdirectory) +$config['language'] = '{{ lacre_webgate_language }}'; + +//whether debug mode should be enabled +$config['debug'] = {{ lacre_webgate_debug }}; + +// +// MAIL SETTINGS +// + +//whether to send mail through SMTP (instead of PHP mail function) +$config['mail_smtp'] = {{ lacre_webgate_mail_smtp }}; + +//SMTP settings, if mail_smtp is enabled +//this requires Net_SMTP from http://pear.php.net/package/Net_SMTP/ to be installed +$config['mail_smtp_host'] = '{{ lacre_webgate_smtp_host }}'; +$config['mail_smtp_port'] = {{ lacre_webgate_smtp_port }}; +$config['mail_smtp_username'] = '{{ lacre_webgate_smtp_username }}'; +$config['mail_smtp_password'] = '{{ lacre_webgate_smtp_password }}'; + +// +// DATABASE SETTINGS +// + +//database name (MySQL only); or see include/dbconnect.php +$config['db_name'] = '{{ lacre_db_name }}'; + +//database host +$config['db_host'] = '{{ lacre_db_host }}'; + +//database username +$config['db_username'] = '{{ lacre_db_username }}'; + +//database password +$config['db_password'] = '{{ lacre_db_password }}'; + +// +// PGP VERIFICATION SETTINGS +// + +//whether to enable immediate verification of PGP keys +// keys will always be verified with the email address in our cron job +// but this will enable verification from the web interface before email confirmation +//for this to work, Crypt_GPG from http://pear.php.net/Crypt_GPG must be installed +// (as well as any of its dependencies), and pgpverify_tmpdir must be set +$config['pgpverify_enable'] = {{ lacre_webgate_pgpverify }}; + +//a temporary directory to use for PGP verification, without trailing slash +// gpgmw will create subdirectories from here to use as temporary gpg home directories +// these directories will (should) be deleted immediately after use +$config['pgpverify_tmpdir'] = '{{ lacre_webgate_pgpverify_tmpdir }}'; + +//whether to allow blank "keys" +// this is useful to allow users to delete their key from the keystore +// if they no longer want encryption +$config['pgpverify_allowblank'] = {{ lacre_webgate_pgpverify_allowblank }}; + +// +// LOCK SETTINGS +// + +//the time in seconds a user must wait before trying again; otherwise they get locked out (count not increased) +$config['lock_time_initial'] = array('requestpgp' => {{ lacre_webgate_lock_time }}); + +//the number of tries a user has (that passes the lock_time_initial test) before being locked by overload (extended duration) +$config['lock_count_overload'] = array('requestpgp' => {{ lacre_webgate_lock_retrycount }}); + +//the time that overloads last +$config['lock_time_overload'] = array('requestpgp' => {{ lacre_webgate_lock_time }}); + +//time after which locks no longer apply, assuming the lock isn't active +$config['lock_time_reset'] = {{ lacre_webgate_lock_reset }}; + +//max time to store locks in the database; this way we can clear old locks with one function +$config['lock_time_max'] = {{ lacre_webgate_locktime_max }}; + +?> + -- 2.30.2 From 2aa0248a9923c199bd5a2380d05a2969f5437bb7 Mon Sep 17 00:00:00 2001 From: muppeth Date: Mon, 21 Mar 2022 22:32:46 +0100 Subject: [PATCH 4/4] bumped debian version in Vagrantfile --- Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 20bae83..dca90a5 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -8,7 +8,7 @@ Vagrant.configure("2") do |config| #config.ssh.insert_key = false config.vm.define "lacre" do |lacre| - lacre.vm.box = "generic/debian10" + lacre.vm.box = "generic/debian11" lacre.vm.provider :libvirt do |libvirt| libvirt.memory = 256 end -- 2.30.2