From e501de37f786b13d2bb6a1b6593dbafd3aa346e6 Mon Sep 17 00:00:00 2001 From: Ermal Date: Fri, 10 Dec 2010 00:19:22 +0000 Subject: [PATCH] Hello xmlrpc to another function! --- etc/inc/pfsense-utils.inc | 16 +++++++++++++++- etc/rc.filter_synchronize | 2 +- usr/local/www/xmlrpc.php | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 76d3510188..92013e33cf 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -760,11 +760,25 @@ function check_firmware_version($tocheck = "all", $return_php = true) { return $versions; } +/* + * host_firmware_version(): Return the versions used in this install + */ +function host_firmware_version() { + global $g, $config; + + return array( + "firmware" => array("version" => trim(file_get_contents('/etc/version', " \n"))), + "kernel" => array("version" => trim(file_get_contents('/etc/version_kernel', " \n"))), + "base" => array("version" => trim(file_get_contents('/etc/version_base', " \n"))), + "platform" => trim(file_get_contents('/etc/platform', " \n")), + "config_version" => $config['version'] + ); +} + function get_disk_info() { $diskout = ""; exec("/bin/df -h | /usr/bin/grep -w '/' | /usr/bin/awk '{ print $2, $3, $4, $5 }'", $diskout); return explode(' ', $diskout[0]); - // $size, $used, $avail, $cap } /****f* pfsense-utils/strncpy diff --git a/etc/rc.filter_synchronize b/etc/rc.filter_synchronize index 36567f7a57..a30825b821 100755 --- a/etc/rc.filter_synchronize +++ b/etc/rc.filter_synchronize @@ -88,7 +88,7 @@ function remove_special_characters($string) { return $string; } -function carp_check_version($url, $password, $port = 80, $method = 'pfsense.check_firmware_version') { +function carp_check_version($url, $password, $port = 80, $method = 'pfsense.host_firmware_version') { global $config, $g; if(file_exists("{$g['varrun_path']}/booting") || $g['booting']) diff --git a/usr/local/www/xmlrpc.php b/usr/local/www/xmlrpc.php index fd5676450d..584e821208 100755 --- a/usr/local/www/xmlrpc.php +++ b/usr/local/www/xmlrpc.php @@ -301,6 +301,24 @@ function check_firmware_version_xmlrpc($raw_params) { return new XML_RPC_Response(new XML_RPC_Value(check_firmware_version(false), $XML_RPC_String)); } +/*****************************/ +$pfsense_firmware_version_doc = gettext("Basic XMLRPC wrapper for check_firmware_version. This function will return the output of check_firmware_version upon co +mpletion."); + +$pfsense_firmware_version_sig = array( + $XML_RPC_String, +); + +function pfsense_firmware_version_xmlrpc($raw_params) { + global $xmlrpc_g, $XML_RPC_String; + + $params = xmlrpc_params_to_php($raw_params); + if(!xmlrpc_auth($params)) + return $xmlrpc_g['return']['authfail']; + + return new XML_RPC_Response(new XML_RPC_Value(host_firmware_version(), $XML_RPC_String)); +} + /*****************************/ $reboot_doc = gettext("Basic XMLRPC wrapper for rc.reboot."); $reboot_sig = array(array($XML_RPC_Boolean, $XML_RPC_String)); @@ -371,6 +389,9 @@ $server = new XML_RPC_Server( 'pfsense.check_firmware_version' => array('function' => 'check_firmware_version_xmlrpc', 'signature' => $check_firmware_version_sig, 'docstring' => $check_firmware_version_doc), + 'pfsense.host_firmware_version' => array('function' => 'pfsense_firmware_version_xmlrpc', + 'signature' => $host_firmware_version_sig, + 'docstring' => $host_firmware_version_doc), 'pfsense.reboot' => array('function' => 'reboot_xmlrpc', 'signature' => $reboot_sig, 'docstring' => $reboot_doc),