Project

General

Profile

Download (14.7 KB) Statistics
| Branch: | Tag: | Revision:
1 50d49018 Colin Smith
<?php
2
/*
3 c5d81585 Renato Botelho
 * xmlrpc.php
4 191cb31d Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 b8f91b7c Luiz Souza
 * Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * Copyright (c) 2005 Colin Smith
8
 * All rights reserved.
9 191cb31d Stephen Beaver
 *
10 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
11
 * you may not use this file except in compliance with the License.
12
 * You may obtain a copy of the License at
13 191cb31d Stephen Beaver
 *
14 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
15 191cb31d Stephen Beaver
 *
16 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
17
 * distributed under the License is distributed on an "AS IS" BASIS,
18
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
 * See the License for the specific language governing permissions and
20
 * limitations under the License.
21 191cb31d Stephen Beaver
 */
22 50d49018 Colin Smith
23 6b07c15a Matthew Grooms
##|+PRIV
24
##|*IDENT=page-xmlrpclibrary
25 5230f468 jim-p
##|*NAME=XMLRPC Library
26 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'XMLRPC Library' page.
27
##|*MATCH=xmlrpc.php*
28
##|-PRIV
29
30 c81ef6e2 Phil Davis
require_once("config.inc");
31
require_once("functions.inc");
32 f81e7cc4 Renato Botelho
require_once("auth.inc");
33 f6339216 jim-p
require_once("filter.inc");
34 c81ef6e2 Phil Davis
require_once("ipsec.inc");
35
require_once("vpn.inc");
36
require_once("shaper.inc");
37 f81e7cc4 Renato Botelho
require_once("XML/RPC2/Server.php");
38 50d49018 Colin Smith
39 f81e7cc4 Renato Botelho
class pfsense_xmlrpc_server {
40 c87f4b70 Ermal
41 f81e7cc4 Renato Botelho
	private $loop_detected = false;
42
	private $remote_addr;
43 c87f4b70 Ermal
44 dc5f639f PiBa-NL
	private function auth() {
45 f81e7cc4 Renato Botelho
		global $config;
46 dc5f639f PiBa-NL
		$username = $_SERVER['PHP_AUTH_USER'];
47
		$password = $_SERVER['PHP_AUTH_PW'];
48 8da3de34 Colin Smith
49 fb1234ab Renato Botelho
		$login_ok = false;
50 f81e7cc4 Renato Botelho
		if (!empty($username) && !empty($password)) {
51
			$attributes = array();
52
			$authcfg = auth_get_authserver(
53
			    $config['system']['webgui']['authmode']);
54 c3638879 Scott Ullrich
55 f81e7cc4 Renato Botelho
			if (authenticate_user($username, $password,
56
			    $authcfg, $attributes) ||
57
			    authenticate_user($username, $password)) {
58 fb1234ab Renato Botelho
				$login_ok = true;
59 f81e7cc4 Renato Botelho
			}
60
		}
61 3dd2a278 Scott Ullrich
62 fb1234ab Renato Botelho
		if (!$login_ok) {
63
			log_auth("webConfigurator authentication error for '" .
64
			    $username . "' from " . $this->remote_addr);
65 137f46d8 Ermal
66 fb1234ab Renato Botelho
			require_once("XML/RPC2/Exception.php");
67
			throw new XML_RPC2_FaultException(gettext(
68
			    'Authentication failed: Invalid username or password'),
69
			    -1);
70
		}
71
72
		$user_entry = getUserEntry($username);
73
		/*
74
		 * admin (uid = 0) is allowed
75
		 * or regular user with necessary privilege
76
		 */
77
		if (isset($user_entry['uid']) && $user_entry['uid'] != '0' &&
78
		    !userHasPrivilege($user_entry, 'system-xmlrpc-ha-sync')) {
79
			log_auth("webConfigurator authentication error for '" .
80
			    $username . "' from " . $this->remote_addr .
81
			    " not enough privileges");
82
83
			require_once("XML/RPC2/Exception.php");
84
			throw new XML_RPC2_FaultException(gettext(
85
			    'Authentication failed: not enough privileges'),
86
			    -2);
87
		}
88
89
		return;
90 3dd2a278 Scott Ullrich
	}
91 f81e7cc4 Renato Botelho
92
	private function array_overlay($a1, $a2) {
93
		foreach ($a1 as $k => $v) {
94
			if (!array_key_exists($k, $a2)) {
95
				continue;
96
			}
97
			if (is_array($v) && is_array($a2[$k])) {
98
				$a1[$k] = $this->array_overlay($v, $a2[$k]);
99
			} else {
100
				$a1[$k] = $a2[$k];
101
			}
102
		}
103
104
		return $a1;
105 962f215d Phil Davis
	}
106 c3638879 Scott Ullrich
107 f81e7cc4 Renato Botelho
	public function __construct() {
108
		global $config;
109 c3638879 Scott Ullrich
110 f82f991c Renato Botelho
		$this->remote_addr = $_SERVER['REMOTE_ADDR'];
111 137f46d8 Ermal
112 f81e7cc4 Renato Botelho
		/* grab sync to ip if enabled */
113
		if (isset($config['hasync']['synchronizetoip']) &&
114 8d44b2cb PiBa-NL
		    $config['hasync']['synchronizetoip'] == $this->remote_addr) {
115 f81e7cc4 Renato Botelho
			$this->loop_detected = true;
116
		}
117 3dd2a278 Scott Ullrich
	}
118 137f46d8 Ermal
119 f81e7cc4 Renato Botelho
	/**
120
	 * Get host version information
121
	 *
122
	 * @return array
123
	 */
124 dc5f639f PiBa-NL
	public function host_firmware_version($dummy = 1) {
125
		$this->auth();
126 f81e7cc4 Renato Botelho
		return host_firmware_version();
127
	}
128 21dc3a7d Colin Smith
129 f81e7cc4 Renato Botelho
	/**
130
	 * Executes a PHP block of code
131
	 *
132
	 * @param string $code
133
	 *
134
	 * @return bool
135
	 */
136 dc5f639f PiBa-NL
	public function exec_php($code) {
137
		$this->auth();
138 137f46d8 Ermal
139 f81e7cc4 Renato Botelho
		eval($code);
140
		if ($toreturn) {
141
			return $toreturn;
142
		}
143 c87f4b70 Ermal
144 f81e7cc4 Renato Botelho
		return true;
145 3dd2a278 Scott Ullrich
	}
146 137f46d8 Ermal
147 f81e7cc4 Renato Botelho
	/**
148
	 * Executes shell commands
149
	 *
150
	 * @param string $code
151
	 *
152
	 * @return bool
153
	 */
154 dc5f639f PiBa-NL
	public function exec_shell($code) {
155
		$this->auth();
156 50d49018 Colin Smith
157 f81e7cc4 Renato Botelho
		mwexec($code);
158
		return true;
159
	}
160 21dc3a7d Colin Smith
161 f81e7cc4 Renato Botelho
	/**
162
	 * Backup chosen config sections
163
	 *
164
	 * @param array $section
165
	 *
166
	 * @return array
167
	 */
168 dc5f639f PiBa-NL
	public function backup_config_section($section) {
169
		$this->auth();
170 137f46d8 Ermal
171 f81e7cc4 Renato Botelho
		global $config;
172 d026178f Renato Botelho
173 f81e7cc4 Renato Botelho
		return array_intersect_key($config, array_flip($section));
174 fb0eb20b Ermal
	}
175 c87f4b70 Ermal
176 f81e7cc4 Renato Botelho
	/**
177
	 * Restore defined config section into local config
178
	 *
179
	 * @param array $sections
180
	 *
181
	 * @return bool
182
	 */
183 dc5f639f PiBa-NL
	public function restore_config_section($sections) {
184
		$this->auth();
185 f81e7cc4 Renato Botelho
186
		global $config;
187 1b99e1e5 jim-p
188 f81e7cc4 Renato Botelho
		$old_config = $config;
189
		$old_ipsec_enabled = ipsec_enabled();
190
191
		if ($this->loop_detected) {
192
			log_error("Disallowing CARP sync loop");
193
			return true;
194
		}
195
196
		/*
197
		 * Some sections should just be copied and not merged or we end
198
		 * up unable to sync the deletion of the last item in a section
199
		 */
200
		$sync_full_sections = array(
201
			'aliases',
202
			'ca',
203
			'cert',
204
			'crl',
205
			'dhcpd',
206
			'dhcpv6',
207
			'dnsmasq',
208
			'filter',
209
			'ipsec',
210
			'load_balancer',
211
			'nat',
212
			'openvpn',
213
			'schedules',
214
			'unbound',
215
			'wol',
216
		);
217
218
		$syncd_full_sections = array();
219
220
		foreach ($sync_full_sections as $section) {
221
			if (!isset($sections[$section])) {
222
				continue;
223
			}
224
225
			$config[$section] = $sections[$section];
226
			unset($sections[$section]);
227
			$syncd_full_sections[] = $section;
228 1b99e1e5 jim-p
		}
229
230 79f7bc7f Renato Botelho
		$g2add = array();
231
		$g2del = array();
232
		$g2del_idx = array();
233
		$g2keep = array();
234
		if (is_array($sections['system']['group'])) {
235
			$local_groups = isset($config['system']['group'])
236
			    ? $config['system']['group']
237
			    : array();
238
239
			foreach ($sections['system']['group'] as $group) {
240
				$idx = array_search($group['name'],
241
				    array_column($local_groups, 'name'));
242
243
				if ($idx === false) {
244
					$g2add[] = $group;
245
				} else if ($group['gid'] < 1999) {
246
					$g2keep[] = $idx;
247
				} else if ($group != $local_groups[$idx]) {
248
					$g2add[] = $group;
249
					$g2del[] = $group;
250
					$g2del_idx[] = $idx;
251
				} else {
252
					$g2keep[] = $idx;
253
				}
254
			}
255
		}
256
		if (is_array($config['system']['group'])) {
257
			foreach ($config['system']['group'] as $idx => $group) {
258
				if (array_search($idx, $g2keep) === false &&
259
				    array_search($idx, $g2del_idx) === false) {
260
					$g2del[] = $group;
261
					$g2del_idx[] = $idx;
262
				}
263
			}
264
		}
265
		unset($sections['system']['group'], $g2keep, $g2del_idx);
266
267
		$u2add = array();
268
		$u2del = array();
269
		$u2del_idx = array();
270
		$u2keep = array();
271
		if (is_array($sections['system']['user'])) {
272
			$local_users = isset($config['system']['user'])
273
			    ? $config['system']['user']
274
			    : array();
275
276
			foreach ($sections['system']['user'] as $user) {
277
				$idx = array_search($user['name'],
278
				    array_column($local_users, 'name'));
279
280
				if ($idx === false) {
281
					$u2add[] = $user;
282
				} else if ($user['uid'] < 2000) {
283
					$u2keep[] = $idx;
284
				} else if ($user != $local_users[$idx]) {
285
					$u2add[] = $user;
286
					$u2del[] = $user;
287
					$u2del_idx[] = $idx;
288
				} else {
289
					$u2keep[] = $idx;
290
				}
291
			}
292
		}
293
		if (is_array($config['system']['user'])) {
294
			foreach ($config['system']['user'] as $idx => $user) {
295
				if (array_search($idx, $u2keep) === false &&
296
				    array_search($idx, $u2del_idx) === false) {
297
					$u2del[] = $user;
298
					$u2del_idx[] = $idx;
299
				}
300
			}
301
		}
302
		unset($sections['system']['user'], $u2keep, $u2del_idx);
303
304 f81e7cc4 Renato Botelho
		$vipbackup = array();
305
		$oldvips = array();
306
		if (isset($sections['virtualip']) &&
307
		    is_array($config['virtualip']['vip'])) {
308
			foreach ($config['virtualip']['vip'] as $vip) {
309 c14781e3 Renato Botelho
				if ($vip['mode'] == "carp") {
310 f81e7cc4 Renato Botelho
					$key = $vip['interface'] .
311
					    "_vip" . $vip['vhid'];
312
313
					$oldvips[$key]['content'] =
314
					    $vip['password'] .
315
					    $vip['advskew'] .
316
					    $vip['subnet'] .
317
					    $vip['subnet_bits'] .
318
					    $vip['advbase'];
319
					$oldvips[$key]['interface'] =
320
					    $vip['interface'];
321
					$oldvips[$key]['subnet'] =
322
					    $vip['subnet'];
323
				} else if ($vip['mode'] == "ipalias" &&
324
				    (substr($vip['interface'], 0, 4) == '_vip'
325
				    || strstr($vip['interface'], "lo0"))) {
326
					$oldvips[$vip['subnet']]['content'] =
327
					    $vip['interface'] .
328
					    $vip['subnet'] .
329
					    $vip['subnet_bits'];
330
					$oldvips[$vip['subnet']]['interface'] =
331
					    $vip['interface'];
332
					$oldvips[$vip['subnet']]['subnet'] =
333
					    $vip['subnet'];
334
				} else if (($vip['mode'] == "ipalias" ||
335
				    $vip['mode'] == 'proxyarp') &&
336
				    !(substr($vip['interface'], 0, 4) == '_vip')
337
				    || strstr($vip['interface'], "lo0")) {
338 51611440 Ermal
					$vipbackup[] = $vip;
339 c14781e3 Renato Botelho
				}
340 51611440 Ermal
			}
341 19b5c3e7 Ermal
		}
342 f51d4f98 Ermal
343 f81e7cc4 Renato Botelho
		/* For vip section, first keep items sent from the master */
344
		$config = array_merge_recursive_unique($config, $sections);
345 51611440 Ermal
346 f81e7cc4 Renato Botelho
		/*
347
		 * Then add ipalias and proxyarp types already defined
348
		 * on the backup
349
		 */
350
		if (is_array($vipbackup) && !empty($vipbackup)) {
351
			if (!is_array($config['virtualip'])) {
352
				$config['virtualip'] = array();
353
			}
354
			if (!is_array($config['virtualip']['vip'])) {
355
				$config['virtualip']['vip'] = array();
356
			}
357
			foreach ($vipbackup as $vip) {
358
				array_unshift($config['virtualip']['vip'], $vip);
359
			}
360 962f215d Phil Davis
		}
361 51611440 Ermal
362 f81e7cc4 Renato Botelho
		/* Log what happened */
363 8cb29dac doktornotor
		$mergedkeys = implode(", ", array_merge(array_keys($sections),
364 f81e7cc4 Renato Botelho
		    $syncd_full_sections));
365
		write_config(sprintf(gettext(
366
		    "Merged in config (%s sections) from XMLRPC client."),
367
		    $mergedkeys));
368
369
		/*
370
		 * The real work on handling the vips specially
371
		 * This is a copy of intefaces_vips_configure with addition of
372
		 * not reloading existing/not changed carps
373
		 */
374
		if (isset($sections['virtualip']) &&
375
		    is_array($config['virtualip']) &&
376
		    is_array($config['virtualip']['vip'])) {
377
			$carp_setuped = false;
378
			$anyproxyarp = false;
379
380
			foreach ($config['virtualip']['vip'] as $vip) {
381
				$key = "{$vip['interface']}_vip{$vip['vhid']}";
382
383
				if ($vip['mode'] == "carp" &&
384
				    isset($oldvips[$key])) {
385
					if ($oldvips[$key]['content'] ==
386
					    $vip['password'] .
387
					    $vip['advskew'] .
388
					    $vip['subnet'] .
389
					    $vip['subnet_bits'] .
390
					    $vip['advbase'] &&
391
					    does_vip_exist($vip)) {
392
						unset($oldvips[$key]);
393
						/*
394
						 * Skip reconfiguring this vips
395
						 * since nothing has changed.
396
						 */
397
						continue;
398 19ed1624 Ermal
					}
399 5fda51cd jim-p
400 f81e7cc4 Renato Botelho
				} elseif ($vip['mode'] == "ipalias" &&
401 5fda51cd jim-p
				    (substr($vip['interface'], 0, 4) == '_vip'
402
				    || strstr($vip['interface'], "lo0")) &&
403 f81e7cc4 Renato Botelho
				    isset($oldvips[$vip['subnet']])) {
404
					$key = $vip['subnet'];
405
					if ($oldvips[$key]['content'] ==
406
					    $vip['interface'] .
407
					    $vip['subnet'] .
408
					    $vip['subnet_bits'] &&
409
					    does_vip_exist($vip)) {
410
						unset($oldvips[$key]);
411
						/*
412
						 * Skip reconfiguring this vips
413
						 * since nothing has changed.
414
						 */
415
						continue;
416 2708a5cf Ermal
					}
417 f81e7cc4 Renato Botelho
					unset($oldvips[$key]);
418 2708a5cf Ermal
				}
419 51611440 Ermal
420 f81e7cc4 Renato Botelho
				switch ($vip['mode']) {
421 962f215d Phil Davis
				case "proxyarp":
422
					$anyproxyarp = true;
423
					break;
424
				case "ipalias":
425
					interface_ipalias_configure($vip);
426
					break;
427
				case "carp":
428 f81e7cc4 Renato Botelho
					$carp_setuped = true;
429 962f215d Phil Davis
					interface_carp_configure($vip);
430
					break;
431 f81e7cc4 Renato Botelho
				}
432 51611440 Ermal
			}
433 f81e7cc4 Renato Botelho
434
			/* Cleanup remaining old carps */
435
			foreach ($oldvips as $oldvipar) {
436
				$oldvipif = get_real_interface(
437
				    $oldvipar['interface']);
438
439
				if (empty($oldvipif)) {
440
					continue;
441
				}
442
443 962f215d Phil Davis
				if (is_ipaddrv6($oldvipar['subnet'])) {
444 f81e7cc4 Renato Botelho
					 mwexec("/sbin/ifconfig " .
445
					     escapeshellarg($oldvipif) .
446
					     " inet6 " .
447
					     escapeshellarg($oldvipar['subnet']) .
448
					     " delete");
449 962f215d Phil Davis
				} else {
450 f81e7cc4 Renato Botelho
					pfSense_interface_deladdress($oldvipif,
451
					    $oldvipar['subnet']);
452 962f215d Phil Davis
				}
453 e3cffd6c Ermal LUÇI
			}
454 f81e7cc4 Renato Botelho
			if ($carp_setuped == true) {
455
				interfaces_sync_setup();
456
			}
457
			if ($anyproxyarp == true) {
458
				interface_proxyarp_configure();
459
			}
460 51611440 Ermal
		}
461 f81e7cc4 Renato Botelho
462
		if ($old_ipsec_enabled !== ipsec_enabled()) {
463
			vpn_ipsec_configure();
464 962f215d Phil Davis
		}
465 137f46d8 Ermal
466 f81e7cc4 Renato Botelho
		unset($old_config);
467
468 79f7bc7f Renato Botelho
		local_sync_accounts($u2add, $u2del, $g2add, $g2del);
469
		filter_configure(false);
470
471 f81e7cc4 Renato Botelho
		return true;
472 962f215d Phil Davis
	}
473 d026178f Renato Botelho
474 f81e7cc4 Renato Botelho
	/**
475
	 * Merge items into installedpackages config section
476
	 *
477
	 * @param array $section
478
	 *
479
	 * @return bool
480
	 */
481 dc5f639f PiBa-NL
	public function merge_installedpackages_section($section) {
482
		$this->auth();
483 d026178f Renato Botelho
484 f81e7cc4 Renato Botelho
		global $config;
485 50d49018 Colin Smith
486 f81e7cc4 Renato Botelho
		if ($this->loop_detected) {
487
			log_error("Disallowing CARP sync loop");
488
			return true;
489
		}
490 82ae5cfc Scott Ullrich
491 f81e7cc4 Renato Botelho
		$config['installedpackages'] = array_merge(
492
		    $config['installedpackages'], $section);
493 8cb29dac doktornotor
		$mergedkeys = implode(", ", array_keys($section));
494 f81e7cc4 Renato Botelho
		write_config(sprintf(gettext(
495
		    "Merged in config (%s sections) from XMLRPC client."),
496
		    $mergedkeys));
497 137f46d8 Ermal
498 f81e7cc4 Renato Botelho
		return true;
499 fb0eb20b Ermal
	}
500 c87f4b70 Ermal
501 f81e7cc4 Renato Botelho
	/**
502
	 * Merge items into config
503
	 *
504
	 * @param array $section
505
	 *
506
	 * @return bool
507
	 */
508 dc5f639f PiBa-NL
	public function merge_config_section($section) {
509
		$this->auth();
510 137f46d8 Ermal
511 f81e7cc4 Renato Botelho
		global $config;
512 82ae5cfc Scott Ullrich
513 f81e7cc4 Renato Botelho
		if ($this->loop_detected) {
514
			log_error("Disallowing CARP sync loop");
515
			return true;
516
		}
517 dc1cd85d Scott Ullrich
518 f81e7cc4 Renato Botelho
		$config_new = $this->array_overlay($config, $section);
519
		$config = $config_new;
520 8cb29dac doktornotor
		$mergedkeys = implode(", ", array_keys($section));
521 f81e7cc4 Renato Botelho
		write_config(sprintf(gettext(
522
		    "Merged in config (%s sections) from XMLRPC client."),
523
		    $mergedkeys));
524 c87f4b70 Ermal
525 f81e7cc4 Renato Botelho
		return true;
526 fb0eb20b Ermal
	}
527 c87f4b70 Ermal
528 f81e7cc4 Renato Botelho
	/**
529
	 * Wrapper for filter_configure()
530
	 *
531
	 * @return bool
532 57b5da70 jim-p
	 */
533 79f7bc7f Renato Botelho
	public function filter_configure($reset_accounts = true) {
534 dc5f639f PiBa-NL
		$this->auth();
535 f81e7cc4 Renato Botelho
536
		global $g, $config;
537
538
		filter_configure();
539
		system_routing_configure();
540
		setup_gateways_monitor();
541
		relayd_configure();
542
		require_once("openvpn.inc");
543
		openvpn_resync_all();
544
545
		/*
546
		 * The DNS Resolver and the DNS Forwarder may both be active so
547
		 * long as * they are running on different ports.
548
		 * See ticket #5882
549
		 */
550
		if (isset($config['dnsmasq']['enable'])) {
551
			/* Configure dnsmasq but tell it NOT to restart DHCP */
552
			services_dnsmasq_configure(false);
553
		} else {
554
			/* kill any running dnsmasq instance */
555
			if (isvalidpid("{$g['varrun_path']}/dnsmasq.pid")) {
556
				sigkillbypid("{$g['varrun_path']}/dnsmasq.pid",
557
				    "TERM");
558
			}
559 57b5da70 jim-p
		}
560 f81e7cc4 Renato Botelho
		if (isset($config['unbound']['enable'])) {
561
			/* Configure unbound but tell it NOT to restart DHCP */
562
			services_unbound_configure(false);
563
		} else {
564
			/* kill any running Unbound instance */
565
			if (isvalidpid("{$g['varrun_path']}/unbound.pid")) {
566
				sigkillbypid("{$g['varrun_path']}/unbound.pid",
567
				    "TERM");
568
			}
569 57b5da70 jim-p
		}
570 137f46d8 Ermal
571 f81e7cc4 Renato Botelho
		/*
572
		 * Call this separately since the above are manually set to
573
		 * skip the DHCP restart they normally perform.
574
		 * This avoids restarting dhcpd twice as described on
575
		 * ticket #3797
576
		 */
577
		services_dhcpd_configure();
578 137f46d8 Ermal
579 79f7bc7f Renato Botelho
		if ($reset_accounts) {
580
			local_reset_accounts();
581
		}
582 c87f4b70 Ermal
583 f81e7cc4 Renato Botelho
		return true;
584 3dd2a278 Scott Ullrich
	}
585 137f46d8 Ermal
586 f81e7cc4 Renato Botelho
	/**
587
	 * Wrapper for configuring CARP interfaces
588
	 *
589
	 * @return bool
590
	 */
591 dc5f639f PiBa-NL
	public function interfaces_carp_configure() {
592
		$this->auth();
593 efe7562e Scott Ullrich
594 f81e7cc4 Renato Botelho
		if ($this->loop_detected) {
595
			log_error("Disallowing CARP sync loop");
596
			return true;
597
		}
598 0567899d Ermal
599 f81e7cc4 Renato Botelho
		interfaces_vips_configure();
600 e501de37 Ermal
601 f81e7cc4 Renato Botelho
		return true;
602
	}
603 e501de37 Ermal
604 f81e7cc4 Renato Botelho
	/**
605
	 * Wrapper for rc.reboot
606
	 *
607
	 * @return bool
608
	 */
609 dc5f639f PiBa-NL
	public function reboot() {
610
		$this->auth();
611 e501de37 Ermal
612 f81e7cc4 Renato Botelho
		mwexec_bg("/etc/rc.reboot");
613 137f46d8 Ermal
614 f81e7cc4 Renato Botelho
		return true;
615 3dd2a278 Scott Ullrich
	}
616 d9064267 Colin Smith
}
617
618 8239af2d PiBa-NL
// run script untill its done and can 'unlock' the xmlrpc.lock, this prevents hanging php-fpm / webgui 
619
ignore_user_abort(true); 
620
set_time_limit(0);
621
622 67d78c87 Ermal
$xmlrpclockkey = lock('xmlrpc', LOCK_EX);
623
624 f81e7cc4 Renato Botelho
XML_RPC2_Backend::setBackend('php');
625
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
626
627
$options = array(
628
	'prefix' => 'pfsense.',
629
	'encoding' => 'utf-8',
630 4f78ae1d Renato Botelho
	'autoDocument' => false,
631 50d49018 Colin Smith
);
632 b298dd06 Scott Ullrich
633 f81e7cc4 Renato Botelho
$server = XML_RPC2_Server::create(new pfsense_xmlrpc_server(), $options);
634
$server->handleCall();
635 67d78c87 Ermal
636 f81e7cc4 Renato Botelho
unlock($xmlrpclockkey);
637 0b581a8a Scott Ullrich
638 de63649b Rafael Lucas
?>