2 import cgi, os, sys, subprocess
5 form = cgi.FieldStorage()
8 print "Content-Type: text/plain"
12 if "user" not in form or "password" not in form or "domain" not in form or "ip" not in form:
14 print "Mandatory argument missing: You must supply all of 'user', 'password', 'domain', 'ip'"
18 domain = form["domain"].value
19 user = form["user"].value
20 password = form["password"].value
23 p = subprocess.Popen(["/var/lib/named/dyn-nsupdate", user, password, domain, ip], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
24 (stdout, stderr) = p.communicate()
25 if stdout: raise Exception("Unexpected output from dyn-nsupdate")
30 print "There was an error while updating the DNS:"
34 if p.returncode or stderr:
35 raise Exception("Unexpected return code or output from dyn-nsupdate")