Validate hostnames by querying to see if the name exists in DNS, and
authorEvan Broder <broder@mit.edu>
Sat, 1 Nov 2008 02:58:23 +0000 (22:58 -0400)
committerEvan Broder <broder@mit.edu>
Sat, 1 Nov 2008 02:58:23 +0000 (22:58 -0400)
add an appropriate dependency

svn path=/trunk/packages/invirt-web/; revision=1473

code/validation.py
debian/changelog
debian/control

index 860bac3..2f64f9a 100644 (file)
@@ -4,6 +4,7 @@ import cache_acls
 import getafsgroups
 import re
 import string
 import getafsgroups
 import re
 import string
+import dns.resolver
 from invirt.database import Machine, NIC, Type, Disk, CDROM, Autoinstall
 from invirt.config import structs as config
 from webcommon import InvalidInput
 from invirt.database import Machine, NIC, Type, Disk, CDROM, Autoinstall
 from invirt.config import structs as config
 from webcommon import InvalidInput
@@ -270,11 +271,21 @@ def testName(user, name, machine=None):
     name = name.lower()
     if machine is not None and name == machine.name:
         return None
     name = name.lower()
     if machine is not None and name == machine.name:
         return None
-    if not Machine.query().filter_by(name=name).count():
+    try:
+        f = open('/tmp/log', 'a')
+        dns.resolver.query('%s.%s.' % (name, config.dns.domains[0]), 'A')
+        # If the hostname didn't exist, it would have thrown an
+        # exception by now - error out
+        raise InvalidInput('name', name, 'Name is already taken.')
+    except dns.resolver.NXDOMAIN, e:
         if not validMachineName(name):
             raise InvalidInput('name', name, 'You must provide a machine name.  Max 63 chars, alnum plus \'-\', does not begin or end with \'-\'.')
         return name
         if not validMachineName(name):
             raise InvalidInput('name', name, 'You must provide a machine name.  Max 63 chars, alnum plus \'-\', does not begin or end with \'-\'.')
         return name
-    raise InvalidInput('name', name, "Name is already taken.")
+    except InvalidInput:
+        raise
+    except:
+        # Any other error is a validation failure
+        raise InvalidInput('name', name, 'We were unable to verify that this name is available. If you believe this is in error, please contact us at %s' % config.dns.contact)
 
 def testDescription(user, description, machine=None):
     if description is None or description.strip() == '':
 
 def testDescription(user, description, machine=None):
     if description is None or description.strip() == '':
