Project

General

Profile

Download (16.9 KB) Statistics
| Branch: | Tag: | Revision:
1 50d49018 Colin Smith
<?php
2
/*
3 81d8a9ad Colin Smith
	$Id$
4 dc1cd85d Scott Ullrich
5 50d49018 Colin Smith
        xmlrpc.php
6 d1a6552b Scott Ullrich
        Copyright (C) 2009, 2010 Scott Ullrich
7 50d49018 Colin Smith
        Copyright (C) 2005 Colin Smith
8
        All rights reserved.
9
10
        Redistribution and use in source and binary forms, with or without
11
        modification, are permitted provided that the following conditions are met:
12
13
        1. Redistributions of source code must retain the above copyright notice,
14
           this list of conditions and the following disclaimer.
15
16
        2. Redistributions in binary form must reproduce the above copyright
17
           notice, this list of conditions and the following disclaimer in the
18
           documentation and/or other materials provided with the distribution.
19
20
        THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
        INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
        AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
        AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
        OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
        SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
        INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
        CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
        ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 0e19e0e4 Scott Ullrich
        POSSIBILITY OF SUCH DAMAGE.
30 50d49018 Colin Smith
*/
31
32 6b07c15a Matthew Grooms
##|+PRIV
33
##|*IDENT=page-xmlrpclibrary
34
##|*NAME=XMLRPC Library page
35
##|*DESCR=Allow access to the 'XMLRPC Library' page.
36
##|*MATCH=xmlrpc.php*
37
##|-PRIV
38
39 0674f163 sullrich
require("config.inc");
40
require("functions.inc");
41
require("filter.inc");
42
require("shaper.inc");
43
require("xmlrpc_server.inc");
44
require("xmlrpc.inc");
45
require("array_intersect_key.inc");
46 50d49018 Colin Smith
47 ff664954 Scott Ullrich
/* grab sync to ip if enabled */
48 dd98e330 Scott Ullrich
if($config['installedpackages']['carpsettings']) {
49
	if ($config['installedpackages']['carpsettings']['config']) {
50
		foreach ($config['installedpackages']['carpsettings']['config'] as $carp) {
51
			$synchronizetoip = $carp['synchronizetoip'];
52
		}
53 ff664954 Scott Ullrich
	}
54
}
55
56
if($synchronizetoip) {
57
	if($synchronizetoip == $_SERVER['REMOTE_ADDR']) {
58 de63649b Rafael Lucas
		log_error(gettext("Disallowing CARP sync loop."));
59 ff664954 Scott Ullrich
		die;	
60
	}
61
}
62
63 8da3de34 Colin Smith
$xmlrpc_g = array(
64 137f46d8 Ermal
	"return" => array(
65
		"true" => new XML_RPC_Response(new XML_RPC_Value(true, $XML_RPC_Boolean)),
66
		"false" => new XML_RPC_Response(new XML_RPC_Value(false, $XML_RPC_Boolean)),
67
		"authfail" => new XML_RPC_Response(new XML_RPC_Value(gettext("Authentication failed"), $XML_RPC_String))
68
	)
69
);
70 8da3de34 Colin Smith
71
/*
72
 *   pfSense XMLRPC errors
73
 *   $XML_RPC_erruser + 1 = Auth failure
74
 */
75
$XML_RPC_erruser = 200;
76
77
/* EXPOSED FUNCTIONS */
78 de63649b Rafael Lucas
$exec_php_doc = gettext("XMLRPC wrapper for eval(). This method must be called with two parameters: a string containing the local system\'s password followed by the PHP code to evaluate.");
79 c3638879 Scott Ullrich
$exec_php_sig = array(
80 137f46d8 Ermal
	array(
81
		$XML_RPC_Boolean, // First signature element is return value.
82
		$XML_RPC_String, // password
83
		$XML_RPC_String, // shell code to exec
84
	)
85
);
86 c3638879 Scott Ullrich
87 3dd2a278 Scott Ullrich
function xmlrpc_authfail() {
88
	log_auth("webConfigurator authentication error for 'admin' from {$_SERVER['REMOTE_ADDR']}");
89
}
90
91 c3638879 Scott Ullrich
function exec_php_xmlrpc($raw_params) {
92
	global $config, $xmlrpc_g;
93 137f46d8 Ermal
94 c3638879 Scott Ullrich
	$params = xmlrpc_params_to_php($raw_params);
95 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
96
		xmlrpc_authfail();
97 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
98 3dd2a278 Scott Ullrich
	}
