Skip to content

Commit

Permalink
Add DNS server validation check for configure-module
Browse files Browse the repository at this point in the history
  • Loading branch information
stephdl committed Jul 30, 2024
1 parent 5b1197a commit 544d985
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions imageroot/actions/configure-module/10validate
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ipaddress
import json
import os
import sys
import subprocess

import agent
import network
Expand Down Expand Up @@ -63,3 +64,15 @@ if request["dhcp-server"]["enabled"]:
agent.set_status('validation-failed')
json.dump([{'field':'dhcp-server.start', 'parameter':'dhcp-server.start','value': request['dhcp-server']['start'], 'error':'must_be_less_than_end'}], fp=sys.stdout)
sys.exit(2)

if request["dns-server"]["enabled"]:
are_dns_bound = network.are_ports_53_bound()
try:
p = subprocess.run(['systemctl', 'is-active', '-q', os.environ['MODULE_ID']])
running = (p.returncode == 0)
except:
running = False
if are_dns_bound and not running:
agent.set_status('validation-failed')
json.dump([{'field':'dns-server.enabled', 'parameter':'dns-server.enabled', 'value': "dns_port_already_bind", 'error':'dns_port_already_bind'}], fp=sys.stdout)
sys.exit(3)

0 comments on commit 544d985

Please sign in to comment.