Skip to content

Commit 6e2c653

Browse files
committed
allow a custom dkim selector
1 parent 3b259ee commit 6e2c653

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

management/dns_update.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def has_rec(qname, rtype, prefix=None):
297297

298298
# Append the DKIM TXT record to the zone as generated by OpenDKIM.
299299
# Skip if the user has set a DKIM record already.
300-
opendkim_record_file = os.path.join(env['STORAGE_ROOT'], 'mail/dkim/mail.txt')
300+
opendkim_record_file = os.path.join(env['STORAGE_ROOT'], 'mail/dkim/' + env['DKIM_SELECTOR'] + '.txt')
301301
with open(opendkim_record_file) as orf:
302302
m = re.match(r'(\S+)\s+IN\s+TXT\s+\( ((?:"[^"]+"\s+)+)\)', orf.read(), re.S)
303303
val = "".join(re.findall(r'"([^"]+)"', m.group(2)))
@@ -764,7 +764,7 @@ def write_opendkim_tables(domains, env):
764764
# Append a record to OpenDKIM's KeyTable and SigningTable for each domain
765765
# that we send mail from (zones and all subdomains).
766766

767-
opendkim_key_file = os.path.join(env['STORAGE_ROOT'], 'mail/dkim/mail.private')
767+
opendkim_key_file = os.path.join(env['STORAGE_ROOT'], 'mail/dkim/' + env['DKIM_SELECTOR'] + '.private')
768768

769769
if not os.path.exists(opendkim_key_file):
770770
# Looks like OpenDKIM is not installed.
@@ -789,7 +789,7 @@ def write_opendkim_tables(domains, env):
789789
# signing domain must match the sender's From: domain.
790790
"KeyTable":
791791
"".join(
792-
"{domain} {domain}:mail:{key_file}\n".format(domain=domain, key_file=opendkim_key_file)
792+
"{domain} {domain}:{selector}:{key_file}\n".format(domain=domain, selector=env['DKIM_SELECTOR'], key_file=opendkim_key_file)
793793
for domain in domains
794794
),
795795
}

setup/dkim.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ fi
5252
# A 1024-bit key is seen as a minimum standard by several providers
5353
# such as Google. But they and others use a 2048 bit key, so we'll
5454
# do the same. Keys beyond 2048 bits may exceed DNS record limits.
55-
if [ ! -f "$STORAGE_ROOT/mail/dkim/mail.private" ]; then
56-
opendkim-genkey -b 2048 -r -s mail -D $STORAGE_ROOT/mail/dkim
55+
if [ ! -f "$STORAGE_ROOT/mail/dkim/$DKIM_SELECTOR.private" ]; then
56+
opendkim-genkey -b 2048 -r -s $DKIM_SELECTOR -D $STORAGE_ROOT/mail/dkim
5757
fi
5858

5959
# Ensure files are owned by the opendkim user and are private otherwise.

setup/start.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ PUBLIC_IPV6=$PUBLIC_IPV6
104104
PRIVATE_IP=$PRIVATE_IP
105105
PRIVATE_IPV6=$PRIVATE_IPV6
106106
MTA_STS_MODE=${DEFAULT_MTA_STS_MODE:-enforce}
107+
DKIM_SELECTOR=${DEFAULT_DKIM_SELECTOR:-mail}
107108
EOF
108109

109110
# Start service configuration.

0 commit comments

Comments
 (0)