99 c3638879 Scott Ullrich
	$exec_php = $params[0];
100
	eval($exec_php);
101 2c0dd581 Scott Ullrich
	if($toreturn) {
102
		$response = XML_RPC_encode($toreturn);
103
		return new XML_RPC_Response($response);
104
	} else
105
		return $xmlrpc_g['return']['true'];
106 c3638879 Scott Ullrich
}
107
108
/*****************************/
109 de63649b Rafael Lucas
$exec_shell_doc = gettext("XMLRPC wrapper for mwexec(). This method must be called with two parameters: a string containing the local system\'s password followed by an shell command to execute.");
110 c3638879 Scott Ullrich
$exec_shell_sig = array(
111 137f46d8 Ermal
	array(
112
		$XML_RPC_Boolean, // First signature element is return value.
113
		$XML_RPC_String, // password
114
		$XML_RPC_String, // shell code to exec
115
	)
116
);
117 c3638879 Scott Ullrich
118
function exec_shell_xmlrpc($raw_params) {
119
	global $config, $xmlrpc_g;
120 137f46d8 Ermal
121 c3638879 Scott Ullrich
	$params = xmlrpc_params_to_php($raw_params);
122 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
123
		xmlrpc_authfail();
124 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
125 3dd2a278 Scott Ullrich
	}
126 c3638879 Scott Ullrich
	$shell_cmd = $params[0];
127
	mwexec($shell_cmd);
128 137f46d8 Ermal
129 c3638879 Scott Ullrich
	return $xmlrpc_g['return']['true'];
130
}
131
132
/*****************************/
133 de63649b Rafael Lucas
$backup_config_section_doc = gettext("XMLRPC wrapper for backup_config_section. This method must be called with two parameters: a string containing the local system\'s password followed by an array containing the keys to be backed up.");
134 8da3de34 Colin Smith
$backup_config_section_sig = array(
135 137f46d8 Ermal
	array(
136
		$XML_RPC_Struct, // First signature element is return value.
137
		$XML_RPC_String,
138
		$XML_RPC_Array
139
	)
140
);
141 21dc3a7d Colin Smith
142 57e6d4c9 Colin Smith
function backup_config_section_xmlrpc($raw_params) {
143 03d89831 Scott Ullrich
	global $config, $xmlrpc_g;
144 137f46d8 Ermal
145 8da3de34 Colin Smith
	$params = xmlrpc_params_to_php($raw_params);
146 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
147
		xmlrpc_authfail();
148 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
149 3dd2a278 Scott Ullrich
	}
150 03d89831 Scott Ullrich
	$val = array_intersect_key($config, array_flip($params[0]));
151 137f46d8 Ermal
152 8da3de34 Colin Smith
	return new XML_RPC_Response(XML_RPC_encode($val));
153 50d49018 Colin Smith
}
154
155 8da3de34 Colin Smith
/*****************************/
156 de63649b Rafael Lucas
$restore_config_section_doc = gettext("XMLRPC wrapper for restore_config_section. This method must be called with two parameters: a string containing the local system\'s password and an array to merge into the system\'s config. This function returns true upon completion.");
157 8da3de34 Colin Smith
$restore_config_section_sig = array(
158 137f46d8 Ermal
	array(
159
		$XML_RPC_Boolean,
160
		$XML_RPC_String,
161
		$XML_RPC_Struct
162
	)
163
);
164 21dc3a7d Colin Smith
165 57e6d4c9 Colin Smith
function restore_config_section_xmlrpc($raw_params) {
166 03d89831 Scott Ullrich
	global $config, $xmlrpc_g;
167 137f46d8 Ermal
168 57e6d4c9 Colin Smith
	$params = xmlrpc_params_to_php($raw_params);
169 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
170
		xmlrpc_authfail();
171 19b5c3e7 Ermal
		return $xmlrpc_g['return']['authfail'];
172 3dd2a278 Scott Ullrich
	}
