1
|
<?php
|
2
|
/*
|
3
|
* xmlrpc.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7
|
* 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
|
18
|
* the documentation and/or other materials provided with the
|
19
|
* distribution.
|
20
|
*
|
21
|
* 3. All advertising materials mentioning features or use of this software
|
22
|
* must display the following acknowledgment:
|
23
|
* "This product includes software developed by the pfSense Project
|
24
|
* for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
25
|
*
|
26
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
27
|
* endorse or promote products derived from this software without
|
28
|
* prior written permission. For written permission, please contact
|
29
|
* coreteam@pfsense.org.
|
30
|
*
|
31
|
* 5. Products derived from this software may not be called "pfSense"
|
32
|
* nor may "pfSense" appear in their names without prior written
|
33
|
* permission of the Electric Sheep Fencing, LLC.
|
34
|
*
|
35
|
* 6. Redistributions of any form whatsoever must retain the following
|
36
|
* acknowledgment:
|
37
|
*
|
38
|
* "This product includes software developed by the pfSense Project
|
39
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
40
|
*
|
41
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
42
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
43
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
44
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
45
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
46
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
47
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
48
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
49
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
50
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
51
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
52
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
53
|
*/
|
54
|
|
55
|
##|+PRIV
|
56
|
##|*IDENT=page-xmlrpclibrary
|
57
|
##|*NAME=XMLRPC Library
|
58
|
##|*DESCR=Allow access to the 'XMLRPC Library' page.
|
59
|
##|*MATCH=xmlrpc.php*
|
60
|
##|-PRIV
|
61
|
|
62
|
require_once("config.inc");
|
63
|
require_once("functions.inc");
|
64
|
require_once("filter.inc");
|
65
|
require_once("ipsec.inc");
|
66
|
require_once("vpn.inc");
|
67
|
require_once("shaper.inc");
|
68
|
require_once("xmlrpc_server.inc");
|
69
|
require_once("xmlrpc.inc");
|
70
|
|
71
|
function xmlrpc_loop_detect() {
|
72
|
global $config;
|
73
|
|
74
|
/* grab sync to ip if enabled */
|
75
|
if ($config['hasync']) {
|
76
|
$synchronizetoip = $config['hasync']['synchronizetoip'];
|
77
|
}
|
78
|
if ($synchronizetoip) {
|
79
|
if ($synchronizetoip == $_SERVER['REMOTE_ADDR']) {
|
80
|
return true;
|
81
|
}
|
82
|
}
|
83
|
|
84
|
return false;
|
85
|
}
|
86
|
|
87
|
$xmlrpc_g = array(
|
88
|
"return" => array(
|
89
|
"true" => new XML_RPC_Response(new XML_RPC_Value(true, $XML_RPC_Boolean)),
|
90
|
"false" => new XML_RPC_Response(new XML_RPC_Value(false, $XML_RPC_Boolean)),
|
91
|
"authfail" => new XML_RPC_Response(new XML_RPC_Value(gettext("Authentication failed"), $XML_RPC_String))
|
92
|
)
|
93
|
);
|
94
|
|
95
|
/*
|
96
|
* pfSense XMLRPC errors
|
97
|
* $XML_RPC_erruser + 1 = Auth failure
|
98
|
*/
|
99
|
$XML_RPC_erruser = 200;
|
100
|
|
101
|
/* EXPOSED FUNCTIONS */
|
102
|
$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.");
|
103
|
$exec_php_sig = array(
|
104
|
array(
|
105
|
$XML_RPC_Boolean, // First signature element is return value.
|
106
|
$XML_RPC_String, // password
|
107
|
$XML_RPC_String, // shell code to exec
|
108
|
)
|
109
|
);
|
110
|
|
111
|
function xmlrpc_authfail() {
|
112
|
log_auth("webConfigurator authentication error for 'admin' from {$_SERVER['REMOTE_ADDR']}");
|
113
|
}
|
114
|
|
115
|
function exec_php_xmlrpc($raw_params) {
|
116
|
global $config, $xmlrpc_g;
|
117
|
|
118
|
$params = xmlrpc_params_to_php($raw_params);
|
119
|
if (!xmlrpc_auth($params)) {
|
120
|
xmlrpc_authfail();
|
121
|
return $xmlrpc_g['return']['authfail'];
|
122
|
}
|
123
|
$exec_php = $params[0];
|
124
|
eval($exec_php);
|
125
|
if ($toreturn) {
|
126
|
$response = XML_RPC_encode($toreturn);
|
127
|
return new XML_RPC_Response($response);
|
128
|
} else {
|
129
|
return $xmlrpc_g['return']['true'];
|
130
|
}
|
131
|
}
|
132
|
|
133
|
/*****************************/
|
134
|
$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.");
|
135
|
$exec_shell_sig = array(
|
136
|
array(
|
137
|
$XML_RPC_Boolean, // First signature element is return value.
|
138
|
$XML_RPC_String, // password
|
139
|
$XML_RPC_String, // shell code to exec
|
140
|
)
|
141
|
);
|
142
|
|
143
|
function exec_shell_xmlrpc($raw_params) {
|
144
|
global $config, $xmlrpc_g;
|
145
|
|
146
|
$params = xmlrpc_params_to_php($raw_params);
|
147
|
if (!xmlrpc_auth($params)) {
|
148
|
xmlrpc_authfail();
|
149
|
return $xmlrpc_g['return']['authfail'];
|
150
|
}
|
151
|
$shell_cmd = $params[0];
|
152
|
mwexec($shell_cmd);
|
153
|
|
154
|
return $xmlrpc_g['return']['true'];
|
155
|
}
|
156
|
|
157
|
/*****************************/
|
158
|
$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.");
|
159
|
$backup_config_section_sig = array(
|
160
|
array(
|
161
|
$XML_RPC_Struct, // First signature element is return value.
|
162
|
$XML_RPC_String,
|
163
|
$XML_RPC_Array
|
164
|
)
|
165
|
);
|
166
|
|
167
|
function backup_config_section_xmlrpc($raw_params) {
|
168
|
global $config, $xmlrpc_g;
|
169
|
|
170
|
if (xmlrpc_loop_detect()) {
|
171
|
log_error("Disallowing CARP sync loop");
|
172
|
return;
|
173
|
}
|
174
|
|
175
|
$params = xmlrpc_params_to_php($raw_params);
|
176
|
if (!xmlrpc_auth($params)) {
|
177
|
xmlrpc_authfail();
|
178
|
return $xmlrpc_g['return']['authfail'];
|
179
|
}
|
180
|
$val = array_intersect_key($config, array_flip($params[0]));
|
181
|
|
182
|
return new XML_RPC_Response(XML_RPC_encode($val));
|
183
|
}
|
184
|
|
185
|
/*****************************/
|
186
|
$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.");
|
187
|
$restore_config_section_sig = array(
|
188
|
array(
|
189
|
$XML_RPC_Boolean,
|
190
|
$XML_RPC_String,
|
191
|
$XML_RPC_Struct
|
192
|
)
|
193
|
);
|
194
|
|
195
|
function restore_config_section_xmlrpc($raw_params) {
|
196
|
global $config, $xmlrpc_g;
|
197
|
|
198
|
$old_config = $config;
|
199
|
$old_ipsec_enabled = ipsec_enabled();
|
200
|
|
201
|
if (xmlrpc_loop_detect()) {
|
202
|
log_error("Disallowing CARP sync loop");
|
203
|
return;
|
204
|
}
|
205
|
|
206
|
$params = xmlrpc_params_to_php($raw_params);
|
207
|
if (!xmlrpc_auth($params)) {
|
208
|
xmlrpc_authfail();
|
209
|
return $xmlrpc_g['return']['authfail'];
|
210
|
}
|
211
|
|
212
|
// Some sections should just be copied and not merged or we end
|
213
|
// up unable to sync the deletion of the last item in a section
|
214
|
$sync_full = array('dnsmasq', 'unbound', 'ipsec', 'aliases', 'wol', 'load_balancer', 'openvpn', 'cert', 'ca', 'crl', 'schedules', 'filter', 'nat', 'dhcpd', 'dhcpv6');
|
215
|
$sync_full_done = array();
|
216
|
foreach ($sync_full as $syncfull) {
|
217
|
if (isset($params[0][$syncfull])) {
|
218
|
$config[$syncfull] = $params[0][$syncfull];
|
219
|
unset($params[0][$syncfull]);
|
220
|
$sync_full_done[] = $syncfull;
|
221
|
}
|
222
|
}
|
223
|
|
224
|
$vipbackup = array();
|
225
|
$oldvips = array();
|
226
|
if (isset($params[0]['virtualip'])) {
|
227
|
if (is_array($config['virtualip']['vip'])) {
|
228
|
foreach ($config['virtualip']['vip'] as $vipindex => $vip) {
|
229
|
if ($vip['mode'] == "carp") {
|
230
|
$oldvips["{$vip['interface']}_vip{$vip['vhid']}"]['content'] = "{$vip['password']}{$vip['advskew']}{$vip['subnet']}{$vip['subnet_bits']}{$vip['advbase']}";
|
231
|
$oldvips["{$vip['interface']}_vip{$vip['vhid']}"]['interface'] = $vip['interface'];
|
232
|
$oldvips["{$vip['interface']}_vip{$vip['vhid']}"]['subnet'] = $vip['subnet'];
|
233
|
} else if ($vip['mode'] == "ipalias" && (substr($vip['interface'], 0, 4) == '_vip' || strstr($vip['interface'], "lo0"))) {
|
234
|
$oldvips[$vip['subnet']]['content'] = "{$vip['interface']}{$vip['subnet']}{$vip['subnet_bits']}";
|
235
|
$oldvips[$vip['subnet']]['interface'] = $vip['interface'];
|
236
|
$oldvips[$vip['subnet']]['subnet'] = $vip['subnet'];
|
237
|
} else if (($vip['mode'] == "ipalias" || $vip['mode'] == 'proxyarp') && !(substr($vip['interface'], 0, 4) == '_vip') || strstr($vip['interface'], "lo0")) {
|
238
|
$vipbackup[] = $vip;
|
239
|
}
|
240
|
}
|
241
|
}
|
242
|
}
|
243
|
|
244
|
// For vip section, first keep items sent from the master
|
245
|
$config = array_merge_recursive_unique($config, $params[0]);
|
246
|
|
247
|
/* Then add ipalias and proxyarp types already defined on the backup */
|
248
|
if (is_array($vipbackup) && !empty($vipbackup)) {
|
249
|
if (!is_array($config['virtualip'])) {
|
250
|
$config['virtualip'] = array();
|
251
|
}
|
252
|
if (!is_array($config['virtualip']['vip'])) {
|
253
|
$config['virtualip']['vip'] = array();
|
254
|
}
|
255
|
foreach ($vipbackup as $vip) {
|
256
|
array_unshift($config['virtualip']['vip'], $vip);
|
257
|
}
|
258
|
}
|
259
|
|
260
|
/* Log what happened */
|
261
|
$mergedkeys = implode(",", array_merge(array_keys($params[0]), $sync_full_done));
|
262
|
write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."), $mergedkeys));
|
263
|
|
264
|
/*
|
265
|
* The real work on handling the vips specially
|
266
|
* This is a copy of intefaces_vips_configure with addition of not reloading existing/not changed carps
|
267
|
*/
|
268
|
if (isset($params[0]['virtualip']) && is_array($config['virtualip']) && is_array($config['virtualip']['vip'])) {
|
269
|
$carp_setuped = false;
|
270
|
$anyproxyarp = false;
|
271
|
foreach ($config['virtualip']['vip'] as $vip) {
|
272
|
if ($vip['mode'] == "carp" && isset($oldvips["{$vip['interface']}_vip{$vip['vhid']}"])) {
|
273
|
if ($oldvips["{$vip['interface']}_vip{$vip['vhid']}"]['content'] == "{$vip['password']}{$vip['advskew']}{$vip['subnet']}{$vip['subnet_bits']}{$vip['advbase']}") {
|
274
|
if (does_vip_exist($vip)) {
|
275
|
unset($oldvips["{$vip['interface']}_vip{$vip['vhid']}"]);
|
276
|
continue; // Skip reconfiguring this vips since nothing has changed.
|
277
|
}
|
278
|
}
|
279
|
} else if ($vip['mode'] == "ipalias" && (substr($vip['interface'], 0, 4) == '_vip' || strstr($vip['interface'], "lo0")) && isset($oldvips[$vip['subnet']])) {
|
280
|
if ($oldvips[$vip['subnet']]['content'] == "{$vip['interface']}{$vip['subnet']}{$vip['subnet_bits']}") {
|
281
|
if (does_vip_exist($vip)) {
|
282
|
unset($oldvips[$vip['subnet']]);
|
283
|
continue; // Skip reconfiguring this vips since nothing has changed.
|
284
|
}
|
285
|
}
|
286
|
unset($oldvips[$vip['subnet']]);
|
287
|
}
|
288
|
|
289
|
switch ($vip['mode']) {
|
290
|
case "proxyarp":
|
291
|
$anyproxyarp = true;
|
292
|
break;
|
293
|
case "ipalias":
|
294
|
interface_ipalias_configure($vip);
|
295
|
break;
|
296
|
case "carp":
|
297
|
if ($carp_setuped == false) {
|
298
|
$carp_setuped = true;
|
299
|
}
|
300
|
interface_carp_configure($vip);
|
301
|
break;
|
302
|
}
|
303
|
}
|
304
|
/* Cleanup remaining old carps */
|
305
|
foreach ($oldvips as $oldvipar) {
|
306
|
$oldvipif = get_real_interface($oldvipar['interface']);
|
307
|
if (!empty($oldvipif)) {
|
308
|
if (is_ipaddrv6($oldvipar['subnet'])) {
|
309
|
mwexec("/sbin/ifconfig " . escapeshellarg($oldvipif) . " inet6 " . escapeshellarg($oldvipar['subnet']) . " delete");
|
310
|
} else {
|
311
|
pfSense_interface_deladdress($oldvipif, $oldvipar['subnet']);
|
312
|
}
|
313
|
}
|
314
|
}
|
315
|
if ($carp_setuped == true) {
|
316
|
interfaces_sync_setup();
|
317
|
}
|
318
|
if ($anyproxyarp == true) {
|
319
|
interface_proxyarp_configure();
|
320
|
}
|
321
|
}
|
322
|
|
323
|
if ($old_ipsec_enabled !== ipsec_enabled()) {
|
324
|
vpn_ipsec_configure();
|
325
|
}
|
326
|
|
327
|
unset($old_config);
|
328
|
|
329
|
return $xmlrpc_g['return']['true'];
|
330
|
}
|
331
|
|
332
|
/*****************************/
|
333
|
$merge_installedpackages_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.");
|
334
|
$merge_installedpackages_section_sig = array(
|
335
|
array(
|
336
|
$XML_RPC_Boolean,
|
337
|
$XML_RPC_String,
|
338
|
$XML_RPC_Struct
|
339
|
)
|
340
|
);
|
341
|
|
342
|
function merge_installedpackages_section_xmlrpc($raw_params) {
|
343
|
global $config, $xmlrpc_g;
|
344
|
|
345
|
if (xmlrpc_loop_detect()) {
|
346
|
log_error("Disallowing CARP sync loop");
|
347
|
return;
|
348
|
}
|
349
|
|
350
|
$params = xmlrpc_params_to_php($raw_params);
|
351
|
if (!xmlrpc_auth($params)) {
|
352
|
xmlrpc_authfail();
|
353
|
return $xmlrpc_g['return']['authfail'];
|
354
|
}
|
355
|
$config['installedpackages'] = array_merge($config['installedpackages'], $params[0]);
|
356
|
$mergedkeys = implode(",", array_keys($params[0]));
|
357
|
write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."), $mergedkeys));
|
358
|
|
359
|
return $xmlrpc_g['return']['true'];
|
360
|
}
|
361
|
|
362
|
/*****************************/
|
363
|
$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.");
|
364
|
$merge_config_section_sig = array(
|
365
|
array(
|
366
|
$XML_RPC_Boolean,
|
367
|
$XML_RPC_String,
|
368
|
$XML_RPC_Struct
|
369
|
)
|
370
|
);
|
371
|
|
372
|
function merge_config_section_xmlrpc($raw_params) {
|
373
|
global $config, $xmlrpc_g;
|
374
|
|
375
|
if (xmlrpc_loop_detect()) {
|
376
|
log_error("Disallowing CARP sync loop");
|
377
|
return;
|
378
|
}
|
379
|
|
380
|
$params = xmlrpc_params_to_php($raw_params);
|
381
|
if (!xmlrpc_auth($params)) {
|
382
|
xmlrpc_authfail();
|
383
|
return $xmlrpc_g['return']['authfail'];
|
384
|
}
|
385
|
$config_new = array_overlay($config, $params[0]);
|
386
|
$config = $config_new;
|
387
|
$mergedkeys = implode(",", array_keys($params[0]));
|
388
|
write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."), $mergedkeys));
|
389
|
return $xmlrpc_g['return']['true'];
|
390
|
}
|
391
|
|
392
|
/*****************************/
|
393
|
$filter_configure_doc = gettext("Basic XMLRPC wrapper for filter_configure. This method must be called with one parameter: a string containing the local system\'s password. This function returns true upon completion.");
|
394
|
$filter_configure_sig = array(
|
395
|
array(
|
396
|
$XML_RPC_Boolean,
|
397
|
$XML_RPC_String
|
398
|
)
|
399
|
);
|
400
|
|
401
|
function filter_configure_xmlrpc($raw_params) {
|
402
|
global $xmlrpc_g, $g, $config;
|
403
|
|
404
|
$params = xmlrpc_params_to_php($raw_params);
|
405
|
if (!xmlrpc_auth($params)) {
|
406
|
xmlrpc_authfail();
|
407
|
return $xmlrpc_g['return']['authfail'];
|
408
|
}
|
409
|
filter_configure();
|
410
|
system_routing_configure();
|
411
|
setup_gateways_monitor();
|
412
|
relayd_configure();
|
413
|
require_once("openvpn.inc");
|
414
|
openvpn_resync_all();
|
415
|
|
416
|
/* The DNS Resolver and the DNS Forwarder may both be active so long as
|
417
|
* they are running on different ports. See ticket #5882
|
418
|
*/
|
419
|
$need_dhcp_start = true;
|
420
|
if (isset($config['dnsmasq']['enable'])) {
|
421
|
/* Configure dnsmasq but tell it NOT to restart DHCP */
|
422
|
services_dnsmasq_configure(false);
|
423
|
} else {
|
424
|
/* kill any running dnsmasq since it is not enabled. */
|
425
|
if (file_exists("{$g['varrun_path']}/dnsmasq.pid")) {
|
426
|
sigkillbypid("{$g['varrun_path']}/dnsmasq.pid", "TERM");
|
427
|
}
|
428
|
}
|
429
|
if (isset($config['unbound']['enable'])) {
|
430
|
/* Configure unbound but tell it NOT to restart DHCP */
|
431
|
services_unbound_configure(false);
|
432
|
} else {
|
433
|
/* kill any running Unbound instance since it is not enabled. */
|
434
|
if (file_exists("{$g['varrun_path']}/unbound.pid")) {
|
435
|
sigkillbypid("{$g['varrun_path']}/unbound.pid", "TERM");
|
436
|
}
|
437
|
}
|
438
|
|
439
|
/* Call this separately since the above are manually set to skip the DHCP restart they normally perform.
|
440
|
* This avoids restarting dhcpd twice as described on ticket #3797
|
441
|
*/
|
442
|
services_dhcpd_configure();
|
443
|
|
444
|
local_sync_accounts();
|
445
|
|
446
|
return $xmlrpc_g['return']['true'];
|
447
|
}
|
448
|
|
449
|
/*****************************/
|
450
|
$carp_configure_doc = gettext("Basic XMLRPC wrapper for configuring CARP interfaces.");
|
451
|
$carp_configure_sig = array(
|
452
|
array(
|
453
|
$XML_RPC_Boolean,
|
454
|
$XML_RPC_String
|
455
|
)
|
456
|
);
|
457
|
|
458
|
function interfaces_carp_configure_xmlrpc($raw_params) {
|
459
|
global $xmlrpc_g;
|
460
|
|
461
|
if (xmlrpc_loop_detect()) {
|
462
|
log_error("Disallowing CARP sync loop");
|
463
|
return;
|
464
|
}
|
465
|
|
466
|
$params = xmlrpc_params_to_php($raw_params);
|
467
|
if (!xmlrpc_auth($params)) {
|
468
|
xmlrpc_authfail();
|
469
|
return $xmlrpc_g['return']['authfail'];
|
470
|
}
|
471
|
interfaces_vips_configure();
|
472
|
|
473
|
return $xmlrpc_g['return']['true'];
|
474
|
}
|
475
|
|
476
|
/*****************************/
|
477
|
$pfsense_firmware_version_doc = gettext("Basic XMLRPC wrapper for host_firmware_version. This function will return the output of host_firmware_version upon completion.");
|
478
|
|
479
|
$pfsense_firmware_version_sig = array (
|
480
|
array (
|
481
|
$XML_RPC_Struct,
|
482
|
$XML_RPC_String
|
483
|
)
|
484
|
);
|
485
|
|
486
|
function pfsense_firmware_version_xmlrpc($raw_params) {
|
487
|
global $xmlrpc_g;
|
488
|
|
489
|
$params = xmlrpc_params_to_php($raw_params);
|
490
|
if (!xmlrpc_auth($params)) {
|
491
|
xmlrpc_authfail();
|
492
|
return $xmlrpc_g['return']['authfail'];
|
493
|
}
|
494
|
return new XML_RPC_Response(XML_RPC_encode(host_firmware_version()));
|
495
|
}
|
496
|
|
497
|
/*****************************/
|
498
|
$reboot_doc = gettext("Basic XMLRPC wrapper for rc.reboot.");
|
499
|
$reboot_sig = array(array($XML_RPC_Boolean, $XML_RPC_String));
|
500
|
function reboot_xmlrpc($raw_params) {
|
501
|
global $xmlrpc_g;
|
502
|
|
503
|
$params = xmlrpc_params_to_php($raw_params);
|
504
|
if (!xmlrpc_auth($params)) {
|
505
|
xmlrpc_authfail();
|
506
|
return $xmlrpc_g['return']['authfail'];
|
507
|
}
|
508
|
mwexec_bg("/etc/rc.reboot");
|
509
|
|
510
|
return $xmlrpc_g['return']['true'];
|
511
|
}
|
512
|
|
513
|
/*****************************/
|
514
|
$get_notices_sig = array(
|
515
|
array(
|
516
|
$XML_RPC_Array,
|
517
|
$XML_RPC_String
|
518
|
),
|
519
|
array(
|
520
|
$XML_RPC_Array
|
521
|
)
|
522
|
);
|
523
|
|
524
|
function get_notices_xmlrpc($raw_params) {
|
525
|
global $g, $xmlrpc_g;
|
526
|
|
527
|
$params = xmlrpc_params_to_php($raw_params);
|
528
|
if (!xmlrpc_auth($params)) {
|
529
|
xmlrpc_authfail();
|
530
|
return $xmlrpc_g['return']['authfail'];
|
531
|
}
|
532
|
if (!function_exists("get_notices")) {
|
533
|
require_once("notices.inc");
|
534
|
}
|
535
|
if (!$params) {
|
536
|
$toreturn = get_notices();
|
537
|
} else {
|
538
|
$toreturn = get_notices($params);
|
539
|
}
|
540
|
$response = new XML_RPC_Response(XML_RPC_encode($toreturn));
|
541
|
|
542
|
return $response;
|
543
|
}
|
544
|
|
545
|
$xmlrpclockkey = lock('xmlrpc', LOCK_EX);
|
546
|
|
547
|
/*****************************/
|
548
|
$server = new XML_RPC_Server(
|
549
|
array(
|
550
|
'pfsense.exec_shell' => array('function' => 'exec_shell_xmlrpc',
|
551
|
'signature' => $exec_shell_sig,
|
552
|
'docstring' => $exec_shell_doc),
|
553
|
'pfsense.exec_php' => array('function' => 'exec_php_xmlrpc',
|
554
|
'signature' => $exec_php_sig,
|
555
|
'docstring' => $exec_php_doc),
|
556
|
'pfsense.filter_configure' => array('function' => 'filter_configure_xmlrpc',
|
557
|
'signature' => $filter_configure_sig,
|
558
|
'docstring' => $filter_configure_doc),
|
559
|
'pfsense.interfaces_carp_configure' => array('function' => 'interfaces_carp_configure_xmlrpc',
|
560
|
'signature' => $carp_configure_sig,
|
561
|
'docstring' => $carp_configure_doc),
|
562
|
'pfsense.backup_config_section' => array('function' => 'backup_config_section_xmlrpc',
|
563
|
'signature' => $backup_config_section_sig,
|
564
|
'docstring' => $backup_config_section_doc),
|
565
|
'pfsense.restore_config_section' => array('function' => 'restore_config_section_xmlrpc',
|
566
|
'signature' => $restore_config_section_sig,
|
567
|
'docstring' => $restore_config_section_doc),
|
568
|
'pfsense.merge_config_section' => array('function' => 'merge_config_section_xmlrpc',
|
569
|
'signature' => $merge_config_section_sig,
|
570
|
'docstring' => $merge_config_section_doc),
|
571
|
'pfsense.merge_installedpackages_section_xmlrpc' => array('function' => 'merge_installedpackages_section_xmlrpc',
|
572
|
'signature' => $merge_installedpackages_section_sig,
|
573
|
'docstring' => $merge_installedpackages_section_doc),
|
574
|
'pfsense.host_firmware_version' => array('function' => 'pfsense_firmware_version_xmlrpc',
|
575
|
'signature' => $pfsense_firmware_version_sig,
|
576
|
'docstring' => $pfsense_firmware_version_doc),
|
577
|
'pfsense.reboot' => array('function' => 'reboot_xmlrpc',
|
578
|
'signature' => $reboot_sig,
|
579
|
'docstring' => $reboot_doc),
|
580
|
'pfsense.get_notices' => array('function' => 'get_notices_xmlrpc',
|
581
|
'signature' => $get_notices_sig)
|
582
|
)
|
583
|
);
|
584
|
|
585
|
unlock($xmlrpclockkey);
|
586
|
|
587
|
function array_overlay($a1, $a2) {
|
588
|
foreach ($a1 as $k => $v) {
|
589
|
if (!array_key_exists($k, $a2)) {
|
590
|
continue;
|
591
|
}
|
592
|
if (is_array($v) && is_array($a2[$k])) {
|
593
|
$a1[$k] = array_overlay($v, $a2[$k]);
|
594
|
} else {
|
595
|
$a1[$k] = $a2[$k];
|
596
|
}
|
597
|
}
|
598
|
return $a1;
|
599
|
}
|
600
|
|
601
|
?>
|