mirror of
				https://github.com/mail-in-a-box/mailinabox.git
				synced 2025-10-30 18:50:53 +00:00 
			
		
		
		
	Merge remote-tracking branch 'upstream/master'
This commit is contained in:
		
						commit
						e50fdb4b9b
					
				| @ -29,10 +29,10 @@ It is a one-click email appliance. There are no user-configurable setup options. | ||||
| The components installed are: | ||||
| 
 | ||||
| * SMTP ([postfix](http://www.postfix.org/)), IMAP ([dovecot](http://dovecot.org/)), CardDAV/CalDAV ([Nextcloud](https://nextcloud.com/)), and Exchange ActiveSync ([z-push](http://z-push.org/)) servers | ||||
| * Webmail ([Roundcube](http://roundcube.net/)), mail filter rules (also using dovecot), email client autoconfig settings (served by [nginx](http://nginx.org/)) | ||||
| * Webmail ([Roundcube](http://roundcube.net/)), mail filter rules (also using dovecot), and email client autoconfig settings (served by [nginx](http://nginx.org/)) | ||||
| * Spam filtering ([spamassassin](https://spamassassin.apache.org/)) and greylisting ([postgrey](http://postgrey.schweikert.ch/)) | ||||
| * DNS ([nsd4](https://www.nlnetlabs.nl/projects/nsd/)) with [SPF](https://en.wikipedia.org/wiki/Sender_Policy_Framework), DKIM ([OpenDKIM](http://www.opendkim.org/)), [DMARC](https://en.wikipedia.org/wiki/DMARC), [DNSSEC](https://en.wikipedia.org/wiki/DNSSEC), [DANE TLSA](https://en.wikipedia.org/wiki/DNS-based_Authentication_of_Named_Entities), [MTA-STS](https://tools.ietf.org/html/rfc8461), and [SSHFP](https://tools.ietf.org/html/rfc4255) policy records automatically set | ||||
| * TLS certificates automatically provisioned [Let's Encrypt](https://letsencrypt.org/) | ||||
| * HTTPS TLS certificates are automatically provisioned using [Let's Encrypt](https://letsencrypt.org/) (needed for webmail, CardDAV/CalDAV, ActiveSync, MTA-STS policy, etc.). | ||||
| * Backups ([duplicity](http://duplicity.nongnu.org/)), firewall ([ufw](https://launchpad.net/ufw)), intrusion protection ([fail2ban](http://www.fail2ban.org/wiki/index.php/Main_Page)), and basic system monitoring ([munin](http://munin-monitoring.org/)) | ||||
| 
 | ||||
| It also includes system management tools: | ||||
|  | ||||
| @ -308,17 +308,23 @@ def build_zone(domain, all_domains, additional_records, www_redirect_domains, en | ||||
| 	# this domain name, then the domain name is a MTA-STS (https://tools.ietf.org/html/rfc8461) | ||||
| 	# Policy Domain. | ||||
| 	# | ||||
| 	# A "_mta-sts" TXT record signals the presence of a MTA-STS policy, and an effectively random policy | ||||
| 	# ID is used to signal that a new policy may (or may not) be deployed any time the DNS is | ||||
| 	# updated. | ||||
| 	# A "_mta-sts" TXT record signals the presence of a MTA-STS policy. The id field helps clients | ||||
| 	# cache the policy. It should be stable so we don't update DNS unnecessarily but change when | ||||
| 	# the policy changes. It must be at most 32 letters and numbers, so we compute a hash of the | ||||
| 	# policy file. | ||||
| 	# | ||||
| 	# The policy itself is served at the "mta-sts" (no underscore) subdomain over HTTPS. Therefore | ||||
| 	# the TLS certificate used by Postfix for STARTTLS must be a valid certificate for the MX | ||||
| 	# domain name (PRIMARY_HOSTNAME) *and* the TLS certificate used by nginx for HTTPS on the mta-sts | ||||
| 	# subdomain must be valid certificate for that domain. Do not set an MTA-STS policy if either | ||||
| 	# certificate in use is not valid (e.g. because it is self-signed and a valid certificate has not | ||||
| 	# yet been provisioned). | ||||
| 	# yet been provisioned). Since we cannot provision a certificate without A/AAAA records, we | ||||
| 	# always set them --- only the TXT records depend on there being valid certificates. | ||||
| 	mta_sts_enabled = False | ||||
| 	mta_sts_records = [ | ||||
| 		("mta-sts", "A", env["PUBLIC_IP"], "Optional. MTA-STS Policy Host serving /.well-known/mta-sts.txt."), | ||||
| 		("mta-sts", "AAAA", env.get('PUBLIC_IPV6'), "Optional. MTA-STS Policy Host serving /.well-known/mta-sts.txt."), | ||||
| 	] | ||||
| 	if domain in get_mail_domains(env): | ||||
| 		# Check that PRIMARY_HOSTNAME and the mta_sts domain both have valid certificates. | ||||
| 		for d in (env['PRIMARY_HOSTNAME'], "mta-sts." + domain): | ||||
| @ -332,11 +338,15 @@ def build_zone(domain, all_domains, additional_records, www_redirect_domains, en | ||||
| 			# 'break' was not encountered above, so both domains are good | ||||
| 			mta_sts_enabled = True | ||||
| 	if mta_sts_enabled: | ||||
| 		mta_sts_records = [ | ||||
| 			("mta-sts", "A", env["PUBLIC_IP"], "Optional. MTA-STS Policy Host serving /.well-known/mta-sts.txt."), | ||||
| 			("mta-sts", "AAAA", env.get('PUBLIC_IPV6'), "Optional. MTA-STS Policy Host serving /.well-known/mta-sts.txt."), | ||||
| 			("_mta-sts", "TXT", "v=STSv1; id=%sZ" % datetime.datetime.now().strftime("%Y%m%d%H%M%S"), "Optional. Part of the MTA-STS policy for incoming mail. If set, a MTA-STS policy must also be published.") | ||||
| 		] | ||||
| 		# Compute a up-to-32-character hash of the policy file. We'll take a SHA-1 hash of the policy | ||||
| 		# file (20 bytes) and encode it as base-64 (60 bytes) but then just take its first 20 bytes | ||||
| 		# which should be sufficient to change whenever the policy file changes. | ||||
| 		with open("/var/lib/mailinabox/mta-sts.txt", "rb") as f: | ||||
| 			mta_sts_policy_id = base64.b64encode(hashlib.sha1(f.read()).digest()).decode("ascii")[0:20] | ||||
| 		mta_sts_records.extend([ | ||||
| 			("_mta-sts", "TXT", "v=STSv1; id=" + mta_sts_policy_id, "Optional. Part of the MTA-STS policy for incoming mail. If set, a MTA-STS policy must also be published.") | ||||
| 		]) | ||||
| 
 | ||||
| 		# Rules can be custom configured accoring to https://tools.ietf.org/html/rfc8460. | ||||
| 		# Skip if the rules below if the user has set a custom _smtp._tls record. | ||||
| 		if not has_rec("_smtp._tls", "TXT", prefix="v=TLSRPTv1;"): | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user