From b5e5f8f9348c76c213cfc0583183601a90a24ee4 Mon Sep 17 00:00:00 2001 From: andryyy Date: Sun, 1 Jan 2017 19:49:02 +0100 Subject: [PATCH 01/14] Add volume --- data/Dockerfiles/sogo/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/Dockerfiles/sogo/Dockerfile b/data/Dockerfiles/sogo/Dockerfile index 2d043fdd..932dc751 100644 --- a/data/Dockerfiles/sogo/Dockerfile +++ b/data/Dockerfiles/sogo/Dockerfile @@ -38,6 +38,8 @@ COPY supervisord.conf /etc/supervisor/supervisord.conf EXPOSE 20000 EXPOSE 9191 +VOLUME /usr/lib/GNUstep/SOGo/WebServerResources/ + CMD exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* From bb3ef747219f78f4b10c8a7aa94e61109af1db61 Mon Sep 17 00:00:00 2001 From: andryyy Date: Sun, 1 Jan 2017 21:23:10 +0100 Subject: [PATCH 02/14] Change service names to skip alias --- docker-compose.yml | 77 ++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b91c5516..2c74fc5c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '2' services: - pdns-mailcow: + pdns: image: andryyy/mailcow-dockerized:pdns volumes: - ./data/conf/pdns/:/etc/powerdns/ @@ -9,13 +9,11 @@ services: networks: mailcow-network: ipv4_address: 172.22.1.254 - aliases: - - pdns - mysql-mailcow: + mysql: image: mariadb:10.1 depends_on: - - pdns-mailcow + - pdns command: mysqld volumes: - mysql-vol-1:/var/lib/mysql/ @@ -31,13 +29,11 @@ services: restart: always networks: mailcow-network: - aliases: - - mysql - redis-mailcow: + redis: image: redis depends_on: - - pdns-mailcow + - pdns volumes: - redis-vol-1:/data/ restart: always @@ -46,13 +42,11 @@ services: dns_search: mailcow-network networks: mailcow-network: - aliases: - - redis - rspamd-mailcow: + rspamd: image: andryyy/mailcow-dockerized:rspamd depends_on: - - pdns-mailcow + - pdns volumes: - ./data/conf/rspamd/override.d/:/etc/rspamd/override.d:ro - ./data/conf/rspamd/local.d/:/etc/rspamd/local.d:ro @@ -64,13 +58,11 @@ services: dns_search: mailcow-network networks: mailcow-network: - aliases: - - rspamd - php-fpm-mailcow: + phpfpm: image: andryyy/mailcow-dockerized:phpfpm depends_on: - - pdns-mailcow + - pdns volumes: - ./data/web:/web:ro - ./data/conf/rspamd/dynmaps:/dynmaps:ro @@ -87,14 +79,12 @@ services: restart: always networks: mailcow-network: - aliases: - - phpfpm - sogo-mailcow: + sogo: image: andryyy/mailcow-dockerized:sogo depends_on: - - pdns-mailcow - - mysql-mailcow + - pdns + - mysql environment: - DBNAME=${DBNAME} - DBUSER=${DBUSER} @@ -105,17 +95,14 @@ services: dns_search: mailcow-network volumes: - ./data/conf/sogo/:/etc/sogo/ - - /usr/lib/GNUstep/SOGo/WebServerResources/ restart: always networks: mailcow-network: - aliases: - - sogo - rmilter-mailcow: + rmilter: image: andryyy/mailcow-dockerized:rmilter depends_on: - - pdns-mailcow + - pdns volumes: - ./data/conf/rmilter/:/etc/rmilter.conf.d/:ro restart: always @@ -124,19 +111,17 @@ services: dns_search: mailcow-network networks: mailcow-network: - aliases: - - rmilter - dovecot-mailcow: + dovecot: image: andryyy/mailcow-dockerized:dovecot depends_on: - - pdns-mailcow + - pdns volumes: - ./data/conf/dovecot:/etc/dovecot - ./data/assets/ssl:/etc/ssl/mail/:ro - vmail-vol-1:/var/vmail volumes_from: - - sogo-mailcow + - sogo environment: - DBNAME=${DBNAME} - DBUSER=${DBUSER} @@ -154,13 +139,11 @@ services: hostname: ${MAILCOW_HOSTNAME} networks: mailcow-network: - aliases: - - dovecot - postfix-mailcow: + postfix: image: andryyy/mailcow-dockerized:postfix depends_on: - - pdns-mailcow + - pdns volumes: - ./data/conf/postfix:/opt/postfix/conf - ./data/assets/ssl:/etc/ssl/mail/:ro @@ -179,31 +162,27 @@ services: dns_search: mailcow-network networks: mailcow-network: - aliases: - - postfix - memcached-mailcow: + memcached: image: memcached depends_on: - - pdns-mailcow + - pdns restart: always dns: - 172.22.1.254 dns_search: mailcow-network networks: mailcow-network: - aliases: - - memcached - nginx-mailcow: + nginx: depends_on: - - mysql-mailcow - - sogo-mailcow - - php-fpm-mailcow - - rspamd-mailcow + - mysql + - sogo + - phpfpm + - rspamd image: nginx:mainline volumes_from: - - sogo-mailcow + - sogo volumes: - ./data/web:/web:ro - ./data/conf/rspamd/dynmaps:/dynmaps:ro @@ -217,8 +196,6 @@ services: restart: always networks: mailcow-network: - aliases: - - nginx networks: mailcow-network: From c0b31ff2d4ef51a97e9c9d0c7d6419ad64a3064a Mon Sep 17 00:00:00 2001 From: andryyy Date: Sun, 1 Jan 2017 21:23:35 +0100 Subject: [PATCH 03/14] Change ports in docker-compose file if needed --- generate_config.sh | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/generate_config.sh b/generate_config.sh index cb1a516e..92deccb5 100755 --- a/generate_config.sh +++ b/generate_config.sh @@ -29,7 +29,6 @@ MAILCOW_HOSTNAME=${MAILCOW_HOSTNAME} # ------------------------------ DBNAME=mailcow DBUSER=mailcow - # Please use long, random alphanumeric strings (A-Za-z0-9) DBPASS=$( Date: Sun, 1 Jan 2017 21:26:51 +0100 Subject: [PATCH 04/14] Change ports in docker-compose file if needed --- docker-compose.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2c74fc5c..f54d9f4a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -127,11 +127,11 @@ services: - DBUSER=${DBUSER} - DBPASS=${DBPASS} ports: - - "${IMAP_PORT}:143" - - "${IMAPS_PORT}:993" - - "${POP_PORT}:110" - - "${POPS_PORT}:995" - - "${SIEVE_PORT}:4190" + - "143:143" + - "993:993" + - "110:110" + - "995:995" + - "4190:4190" dns: - 172.22.1.254 dns_search: mailcow-network @@ -152,9 +152,9 @@ services: - DBUSER=${DBUSER} - DBPASS=${DBPASS} ports: - - "${SMTP_PORT}:25" - - "${SMTPS_PORT}:465" - - "${SUBMISSION_PORT}:587" + - "25:25" + - "465:465" + - "587:587" restart: always hostname: ${MAILCOW_HOSTNAME} dns: From 2c822accb8f5d602529979fb1f710b56144ab74b Mon Sep 17 00:00:00 2001 From: andryyy Date: Tue, 3 Jan 2017 10:33:06 +0100 Subject: [PATCH 05/14] Do not change service names --- docker-compose.yml | 93 +++++++++++++++++++++++++++++----------------- generate_config.sh | 13 +++++++ 2 files changed, 71 insertions(+), 35 deletions(-) mode change 100755 => 100644 generate_config.sh diff --git a/docker-compose.yml b/docker-compose.yml index f54d9f4a..b91c5516 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '2' services: - pdns: + pdns-mailcow: image: andryyy/mailcow-dockerized:pdns volumes: - ./data/conf/pdns/:/etc/powerdns/ @@ -9,11 +9,13 @@ services: networks: mailcow-network: ipv4_address: 172.22.1.254 + aliases: + - pdns - mysql: + mysql-mailcow: image: mariadb:10.1 depends_on: - - pdns + - pdns-mailcow command: mysqld volumes: - mysql-vol-1:/var/lib/mysql/ @@ -29,11 +31,13 @@ services: restart: always networks: mailcow-network: + aliases: + - mysql - redis: + redis-mailcow: image: redis depends_on: - - pdns + - pdns-mailcow volumes: - redis-vol-1:/data/ restart: always @@ -42,11 +46,13 @@ services: dns_search: mailcow-network networks: mailcow-network: + aliases: + - redis - rspamd: + rspamd-mailcow: image: andryyy/mailcow-dockerized:rspamd depends_on: - - pdns + - pdns-mailcow volumes: - ./data/conf/rspamd/override.d/:/etc/rspamd/override.d:ro - ./data/conf/rspamd/local.d/:/etc/rspamd/local.d:ro @@ -58,11 +64,13 @@ services: dns_search: mailcow-network networks: mailcow-network: + aliases: + - rspamd - phpfpm: + php-fpm-mailcow: image: andryyy/mailcow-dockerized:phpfpm depends_on: - - pdns + - pdns-mailcow volumes: - ./data/web:/web:ro - ./data/conf/rspamd/dynmaps:/dynmaps:ro @@ -79,12 +87,14 @@ services: restart: always networks: mailcow-network: + aliases: + - phpfpm - sogo: + sogo-mailcow: image: andryyy/mailcow-dockerized:sogo depends_on: - - pdns - - mysql + - pdns-mailcow + - mysql-mailcow environment: - DBNAME=${DBNAME} - DBUSER=${DBUSER} @@ -95,14 +105,17 @@ services: dns_search: mailcow-network volumes: - ./data/conf/sogo/:/etc/sogo/ + - /usr/lib/GNUstep/SOGo/WebServerResources/ restart: always networks: mailcow-network: + aliases: + - sogo - rmilter: + rmilter-mailcow: image: andryyy/mailcow-dockerized:rmilter depends_on: - - pdns + - pdns-mailcow volumes: - ./data/conf/rmilter/:/etc/rmilter.conf.d/:ro restart: always @@ -111,27 +124,29 @@ services: dns_search: mailcow-network networks: mailcow-network: + aliases: + - rmilter - dovecot: + dovecot-mailcow: image: andryyy/mailcow-dockerized:dovecot depends_on: - - pdns + - pdns-mailcow volumes: - ./data/conf/dovecot:/etc/dovecot - ./data/assets/ssl:/etc/ssl/mail/:ro - vmail-vol-1:/var/vmail volumes_from: - - sogo + - sogo-mailcow environment: - DBNAME=${DBNAME} - DBUSER=${DBUSER} - DBPASS=${DBPASS} ports: - - "143:143" - - "993:993" - - "110:110" - - "995:995" - - "4190:4190" + - "${IMAP_PORT}:143" + - "${IMAPS_PORT}:993" + - "${POP_PORT}:110" + - "${POPS_PORT}:995" + - "${SIEVE_PORT}:4190" dns: - 172.22.1.254 dns_search: mailcow-network @@ -139,11 +154,13 @@ services: hostname: ${MAILCOW_HOSTNAME} networks: mailcow-network: + aliases: + - dovecot - postfix: + postfix-mailcow: image: andryyy/mailcow-dockerized:postfix depends_on: - - pdns + - pdns-mailcow volumes: - ./data/conf/postfix:/opt/postfix/conf - ./data/assets/ssl:/etc/ssl/mail/:ro @@ -152,9 +169,9 @@ services: - DBUSER=${DBUSER} - DBPASS=${DBPASS} ports: - - "25:25" - - "465:465" - - "587:587" + - "${SMTP_PORT}:25" + - "${SMTPS_PORT}:465" + - "${SUBMISSION_PORT}:587" restart: always hostname: ${MAILCOW_HOSTNAME} dns: @@ -162,27 +179,31 @@ services: dns_search: mailcow-network networks: mailcow-network: + aliases: + - postfix - memcached: + memcached-mailcow: image: memcached depends_on: - - pdns + - pdns-mailcow restart: always dns: - 172.22.1.254 dns_search: mailcow-network networks: mailcow-network: + aliases: + - memcached - nginx: + nginx-mailcow: depends_on: - - mysql - - sogo - - phpfpm - - rspamd + - mysql-mailcow + - sogo-mailcow + - php-fpm-mailcow + - rspamd-mailcow image: nginx:mainline volumes_from: - - sogo + - sogo-mailcow volumes: - ./data/web:/web:ro - ./data/conf/rspamd/dynmaps:/dynmaps:ro @@ -196,6 +217,8 @@ services: restart: always networks: mailcow-network: + aliases: + - nginx networks: mailcow-network: diff --git a/generate_config.sh b/generate_config.sh old mode 100755 new mode 100644 index 92deccb5..cb1a516e --- a/generate_config.sh +++ b/generate_config.sh @@ -29,6 +29,7 @@ MAILCOW_HOSTNAME=${MAILCOW_HOSTNAME} # ------------------------------ DBNAME=mailcow DBUSER=mailcow + # Please use long, random alphanumeric strings (A-Za-z0-9) DBPASS=$( Date: Tue, 3 Jan 2017 10:35:41 +0100 Subject: [PATCH 06/14] Revert vol change --- data/Dockerfiles/sogo/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/data/Dockerfiles/sogo/Dockerfile b/data/Dockerfiles/sogo/Dockerfile index 932dc751..2d043fdd 100644 --- a/data/Dockerfiles/sogo/Dockerfile +++ b/data/Dockerfiles/sogo/Dockerfile @@ -38,8 +38,6 @@ COPY supervisord.conf /etc/supervisor/supervisord.conf EXPOSE 20000 EXPOSE 9191 -VOLUME /usr/lib/GNUstep/SOGo/WebServerResources/ - CMD exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* From 2aace3d5cc2a15380c9d182e76fb2195963c9087 Mon Sep 17 00:00:00 2001 From: andryyy Date: Tue, 3 Jan 2017 10:36:12 +0100 Subject: [PATCH 07/14] Fix permission --- generate_config.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 generate_config.sh diff --git a/generate_config.sh b/generate_config.sh old mode 100644 new mode 100755 From 8e07d29f0a43e3c44b7341aa4906f9dd81350c4c Mon Sep 17 00:00:00 2001 From: andryyy Date: Tue, 3 Jan 2017 10:39:32 +0100 Subject: [PATCH 08/14] Some slight changes in permission checks for future updates --- data/web/inc/functions.inc.php | 35 +++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/data/web/inc/functions.inc.php b/data/web/inc/functions.inc.php index ce1b374e..cfa3fdb4 100644 --- a/data/web/inc/functions.inc.php +++ b/data/web/inc/functions.inc.php @@ -8,11 +8,12 @@ function hasDomainAccess($username, $role, $domain) { if (!filter_var($username, FILTER_VALIDATE_EMAIL) && !ctype_alnum(str_replace(array('_', '.', '-'), '', $username))) { return false; } - if (!is_valid_domain_name($domain)) { return false; } - + if ($role != 'admin' && $role != 'domainadmin' && $role != 'user') { + return false; + } try { $stmt = $pdo->prepare("SELECT `domain` FROM `domain_admins` WHERE ( @@ -2192,6 +2193,9 @@ function delete_domain_admin($postarray) { function get_spam_score($username) { global $pdo; $default = "5, 15"; + if ($_SESSION['mailcow_cc_role'] != "user") { + return false; + } if (!filter_var($username, FILTER_VALIDATE_EMAIL)) { return $default; } @@ -2235,6 +2239,13 @@ function get_spam_score($username) { function set_spam_score($postarray) { global $lang; global $pdo; + if ($_SESSION['mailcow_cc_role'] != "user") { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['access_denied']) + ); + return false; + } $username = $_SESSION['mailcow_cc_username']; $lowspamlevel = explode(',', $postarray['score'])[0]; $highspamlevel = explode(',', $postarray['score'])[1]; @@ -2288,7 +2299,15 @@ function set_spam_score($postarray) { function set_policy_list($postarray) { global $lang; global $pdo; - + if ($_SESSION['mailcow_cc_role'] != "admin" && + $_SESSION['mailcow_cc_role'] != "domainadmin" && + $_SESSION['mailcow_cc_role'] != "user") { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['access_denied']) + ); + return false; + } (isset($postarray['domain'])) ? $object = $postarray['domain'] : $object = $_SESSION['mailcow_cc_username']; ($postarray['object_list'] == "bl") ? $object_list = "blacklist_from" : $object_list = "whitelist_from"; $object_from = preg_replace('/\.+/', '.', rtrim(preg_replace("/\.\*/", "*", trim(strtolower($postarray['object_from']))), '.')); @@ -2389,6 +2408,13 @@ function set_policy_list($postarray) { function set_tls_policy($postarray) { global $lang; global $pdo; + if ($_SESSION['mailcow_cc_role'] != "user") { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['access_denied']) + ); + return false; + } isset($postarray['tls_in']) ? $tls_in = '1' : $tls_in = '0'; isset($postarray['tls_out']) ? $tls_out = '1' : $tls_out = '0'; $username = $_SESSION['mailcow_cc_username']; @@ -2422,6 +2448,9 @@ function set_tls_policy($postarray) { function get_tls_policy($username) { global $lang; global $pdo; + if ($_SESSION['mailcow_cc_role'] != "user") { + return false; + } if (!filter_var($username, FILTER_VALIDATE_EMAIL)) { $_SESSION['return'] = array( 'type' => 'danger', From 887f7db7a8f059924a2d0c6769773e1516ae1e40 Mon Sep 17 00:00:00 2001 From: andryyy Date: Tue, 3 Jan 2017 11:46:11 +0100 Subject: [PATCH 09/14] Add language strings --- data/web/inc/footer.inc.php | 6 +++--- data/web/inc/header.inc.php | 2 +- data/web/lang/lang.de.php | 5 ++++- data/web/lang/lang.en.php | 6 ++++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/data/web/inc/footer.inc.php b/data/web/inc/footer.inc.php index 052f03b2..b2976bec 100644 --- a/data/web/inc/footer.inc.php +++ b/data/web/inc/footer.inc.php @@ -6,12 +6,12 @@ if ($_SESSION['mailcow_cc_role'] == "admin"):