X-Git-Url: https://git.ralfj.de/dyn-nsupdate.git/blobdiff_plain/e9f6935aad370f9ac285f33a55c1c0ae51895939:/update.py..9292050b47d5c0a6c076da2c1a8f22c307c19ed2:/update?ds=inline diff --git a/update.py b/update old mode 100644 new mode 100755 similarity index 81% rename from update.py rename to update index 0642c40..1c149be --- a/update.py +++ b/update @@ -1,7 +1,5 @@ #!/usr/bin/python import cgi, os, sys, subprocess -import cgitb -cgitb.enable() form = cgi.FieldStorage() # print headers @@ -10,19 +8,21 @@ print "" # get input if "user" not in form or "password" not in form or "domain" not in form or "ip" not in form: - print "Error:" print "Mandatory argument missing: You must supply all of 'user', 'password', 'domain', 'ip'" sys.exit() +ip = form["ip"].value +domain = form["domain"].value user = form["user"].value password = form["password"].value -domain = form["domain"].value -ip = form["ip"].value # run update program p = subprocess.Popen(["/var/lib/named/dyn-nsupdate", user, password, domain, ip], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() -if stdout: raise Exception("Unexpected output from dyn-nsupdate") +if stdout: + print "Unexpected stdout from dyn-nsupdate:" + print stdout + sys.exit() # check what it did if p.returncode == 1: @@ -32,5 +32,7 @@ if p.returncode == 1: else: # all right! if p.returncode or stderr: - raise Exception("Unexpected return code or output from dyn-nsupdate") + print "Unexpected stderr from dyn-nsupdate:" + print stderr + sys.exit() print "good",ip