X-Git-Url: https://git.ralfj.de/dyn-nsupdate.git/blobdiff_plain/0f7c85cebd0ecebf94390fb7ab380327e1068b20..97db64724a34ef62837621a81365c26c78162d67:/update?ds=sidebyside diff --git a/update b/update index 1c149be..d5fbca3 100755 --- a/update +++ b/update @@ -7,32 +7,23 @@ print "Content-Type: text/plain" print "" # get input -if "user" not in form or "password" not in form or "domain" not in form or "ip" not in form: - print "Mandatory argument missing: You must supply all of 'user', 'password', 'domain', 'ip'" +if "password" not in form or "domain" not in form or "ip" not in form: + print "Mandatory argument missing: You must supply all of 'password', 'domain', 'ip'" sys.exit() ip = form["ip"].value domain = form["domain"].value -user = form["user"].value password = form["password"].value # run update program -p = subprocess.Popen(["/var/lib/named/dyn-nsupdate", user, password, domain, ip], stdout=subprocess.PIPE, stderr=subprocess.PIPE) +p = subprocess.Popen(["/var/lib/named/dyn-nsupdate", domain, password, ip], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() -if stdout: - print "Unexpected stdout from dyn-nsupdate:" - print stdout - sys.exit() # check what it did -if p.returncode == 1: +if p.returncode or stderr or stdout: # error :/ - print "There was an error while updating the DNS:" - print stderr + print "There was an error while updating the DNS: Return code %d" % p.returncode + if stdout: print stdout + if stderr: print stderr else: - # all right! - if p.returncode or stderr: - print "Unexpected stderr from dyn-nsupdate:" - print stderr - sys.exit() print "good",ip