173 1b99e1e5 jim-p
174
	// Some sections should just be copied and not merged or we end
175
	//   up unable to sync the deletion of the last item in a section
176
	$sync_full = array('ipsec', 'aliases', 'wol', 'load_balancer', 'openvpn', 'cert', 'ca', 'crl', 'schedules');
177
	$sync_full_done = array();
178
	foreach ($sync_full as $syncfull) {
179
		if (isset($params[0][$syncfull])) {
180
			$config[$syncfull] = $params[0][$syncfull];
181
			unset($params[0][$syncfull]);
182
			$sync_full_done[] = $syncfull;
183
		}
184
	}
185
186 a8200dbf Ermal
	$vipbackup = array();
187 51611440 Ermal
	$oldvips = array();
188 4d775dd0 Ermal
	if (isset($params[0]['virtualip'])) {
189 19b5c3e7 Ermal
		if(is_array($config['virtualip']['vip'])) {
190 51611440 Ermal
			foreach ($config['virtualip']['vip'] as $vipindex => $vip) {
191
				if ($vip['mode'] == "carp")
192
					$oldvips[$vip['vhid']] = "{$vip['password']}{$vip['advskew']}{$vip['subnet']}{$vip['subnet_bits']}{$vip['advbase']}";
193 2708a5cf Ermal
				else if ($vip['mode'] == "ipalias" && substr($vip['interface'], 0, 3) == "vip")
194
					$oldvips[$vip['subnet']] = "{$vip['interface']}{$vip['subnet']}{$vip['subnet_bits']}";
195
				else if (($vip['mode'] == "ipalias" || $vip['mode'] == 'proxyarp') && substr($vip['interface'], 0, 3) != "vip")
196 51611440 Ermal
					$vipbackup[] = $vip;
197
			}
198 19b5c3e7 Ermal
		}
199
	}
200 f51d4f98 Ermal
201 b019222a pierrepomes
        // For vip section, first keep items sent from the master
202 aa6699fb jim-p
	$config = array_merge_recursive_unique($config, $params[0]);
203 51611440 Ermal
204 f51d4f98 Ermal
        /* Then add ipalias and proxyarp types already defined on the backup */
205
	if (is_array($vipbackup) && !empty($vipbackup)) {
206 51611440 Ermal
		if (!is_array($config['virtualip']))
207
			$config['virtualip'] = array();
208 f51d4f98 Ermal
		if (!is_array($config['virtualip']['vip']))
209
			$config['virtualip']['vip'] = array();
210
		foreach ($vipbackup as $vip)
211 51611440 Ermal
			array_unshift($config['virtualip']['vip'], $vip);
212 a8200dbf Ermal
	}
213 51611440 Ermal
214
	/* Log what happened */
215 1b99e1e5 jim-p
	$mergedkeys = implode(",", array_merge(array_keys($params[0]), $sync_full_done));
216 3a3fb8ea Erik Fonnesbeck
	write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."),$mergedkeys));
217 51611440 Ermal
218
	/* 
219
	 * The real work on handling the vips specially
220
	 * This is a copy of intefaces_vips_configure with addition of not reloading existing/not changed carps
221
	 */
222 63f81fbd Ermal
	if (isset($params[0]['virtualip']) && is_array($config['virtualip']) && is_array($config['virtualip']['vip'])) {
223 51611440 Ermal
		$carp_setuped = false;
224 f51d4f98 Ermal
		$anyproxyarp = false;
225 51611440 Ermal
		foreach ($config['virtualip']['vip'] as $vip) {
226 2708a5cf Ermal
			if ($vip['mode'] == "carp" && isset($oldvips[$vip['vhid']])) {
227 51611440 Ermal
				if ($oldvips[$vip['vhid']] == "{$vip['password']}{$vip['advskew']}{$vip['subnet']}{$vip['subnet_bits']}{$vip['advbase']}") {
228 2708a5cf Ermal
					if (does_vip_exist($vip)) {
229 19ed1624 Ermal
						unset($oldvips[$vip['vhid']]);
230 d1e03822 Ermal
						continue; // Skip reconfiguring this vips since nothing has changed.
231 19ed1624 Ermal
					}
232 92ca32cc Ermal
				}
233 19ed1624 Ermal
				unset($oldvips[$vip['vhid']]);
234 2708a5cf Ermal
			} else if ($vip['mode'] == "ipalias" && substr($vip['interface'], 0, 3) == "vip" && isset($oldvips[$vip['subnet']])) {
235
				if ($oldvips[$vip['subnet']] = "{$vip['interface']}{$vip['subnet']}{$vip['subnet_bits']}") {
236
					if (does_vip_exist($vip)) {
237
						unset($oldvips[$vip['subnet']]);
238
						continue; // Skip reconfiguring this vips since nothing has changed.
239
					}
240
				}
241
				unset($oldvips[$vip['subnet']]);
242 51611440 Ermal
			}
243
244
			switch ($vip['mode']) {
245
			case "proxyarp":
246
				$anyproxyarp = true;
247
				break;
248
			case "ipalias":
249
				interface_ipalias_configure(&$vip);
250
				break;
251
			case "carp":
252
				if ($carp_setuped == false)
253
                                        $carp_setuped = true;
254
				interface_carp_configure($vip);
255
				break;
256
			case "carpdev-dhcp":
257
				interface_carpdev_configure($vip);
258
				break;
259
			}
260
		}
261
		/* Cleanup remaining old carps */
262
		foreach ($oldvips as $oldvipif => $oldvippar) {
263 2708a5cf Ermal
			if (!is_ipaddr($oldvipif) && does_interface_exist("vip{$oldvipif}"))
264 51611440 Ermal
				pfSense_interface_destroy("vip{$oldvipif}");
265
		}
266
		if ($carp_setuped == true)
267
			interfaces_carp_setup();
268
		if ($anyproxyarp == true)
269
			interface_proxyarp_configure();
270
	}
271 137f46d8 Ermal
272 8da3de34 Colin Smith
	return $xmlrpc_g['return']['true'];
273 50d49018 Colin Smith
}
274
275 82ae5cfc Scott Ullrich
/*****************************/
276 de63649b Rafael Lucas
$merge_config_section_doc = gettext("XMLRPC wrapper for merging package sections. This method must be called with two parameters: a string containing the local system\'s password and an array to merge into the system\'s config. This function returns true upon completion.");
277 82ae5cfc Scott Ullrich
$merge_config_section_sig = array(
278 137f46d8 Ermal
	array(
279
		$XML_RPC_Boolean,
280
		$XML_RPC_String,
281
		$XML_RPC_Struct
282
	)
283
);
284 82ae5cfc Scott Ullrich
285
function merge_installedpackages_section_xmlrpc($raw_params) {
286
	global $config, $xmlrpc_g;
287 137f46d8 Ermal
288 82ae5cfc Scott Ullrich
	$params = xmlrpc_params_to_php($raw_params);
289 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
290
		xmlrpc_authfail();
291 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
292 3dd2a278 Scott Ullrich
	}
293 82ae5cfc Scott Ullrich
	$config['installedpackages'] = array_merge($config['installedpackages'], $params[0]);
294
	$mergedkeys = implode(",", array_keys($params[0]));
295 3a3fb8ea Erik Fonnesbeck
	write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."),$mergedkeys));
296 137f46d8 Ermal
297 82ae5cfc Scott Ullrich
	return $xmlrpc_g['return']['true'];
298
}
299
300 8da3de34 Colin Smith
/*****************************/
301 de63649b Rafael Lucas
$merge_config_section_doc = gettext("XMLRPC wrapper for merge_config_section. This method must be called with two parameters: a string containing the local system\'s password and an array to merge into the system\'s config. This function returns true upon completion.");
302 dc1cd85d Scott Ullrich
$merge_config_section_sig = array(
303 137f46d8 Ermal
	array(
304
		$XML_RPC_Boolean,
305
		$XML_RPC_String,
306
		$XML_RPC_Struct
307
	)
308
);
309 dc1cd85d Scott Ullrich
310
function merge_config_section_xmlrpc($raw_params) {
311
	global $config, $xmlrpc_g;
312 db748384 Scott Ullrich
	$params = xmlrpc_params_to_php($raw_params);
313 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
314
		xmlrpc_authfail();
315 db748384 Scott Ullrich
		return $xmlrpc_g['return']['authfail'];
316 3dd2a278 Scott Ullrich
	}
317 f9d7c5b3 Scott Ullrich
	$config_new = array_overlay($config, $params[0]);
318 db748384 Scott Ullrich
	$config = $config_new;
319
	$mergedkeys = implode(",", array_keys($params[0]));
320
	write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."), $mergedkeys));
321
	return $xmlrpc_g['return']['true'];
322 dc1cd85d Scott Ullrich
}
323
324
/*****************************/
325 de63649b Rafael Lucas
$filter_configure_doc = gettext("Basic XMLRPC wrapper for filter_configure. This method must be called with one paramater: a string containing the local system\'s password. This function returns true upon completion.");
326 8da3de34 Colin Smith
$filter_configure_sig = array(
327 137f46d8 Ermal
	array(
328
		$XML_RPC_Boolean,
329
		$XML_RPC_String
330
	)
331
);
332 07a7b08f Colin Smith
333
function filter_configure_xmlrpc($raw_params) {
334 8da3de34 Colin Smith
	global $xmlrpc_g;
335 137f46d8 Ermal
336 07a7b08f Colin Smith
	$params = xmlrpc_params_to_php($raw_params);
337 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
338
		xmlrpc_authfail();
339 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
340 3dd2a278 Scott Ullrich
	}
341 07a7b08f Colin Smith
	filter_configure();
342 e700437b Scott Ullrich
	system_routing_configure();
343 41e6d4bd Seth Mos
	setup_gateways_monitor();
344 651c32e2 Bill Marquette
	relayd_configure();
345 c3fef0c9 jim-p
	require_once("openvpn.inc");
346
	openvpn_resync_all();
347
	services_dhcpd_configure();
348 62c4d0fb jim-p
	services_dnsmasq_configure();
349 0ce72662 jim-p
	local_sync_accounts();
350 137f46d8 Ermal
351 8da3de34 Colin Smith
	return $xmlrpc_g['return']['true'];
352 07a7b08f Colin Smith
}
353
354 8da3de34 Colin Smith
/*****************************/
355 de63649b Rafael Lucas
$carp_configure_doc = gettext("Basic XMLRPC wrapper for configuring CARP interfaces.");
356 efe7562e Scott Ullrich
$carp_configure_sig = array(
357 137f46d8 Ermal
	array(
358
		$XML_RPC_Boolean,
359
		$XML_RPC_String
360
	)
361
);
362 efe7562e Scott Ullrich
363
function interfaces_carp_configure_xmlrpc($raw_params) {
364
	global $xmlrpc_g;
365 137f46d8 Ermal
366 efe7562e Scott Ullrich
	$params = xmlrpc_params_to_php($raw_params);
367 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
368
		xmlrpc_authfail();
369 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
370 3dd2a278 Scott Ullrich
	}
371 efe7562e Scott Ullrich
	interfaces_vips_configure();
372 137f46d8 Ermal
373 efe7562e Scott Ullrich
	return $xmlrpc_g['return']['true'];
374
}
375
376
/*****************************/
377 de63649b Rafael Lucas
$check_firmware_version_doc = gettext("Basic XMLRPC wrapper for check_firmware_version. This function will return the output of check_firmware_version upon completion.");
378 137f46d8 Ermal
379 8da3de34 Colin Smith
$check_firmware_version_sig = array(
380 137f46d8 Ermal
	array(
381
		$XML_RPC_String,
382
		$XML_RPC_String
383
	)
384
);
385 44488c3c Colin Smith
386
function check_firmware_version_xmlrpc($raw_params) {
387 b4d19b46 Bill Marquette
	global $xmlrpc_g, $XML_RPC_String;
388 137f46d8 Ermal
389 b4d19b46 Bill Marquette
	$params = xmlrpc_params_to_php($raw_params);
390 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
391
		xmlrpc_authfail();
392 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
393 3dd2a278 Scott Ullrich
	}
394 8da3de34 Colin Smith
	return new XML_RPC_Response(new XML_RPC_Value(check_firmware_version(false), $XML_RPC_String));
395 44488c3c Colin Smith
}
396
397 e501de37 Ermal
/*****************************/
398 0567899d Ermal
$pfsense_firmware_version_doc = gettext("Basic XMLRPC wrapper for check_firmware_version. This function will return the output of check_firmware_version upon completion.");
399
400
$pfsense_firmware_version_sig = array (
401
        array (
402
                $XML_RPC_Struct,
403
                $XML_RPC_String
404
        )
405
);
406 e501de37 Ermal
407
function pfsense_firmware_version_xmlrpc($raw_params) {
408 0567899d Ermal
        global $xmlrpc_g;
409 e501de37 Ermal
410
        $params = xmlrpc_params_to_php($raw_params);
411 3dd2a278 Scott Ullrich
        if(!xmlrpc_auth($params)) {
412
			xmlrpc_authfail();
413
			return $xmlrpc_g['return']['authfail'];
414
		}
415 0567899d Ermal
        return new XML_RPC_Response(XML_RPC_encode(host_firmware_version()));
416 e501de37 Ermal
}
417
418 8da3de34 Colin Smith
/*****************************/
419 de63649b Rafael Lucas
$reboot_doc = gettext("Basic XMLRPC wrapper for rc.reboot.");
420 1cdca133 Colin Smith
$reboot_sig = array(array($XML_RPC_Boolean, $XML_RPC_String));
421 bd0fe65b Colin Smith
function reboot_xmlrpc($raw_params) {
422 8da3de34 Colin Smith
	global $xmlrpc_g;
423 137f46d8 Ermal
424 bd0fe65b Colin Smith
	$params = xmlrpc_params_to_php($raw_params);
425 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
426
		xmlrpc_authfail();
427 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
428 3dd2a278 Scott Ullrich
	}
429 53cf5533 Colin Smith
	mwexec_bg("/etc/rc.reboot");
430 137f46d8 Ermal
431 8da3de34 Colin Smith
	return $xmlrpc_g['return']['true'];
432 bd0fe65b Colin Smith
}
433
434 8da3de34 Colin Smith
/*****************************/
435
$get_notices_sig = array(
436 137f46d8 Ermal
	array(
437
		$XML_RPC_Array,
438
		$XML_RPC_String
439
	),
440
	array(
441
		$XML_RPC_Array
442
	)
443
);
444 8da3de34 Colin Smith
445 d9064267 Colin Smith
function get_notices_xmlrpc($raw_params) {
446 8da3de34 Colin Smith
	global $g, $xmlrpc_g;
447 137f46d8 Ermal
448 b4d19b46 Bill Marquette
	$params = xmlrpc_params_to_php($raw_params);
449 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
450
		xmlrpc_authfail();
451
		return $xmlrpc_g['return']['authfail'];
452
	}
453 0674f163 sullrich
	require("notices.inc");
454 8da3de34 Colin Smith
	if(!$params) {
455 d9064267 Colin Smith
		$toreturn = get_notices();
456
	} else {
457 8da3de34 Colin Smith
		$toreturn = get_notices($params);
458 d9064267 Colin Smith
	}
459
	$response = new XML_RPC_Response(XML_RPC_encode($toreturn));
460 137f46d8 Ermal
461 d9064267 Colin Smith
	return $response;
