Commit 60e18ce2 authored by Andreas Kempe's avatar Andreas Kempe
Browse files

Correct handling of @ domains

parent dcef793a
......@@ -36,6 +36,15 @@ class DB():
cursor.execute('SELECT name FROM subdomain WHERE id = %s', id)
return cursor.fetchone().get("name")
def get_fqdn(self, domain_name, sid):
subdomain_name = self.get_subdomain_name(sid)
if subdomain_name.startswith('@'):
return domain_name
else:
return subdomain_name + '.' + domain_name
def get_key(self, subid):
with self.connection.cursor() as cursor:
cursor.execute('SELECT secret FROM update_key WHERE subid = %s LIMIT 1', subid)
......
......@@ -66,8 +66,7 @@ def application(env, start_response):
for id in d.get_domain_ids():
domain_name = d.get_domain_name(id)
for sid in d.get_subdomain_ids_without_keys(id):
subdomain_name = d.get_subdomain_name(sid)
fqdn = subdomain_name + '.' + domain_name
fqdn = d.get_fqdn(domain_name, sid)
with dnssec_keygen() as dk:
public_key, private_key = dk.create_keys(fqdn)
if not d.set_subdomain_keys(sid, public_key, private_key):
......@@ -80,8 +79,7 @@ def application(env, start_response):
domain_name = d.get_domain_name(id)
for sid in d.get_subdomain_ids(id):
key_template = env.get_template('key.template')
subdomain_name = d.get_subdomain_name(sid)
fqdn = subdomain_name + '.' + domain_name
fqdn = d.get_fqdn(domain_name, sid)
key = Key(fqdn, 'hmac-md5', d.get_key(sid))
rendered_key = key_template.render(keylist = [ key ])
keys_file.write(rendered_key)
......@@ -94,8 +92,7 @@ def application(env, start_response):
zone_template = env.get_template('zone.template')
zone_keys = list()
for sid in d.get_subdomain_ids(id):
subdomain_name = d.get_subdomain_name(sid)
fqdn = subdomain_name + '.' + domain_name
fqdn = d.get_fqdn(domain_name, sid)
key = Key(fqdn, 'hmac-md5', d.get_key(sid))
zone_key = ZoneKey(key.name, fqdn)
zone_keys.append(zone_key)
......@@ -117,10 +114,7 @@ def application(env, start_response):
records = list()
for sid in d.get_subdomain_ids(id):
rr = d.get_record(sid)
subdomain_name = d.get_subdomain_name(sid)
fqdn = subdomain_name + '.' + domain_name
if subdomain_name == "@":
fqdn = domain_name
fqdn = d.get_fqdn(domain_name, sid)
for ip in lookup(fqdn):
record = Record(rr.get('name'),
rr.get('ttl'),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment