diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2010-08-15 18:42:48 -0400 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2010-08-15 18:42:48 -0400 |
commit | 052e65efd5776a8a5e9355d68e039323874f07d7 (patch) | |
tree | fa0b7385bc6c59d14cfce23e3555fd5bc860b7f5 /etc | |
parent | 5da3430e3d29c353548e79cd9e502830813baef5 (diff) | |
download | pfsense-052e65efd5776a8a5e9355d68e039323874f07d7.zip pfsense-052e65efd5776a8a5e9355d68e039323874f07d7.tar.gz |
Adapt to use 2.0's accounts
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/auth.inc | 6 | ||||
-rw-r--r-- | etc/inc/zeromq.inc | 64 |
2 files changed, 47 insertions, 23 deletions
diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index f85f897..4bca766 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -46,8 +46,8 @@ * NOTE : Portions of the mschapv2 support was based on the BSD licensed CHAP.php * file courtesy of Michael Retterklieber. */ - -require_once("config.gui.inc"); +if(!$do_not_include_config_gui_inc) + require_once("config.gui.inc"); /* If this function doesn't exist, we're being called from Captive Portal or another internal subsystem which does not include authgui.inc */ @@ -1242,4 +1242,4 @@ function session_auth() { return true; } -?> +?>
\ No newline at end of file diff --git a/etc/inc/zeromq.inc b/etc/inc/zeromq.inc index f644fe2..5b2d70c 100644 --- a/etc/inc/zeromq.inc +++ b/etc/inc/zeromq.inc @@ -28,14 +28,24 @@ */ define('ZEROMQ_AUTH_FAIL', 'authfail'); +define('ZEROMQ_TRUE', 'true'); +define('ZEROMQ_FASLE', 'false'); + +$do_not_include_config_gui_inc = true; +require("auth.inc"): /* zeromq_send: Send a message to a member node */ -function zeromq_send($protocol = "tcp", $ipaddress, $port, $message) { - if(!$ipaddress || !$port || !$message) +function zeromq_send($protocol = "tcp", $ipaddress, $port, $method, $params, $username, $password) { + if(!$ipaddress || !$port || !$message || !$username || !$password) return; + /* Set calling function and auth information */ + $params['username'] = $username; + $params['password'] = $password; + $params['function'] = $method; + /* Serialize the data we are going to send over */ - $serialized = serialize($message); + $serialized = serialize($params); /* Create new queue object */ $queue = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, "MySock1"); @@ -103,17 +113,31 @@ function zeromq_server($protocol = "tcp", $ipaddress, $port) { } } -function zeromq_auth(&$params) { - global $config, $g; - $localpass = $config['system']['user'][0]['password']; - if(crypt($params[0], $localpass) == $localpass) { - array_shift($params); - return true; - } else if(crypt($params['xmlrpcauth'], $localpass) != $localpass) { - unset($params['xmlrpcauth']); +function zeromq_auth($params) { + global $config, $g; + + $username = $params['username']; + $password = $params['password']; + + $user = getUserEntry($username); + if (!$user) return false; + + if (is_account_disabled($username) || is_account_expired($username)) + return false; + + if ($user['password']) { + $passwd = crypt($passwd, $user['password']); + if ($passwd == $user['password']) + return true; } - unset($params['xmlrpcauth']); + + if ($user['md5-hash']) { + $passwd = md5($passwd); + if ($passwd == $user['md5-hash']) + return true; + } + return false; } @@ -128,7 +152,7 @@ function exec_php_zeromq($raw_params) { $response = XML_RPC_encode($toreturn); return new XML_RPC_Response($response); } else - return $xmlrpc_g['return']['true']; + return ZEROMQ_FASLE; } function exec_shell_zeromq($raw_params) { @@ -138,7 +162,7 @@ function exec_shell_zeromq($raw_params) { return ZEROMQ_AUTH_FAIL; $shell_cmd = $params[0]; mwexec($shell_cmd); - return $xmlrpc_g['return']['true']; + return ZEROMQ_FASLE; } function backup_config_section_zeromq($raw_params) { @@ -158,7 +182,7 @@ function restore_config_section_zeromq($raw_params) { $config = array_merge($config, $params[0]); $mergedkeys = implode(",", array_keys($params[0])); write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."),$mergedkeys)); - return $xmlrpc_g['return']['true']; + return ZEROMQ_FASLE; } function merge_installedpackages_section_zeromq($raw_params) { @@ -169,7 +193,7 @@ function merge_installedpackages_section_zeromq($raw_params) { $config['installedpackages'] = array_merge($config['installedpackages'], $params[0]); $mergedkeys = implode(",", array_keys($params[0])); write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."),$mergedkeys)); - return $xmlrpc_g['return']['true']; + return ZEROMQ_FASLE; } function merge_config_section_zeromq($raw_params) { @@ -180,7 +204,7 @@ function merge_config_section_zeromq($raw_params) { $config = array_merge_recursive_unique($config, $params[0]); $mergedkeys = implode(",", array_keys($params[0])); write_config("Merged in config ({$mergedkeys} sections) from XMLRPC client."); - return $xmlrpc_g['return']['true']; + return ZEROMQ_FASLE; } function filter_configure_zeromq($raw_params) { @@ -197,7 +221,7 @@ function filter_configure_zeromq($raw_params) { services_dhcpd_configure(); services_dnsmasq_configure(); local_sync_accounts(); - return $xmlrpc_g['return']['true']; + return ZEROMQ_FASLE; } function interfaces_carp_configure_zeromq($raw_params) { @@ -207,7 +231,7 @@ function interfaces_carp_configure_zeromq($raw_params) { return ZEROMQ_AUTH_FAIL; interfaces_carp_setup(); interfaces_vips_configure(); - return $xmlrpc_g['return']['true']; + return ZEROMQ_FASLE; } function check_firmware_version_zeromq($raw_params) { @@ -223,7 +247,7 @@ function reboot_zeromq($raw_params) { if(!zeromq_auth($params)) return ZEROMQ_AUTH_FAIL; mwexec_bg("/etc/rc.reboot"); - return $xmlrpc_g['return']['true']; + return ZEROMQ_FASLE; } function get_notices_zeromq($raw_params) { |