462
}
463
464 67d78c87 Ermal
$xmlrpclockkey = lock('xmlrpc', LOCK_EX);
465
466 8da3de34 Colin Smith
/*****************************/
467 21dc3a7d Colin Smith
$server = new XML_RPC_Server(
468
        array(
469 137f46d8 Ermal
		'pfsense.exec_shell' => array('function' => 'exec_shell_xmlrpc',
470 0567899d Ermal
			'signature' => $exec_shell_sig,
471
			'docstring' => $exec_shell_doc),
472 137f46d8 Ermal
		'pfsense.exec_php' => array('function' => 'exec_php_xmlrpc',
473 0567899d Ermal
			'signature' => $exec_php_sig,
474
			'docstring' => $exec_php_doc),	
475 137f46d8 Ermal
		'pfsense.filter_configure' => array('function' => 'filter_configure_xmlrpc',
476 0567899d Ermal
			'signature' => $filter_configure_sig,
477
			'docstring' => $filter_configure_doc),
478 137f46d8 Ermal
		'pfsense.interfaces_carp_configure' => array('function' => 'interfaces_carp_configure_xmlrpc',
479 0567899d Ermal
			'docstring' => $carp_configure_sig),
480 137f46d8 Ermal
		'pfsense.backup_config_section' => array('function' => 'backup_config_section_xmlrpc',
481 0567899d Ermal
			'signature' => $backup_config_section_sig,
482
			'docstring' => $backup_config_section_doc),
483 137f46d8 Ermal
		'pfsense.restore_config_section' => array('function' => 'restore_config_section_xmlrpc',
484 0567899d Ermal
			'signature' => $restore_config_section_sig,
485
			'docstring' => $restore_config_section_doc),
486 137f46d8 Ermal
		'pfsense.merge_config_section' => array('function' => 'merge_config_section_xmlrpc',
487 0567899d Ermal
			'signature' => $merge_config_section_sig,
488
			'docstring' => $merge_config_section_doc),
489 137f46d8 Ermal
		'pfsense.merge_installedpackages_section_xmlrpc' => array('function' => 'merge_installedpackages_section_xmlrpc',
490 0567899d Ermal
			'signature' => $merge_config_section_sig,
491
			'docstring' => $merge_config_section_doc),							
492 137f46d8 Ermal
		'pfsense.check_firmware_version' => array('function' => 'check_firmware_version_xmlrpc',
493 0567899d Ermal
			'signature' => $check_firmware_version_sig,
494
			'docstring' => $check_firmware_version_doc),
495 e501de37 Ermal
		'pfsense.host_firmware_version' => array('function' => 'pfsense_firmware_version_xmlrpc',
496 0567899d Ermal
			'signature' => $pfsense_firmware_version_sig,
497
			'docstring' => $host_firmware_version_doc),
498 137f46d8 Ermal
		'pfsense.reboot' => array('function' => 'reboot_xmlrpc',
499 0567899d Ermal
			'signature' => $reboot_sig,
500
			'docstring' => $reboot_doc),
501 137f46d8 Ermal
		'pfsense.get_notices' => array('function' => 'get_notices_xmlrpc',
502 0567899d Ermal
			'signature' => $get_notices_sig)
503 50d49018 Colin Smith
        )
504
);
505 b298dd06 Scott Ullrich
506 67d78c87 Ermal
unlock($xmlrpclockkey);
507
508 f9d7c5b3 Scott Ullrich
    function array_overlay($a1,$a2)
509
    {
510
        foreach($a1 as $k => $v) {
511
            if(!array_key_exists($k,$a2)) continue;
512
            if(is_array($v) && is_array($a2[$k])){
513
                $a1[$k] = array_overlay($v,$a2[$k]);
514
            }else{
515
                $a1[$k] = $a2[$k];
516 0b581a8a Scott Ullrich
            }
517
        }
518 f9d7c5b3 Scott Ullrich
        return $a1;
519 0b581a8a Scott Ullrich
    }
520
521 de63649b Rafael Lucas
?>