mirror of
https://github.com/opnsense/core.git
synced 2026-10-12 02:20:36 +00:00
interfaces: priv-sep script for interface apply the legacy way #9352
This commit is contained in:
@@ -1304,6 +1304,7 @@
|
||||
/usr/local/opnsense/scripts/health/library/OPNsense/RRD/Types/Wireless.php
|
||||
/usr/local/opnsense/scripts/health/listReports.py
|
||||
/usr/local/opnsense/scripts/health/updaterrd.php
|
||||
/usr/local/opnsense/scripts/interfaces/apply_legacy_if_changes.php
|
||||
/usr/local/opnsense/scripts/interfaces/apply_pending_if_changes.php
|
||||
/usr/local/opnsense/scripts/interfaces/capture.py
|
||||
/usr/local/opnsense/scripts/interfaces/carp_global_status.php
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/usr/local/bin/php
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2026 Deciso B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require_once("interfaces.inc");
|
||||
require_once("system.inc");
|
||||
require_once("config.inc");
|
||||
require_once("util.inc");
|
||||
|
||||
$interfaces_apply = '/var/lib/php/tmp/.interfaces.apply';
|
||||
|
||||
if (!file_exists($interfaces_apply)) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$toapplylist = unserialize(file_get_contents($interfaces_apply), ['allowed_classes' => false]);
|
||||
|
||||
foreach ($toapplylist as $ifapply => $ifcfgo) {
|
||||
interface_reset($ifapply, $ifcfgo, isset($ifcfgo['enable']));
|
||||
interface_configure(true, $ifapply, true);
|
||||
}
|
||||
|
||||
configd_run('filter reload');
|
||||
configd_run('webgui restart 3', true);
|
||||
|
||||
clear_subsystem_dirty('interfaces');
|
||||
@unlink($interfaces_apply);
|
||||
|
||||
exit(0);
|
||||
@@ -11,6 +11,12 @@ parameters:
|
||||
type:script
|
||||
message:Apply pending interface changes
|
||||
|
||||
[legacy.apply]
|
||||
command:/usr/local/opnsense/scripts/interfaces/apply_legacy_if_changes.php
|
||||
parameters:
|
||||
type:script
|
||||
message:Apply legacy interface changes
|
||||
|
||||
[address]
|
||||
command:/usr/local/sbin/pluginctl -46
|
||||
parameters:%s
|
||||
|
||||
+1
-13
@@ -323,19 +323,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
if (!is_subsystem_dirty('interfaces')) {
|
||||
$intput_errors[] = gettext("You have already applied your settings!");
|
||||
} else {
|
||||
if (file_exists('/var/lib/php/tmp/.interfaces.apply')) {
|
||||
$toapplylist = unserialize(file_get_contents('/var/lib/php/tmp/.interfaces.apply'), ['allowed_classes' => false]);
|
||||
foreach ($toapplylist as $ifapply => $ifcfgo) {
|
||||
interface_reset($ifapply, $ifcfgo, isset($ifcfgo['enable']));
|
||||
interface_configure(false, $ifapply, true);
|
||||
}
|
||||
|
||||
configd_run('filter reload');
|
||||
configd_run('webgui restart 3', true);
|
||||
}
|
||||
|
||||
clear_subsystem_dirty('interfaces');
|
||||
@unlink('/var/lib/php/tmp/.interfaces.apply');
|
||||
configd_run('interface legacy apply');
|
||||
}
|
||||
if (!empty($ifgroup)) {
|
||||
header(url_safe('Location: /interfaces.php?if=%s&group=%s', array($if, $ifgroup)));
|
||||
|
||||
Reference in New Issue
Block a user