index 4d695b3..3ebb5c0 100644 (file)
-invirt-web-iptables (0.0.2) unstable; urgency=low
+invirt-web (0.0.5) unstable; urgency=low
 
 
-  * Be sure to enable IP forwarding for VNC
+  * Add new dependency on python-dns
 
 
- -- Evan Broder <broder@mit.edu>  Wed, 29 Oct 2008 01:27:48 -0400
+ -- Evan Broder <broder@mit.edu>  Fri, 31 Oct 2008 22:57:41 -0400
 
 
-invirt-web-iptables (0.0.1) unstable; urgency=low
+invirt-web (0.0.4) unstable; urgency=low
 
 
-  * sipb-xen-iptables -> invirt-web-iptables
+  * sipb-xen-base -> invirt-base
 
 
- -- Greg Price <price@mit.edu>  Sat, 25 Oct 2008 17:47:46 -0400
+ -- Evan Broder <broder@mit.edu>  Tue, 28 Oct 2008 04:23:35 -0400
 
 
-sipb-xen-iptables (3) unstable; urgency=low
+invirt-web (0.0.3) unstable; urgency=low
 
 
-  * shorten initscript with std-init.sh
-  * make reload work too, just for fun
+  * sipb-xen-vnc-client -> invirt-vnc-client
 
 
- -- Greg Price <price@mit.edu>  Sat, 25 Oct 2008 15:37:07 -0400
+ -- Evan Broder <broder@mit.edu>  Sun, 26 Oct 2008 17:28:51 -0400
 
 
-sipb-xen-iptables (2) unstable; urgency=low
+invirt-web (0.0.2) unstable; urgency=low
 
 
-  * invirt-configurize sipb-xen-iptables
+  * /sipb-xen -> /invirt in apt repo URI
 
 
- -- Evan Broder <broder@mit.edu>  Sun, 05 Oct 2008 01:22:25 -0400
+ -- Greg Price <price@mit.edu>  Sun, 26 Oct 2008 04:56:21 -0400
 
 
-sipb-xen-iptables (1) unstable; urgency=low
+invirt-web (0.0.1) unstable; urgency=low
+
+  * sipb-xen-www -> invirt-web
+
+ -- Greg Price <price@mit.edu>  Sat, 25 Oct 2008 22:09:29 -0400
+
+sipb-xen-www (3.18) unstable; urgency=low
+
+  * sipb-xen-database-common -> invirt-database
+
+ -- Evan Broder <broder@mit.edu>  Sat, 25 Oct 2008 21:04:09 -0400
+
+sipb-xen-www (3.17) unstable; urgency=low
+
+  [ Quentin Smith ]
+  * Add Kerberos-authenticated web interface on port 442
+
+  [ Evan Broder ]
+  * Add config-package-dev to the build dependencies
+
+ -- Evan Broder <broder@mit.edu>  Fri, 24 Oct 2008 15:32:34 -0400
+
+sipb-xen-www (3.16) unstable; urgency=low
+
+  * Shorten initscript with spiffy new library from sipb-xen-base
+  * Fix comment copy-paste error in initscript, now that it's mostly comments
+
+ -- Greg Price <price@mit.edu>  Fri, 24 Oct 2008 07:19:13 -0400
+
+sipb-xen-www (3.15) unstable; urgency=low
+
+  * Use /etc/invirt/keytab instead of a separate keytab for apache
+
+ -- Evan Broder <broder@mit.edu>  Sun, 19 Oct 2008 19:56:04 -0400
+
+sipb-xen-www (3.14.4) unstable; urgency=low
+
+  * allow '*' wildcard in config.errormail_exclude
+
+ -- Greg Price <price@mit.edu>  Sat, 11 Oct 2008 17:32:42 -0700
+
+sipb-xen-www (3.14.3) unstable; urgency=low
+
+  * Actually stop Apache on shutdown
+
+ -- Evan Broder <broder@mit.edu>  Sun, 05 Oct 2008 00:24:40 -0400
+
+sipb-xen-www (3.14.2) unstable; urgency=low
+
+  * Be a good debian package and undo what you did on uninstall
+
+ -- Evan Broder <broder@mit.edu>  Sun, 05 Oct 2008 00:06:30 -0400
+
+sipb-xen-www (3.14.1) unstable; urgency=low
+
+  * Try again, now that I actually understand what the problem is
+
+ -- Evan Broder <broder@mit.edu>  Sat, 04 Oct 2008 23:58:46 -0400
+
+sipb-xen-www (3.14) unstable; urgency=low
+
+  * Try to fix startup ordering problem by specifying that the new startup
+    script depends on $remote_fs
+
+ -- Evan Broder <broder@mit.edu>  Sat, 04 Oct 2008 23:32:14 -0400
+
+sipb-xen-www (3.13.1) unstable; urgency=low
+
+  * Don't add another Listen 443 directive - apache gets angry
+  * And this, kids, is why you should always test your code before
+    committing
+
+ -- Evan broder <broder@mit.edu>  Fri, 03 Oct 2008 22:01:22 -0400
+
+sipb-xen-www (3.13) unstable; urgency=low
+
+  * Make sure we're listening on all the necessary ports
+
+ -- Evan Broder <broder@mit.edu>  Fri, 03 Oct 2008 21:40:47 -0400
+
+sipb-xen-www (3.12) unstable; urgency=low
+
+  * invirt-confiscate the SVN checkout
+
+ -- Evan Broder <broder@mit.edu>  Fri, 03 Oct 2008 21:01:33 -0400
+
+sipb-xen-www (3.11) unstable; urgency=low
+
+  * fix distribution
+
+ -- Greg Price <price@mit.edu>  Tue, 30 Sep 2008 23:48:37 -0400
+
+sipb-xen-www (3.10) hardy; urgency=low
+
+  * depend on debathena-afs-config and python-flup
+
+ -- Greg Price <price@mit.edu>  Mon, 29 Sep 2008 05:58:01 +0000
+
+sipb-xen-www (3.9) unstable; urgency=low
+
+  * further integration of invirt.config
+
+ -- Yang Zhang <y_z@mit.edu>  Fri,  8 Aug 2008 02:39:15 -0400
+
+sipb-xen-www (3.8) unstable; urgency=low
+
+  * sipb_xen_database -> invirt.database in cache_acls.py
+
+ -- Yang Zhang <y_z@mit.edu>  Sun,  3 Aug 2008 19:45:19 -0400
+
+sipb-xen-www (3.7) unstable; urgency=low
+
+  uncommitted changes in /etc/apache2 on xvm.mit.edu:
+  * rewrite static/ uris for admin mode
+  * allow ~ uris
+
+  * take instance from keytab in k5start apache2.init wrapper
+
+ -- Greg Price <price@mit.edu>  Mon,  4 Aug 2008 01:22:47 -0400
+
+sipb-xen-www (3.6) unstable; urgency=low
+
+  * Add Anders' kstart-using apache2 init script.
+  * Add some dependencies the svn site needs.
+  * Use daemon/xvm-2.mit.edu for svn site, as it's on xvm-2 now
+
+ -- Greg Price <price@mit.edu>  Fri,  1 Aug 2008 20:23:50 -0400
+
+sipb-xen-www (3.5) unstable; urgency=low
+
+  * Use FCGI.
+  * Lengthen timeouts to let the autoinstaller work.
+
+ -- Greg Price <price@mit.edu>  Sun, 15 Jun 2008 21:51:59 -0400
+
+sipb-xen-www (3.4) unstable; urgency=low
+
+  * xvm.mit.edu rather than sipb-xen-dev.mit.edu
+
+ -- Greg Price <price@mit.edu>  Sun, 11 May 2008 00:49:58 -0400
+
+sipb-xen-www (3.3) unstable; urgency=low
+
+  * Fix the SVN server to point to the new AFS mountpoint
+
+ -- Evan Broder <broder@mit.edu>  Fri,  9 May 2008 02:37:21 -0400
+
+sipb-xen-www (3.2) unstable; urgency=low
+
+  * Check in (part of?) the Apache config.
+  * Modify it to allow an informative front page without certs.
+  * Add that front page.
+
+ -- Greg Price <price@mit.edu>  Fri,  9 May 2008 02:11:04 -0400
+
+sipb-xen-www (3.1) unstable; urgency=low
+
+  * Fixed the crontab definition
+
+ -- SIPB Xen Project <sipb-xen@mit.edu>  Mon, 31 Mar 2008 05:49:32 -0400
+
+sipb-xen-www (3) unstable; urgency=low
+
+  * Refresh the ACL cache every 5 minutes
+
+ -- SIPB Xen Project <sipb-xen@mit.edu>  Mon, 31 Mar 2008 05:38:16 -0400
+
+sipb-xen-www (2) unstable; urgency=low
+
+  * Create sipb-xen group in preinst script.
+
+ -- Eric Price <ecprice@sipb-xen-dev.mit.edu>  Sat, 29 Mar 2008 18:45:02 -0400
+
+sipb-xen-www (1) unstable; urgency=low
 
   * Initial Release.
 
   * Initial Release.
- -- SIPB Xen Project <sipb-xen@mit.edu>  Fri, 28 Mar 2008 21:22:12 -0500
+ -- SIPB Xen Project <sipb-xen@mit.edu>  Fri, 28 Mar 2008 22:43:12 -0500
 
 
index 986ac5d..7c9d1c5 100644 (file)
@@ -8,7 +8,8 @@ Standards-Version: 3.7.2
 Package: invirt-web
 Architecture: all
 Depends: ${misc:Depends}, libapache2-mod-fcgid, python-flup,
 Package: invirt-web
 Architecture: all
 Depends: ${misc:Depends}, libapache2-mod-fcgid, python-flup,
- python-cheetah, python-simplejson, invirt-database,
+ python-cheetah, python-simplejson, python-dns, invirt-database,
  invirt-vnc-client, kstart, debathena-afs-config, invirt-base,
  invirt-vnc-client, kstart, debathena-afs-config, invirt-base,
- libapache2-svn, libapache2-mod-auth-kerb, postfix, subversion, zephyr-clients
+ libapache2-svn, libapache2-mod-auth-kerb, postfix, subversion,
+ zephyr-clients
 Description: the Invirt web interface
 Description: the Invirt web interface