summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-08-03 12:00:46 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-08-03 12:00:46 -0400
commitb08e850d7a38f3ba75eab394faddb474a94d8193 (patch)
treea07be94d164154fe054cdf44f5535a9d75c0ddfc /scripts
parente722459eb6b483d71dd71c2b2c80a72b9ab52ef3 (diff)
downloadthird_party-cobbler-b08e850d7a38f3ba75eab394faddb474a94d8193.tar.gz
third_party-cobbler-b08e850d7a38f3ba75eab394faddb474a94d8193.tar.xz
third_party-cobbler-b08e850d7a38f3ba75eab394faddb474a94d8193.zip
Implement PXE boot loop prevention feature using a CGI script that speaks to a special
function in cobblerd.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/nopxe.cgi80
1 files changed, 80 insertions, 0 deletions
diff --git a/scripts/nopxe.cgi b/scripts/nopxe.cgi
new file mode 100755
index 0000000..e90e886
--- /dev/null
+++ b/scripts/nopxe.cgi
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+
+# This software may be freely redistributed under the terms of the GNU
+# general public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+# This script disables the netboot flag for a given
+# system if (and only if) pxe_just_once is enabled in settings.
+# It must not be able to do anything else for security
+# reasons.
+#
+#
+# (C) Red Hat, 2007
+# Michael DeHaan <mdehaan@redhat.com>
+#
+
+import cgi
+import cgitb
+import time
+import os
+import sys
+import socket
+import xmlrpclib
+from cobbler import sub_process as sub_process
+
+COBBLER_BASE = "/var/www/cobbler"
+XMLRPC_SERVER = "http://127.0.0.1:25151"
+
+#----------------------------------------------------------------------
+
+class ServerProxy(xmlrpclib.ServerProxy):
+
+ def __init__(self, url=None):
+ xmlrpclib.ServerProxy.__init__(self, url, allow_none=True)
+
+#----------------------------------------------------------------------
+
+def parse_query():
+ """
+ Read arguments from query string.
+ """
+
+ form = cgi.parse()
+
+ if form.has_key("system"):
+ return form["system"][0]
+ return 0
+
+def disable(name):
+ """
+ Determine if this feature is enabled.
+ """
+
+ #try:
+ xmlrpc_server = ServerProxy(XMLRPC_SERVER)
+ print xmlrpc_server.disable_netboot(name)
+ #except:
+ # print "# could not contact cobblerd at %s" % XMLRPC_SERVER
+ # sys.exit(1)
+
+ return True
+
+#----------------------------------------------------------------------
+
+def header():
+ print "Content-type: text/plain"
+ print
+
+#----------------------------------------------------------------------
+
+if __name__ == "__main__":
+ cgitb.enable(format='text')
+ header()
+ name = parse_query()
+ disable(name)
+
+