From 50d4901819507fb08837a9d6e45fa7cb5961bfb8 Mon Sep 17 00:00:00 2001 From: Colin Smith Date: Thu, 24 Mar 2005 22:36:48 +0000 Subject: Stub in XMLRPC support (basic md5 authentication, signatures, and wrapper for backup_config_section and restore_config_section). Methods currently exposed are pfsense.backup_config_section and pfsense.restore_config_section. --- usr/local/www/xmlrpc.php | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 usr/local/www/xmlrpc.php (limited to 'usr/local/www') diff --git a/usr/local/www/xmlrpc.php b/usr/local/www/xmlrpc.php new file mode 100755 index 0000000..5e37b42 --- /dev/null +++ b/usr/local/www/xmlrpc.php @@ -0,0 +1,82 @@ +#!/usr/local/bin/php +getNumParams() != 2) return; // Make sure we have 2 params. + $param1 = $params->getParam(0); + $md5 = $param1->scalarval(); + if($md5 != md5($config['system']['password'])) return; // Basic authentication. + $param2 = $params->getParam(1); + $section = $param2->scalarval(); + $val = new XML_RPC_Value(backup_config_section($section), 'string'); + return new XML_RPC_Response($val); +} + +/* + * restore_config_section_xmlrpc: XMLRPC wrapper for restore_config_section. + * This method must be called with three parameters: a string containing the md5 of + * the local system's password, a string containing the section to be restored, + * and a string containing the returned value of backup_config_section() for that + * section. This function returns + */ +$restore_config_section_sig = array(array($xmlrpcBoolean, $xmlrpcString, $xmlrpcString, $xmlrpcString)); +function restore_config_section_xmlrpc($params) { + global $config; + if($params->getNumParams() != 3) return; // Make sure we have 3 params. + $param1 = $params->getParam(0); + $md5 = $param1->scalarval(); + if($md5 != md5($config['system']['password'])) return; // Basic authentication. + $param2 = $params->getParam(1); + $section - $param2->scalarval(); + $param3 = $params->getParam(2); + $new_contents = $param3->scalarval(); + restore_config_section($section, $new_contents); + return new XML_RPC_Response(new XML_RPC_Value(true, 'boolean')); +} + +$server = new XML_RPC_Server( + array( + 'pfsense.backup_config_section' => array('function' => 'backup_config_section_xmlrpc', + 'signature' => $backup_config_section_sig), + 'pfsense.restore_config_section' => array('function' => 'restore_config_section_xmlrpc', + 'signature' => $restore_config_section_sig) + ) +); +?> -- cgit v1.1