Skip to content

Commit

Permalink
upnp: hardcode loading of miniupnpd.xml, hiding the
Browse files Browse the repository at this point in the history
possibility to invoke XML files completely.  Now the only thing is
the missing conversion of the UPnP Service into MVC.
  • Loading branch information
fichtner committed Jun 26, 2015
1 parent 3981b45 commit 43ae21e
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 79 deletions.
2 changes: 1 addition & 1 deletion src/opnsense/mvc/app/models/OPNsense/Base/Menu/Menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<PPPoEServer VisibleName="PPPoE Server" url="/services_vpn_pppoe.php"/>
<Proxy VisibleName="Proxy Server" url="/ui/proxy/"/>
<SNMP VisibleName="SNMP" url="/services_snmp.php"/>
<UPnP VisibleName="Universal Plug and Play" url="/pkg_edit.php?xml=miniupnpd.xml"/>
<UPnP VisibleName="Universal Plug and Play" url="/service_upnp.php"/>
<WoL VisibleName="Wake on LAN" url="/services_wol.php"/>
</Services>

Expand Down
62 changes: 10 additions & 52 deletions src/opnsense/mvc/app/models/OPNsense/Core/ACL_Legacy_Page_Map.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"user-copy-files": {
"name": "User - System - Copy files",
"descr": "Indicates whether the user is allowed to copy files onto the appliance via SCP\/SFTP. If you are going to use this privilege, you must install scponly on the appliance (Hint: pkg_add -r scponly)."
"descr": "Indicates whether the user is allowed to copy files onto the appliance via SCP\/SFTP."
},
"user-shell-access": {
"name": "User - System - Shell account access",
Expand Down Expand Up @@ -651,27 +651,6 @@
"index.php*"
]
},
"page-package-edit": {
"name": "WebCfg - Package: Edit page",
"descr": "Allow access to the 'Package: Edit' page.",
"match": [
"pkg_edit.php*"
]
},
"page-package-settings": {
"name": "WebCfg - Package: Settings page",
"descr": "Allow access to the 'Package: Settings' page.",
"match": [
"pkg.php*"
]
},
"page-pkg-mgr-settings": {
"name": "WebCfg - Packages: Settings page",
"descr": "Allow access to the 'Packages: Settings' page.",
"match": [
"pkg_mgr_settings.php*"
]
},
"page-pfsensewizardsubsystem": {
"name": "WebCfg - pfSense wizard subsystem page",
"descr": "Allow access to the 'pfSense wizard subsystem' page.",
Expand Down Expand Up @@ -1176,13 +1155,6 @@
"status_openvpn.php*"
]
},
"page-status-packagelogs": {
"name": "WebCfg - Status: Package logs page",
"descr": "Allow access to the 'Status: Package logs' page.",
"match": [
"diag_pkglogs.php*"
]
},
"page-status-rrdgraphs": {
"name": "WebCfg - Status: RRD Graphs page",
"descr": "Allow access to the 'Status: RRD Graphs' page.",
Expand Down Expand Up @@ -1271,9 +1243,16 @@
"ifstats.php*"
]
},
"page-service-upnp": {
"name": "WebCfg - Service: Univeral Plug and Play page",
"descr": "Allow access to the 'Service: Univeral Plug and Play' page.",
"match": [
"service_upnp.php*"
]
},
"page-status-upnpstatus": {
"name": "WebCfg - Status: UPnP Status page",
"descr": "Allow access to the 'Status: UPnP Status' page.",
"name": "WebCfg - Status: Univeral Plug and Play Status page",
"descr": "Allow access to the 'Status: Univeral Plug and Play Status' page.",
"match": [
"status_upnp.php*"
]
Expand Down Expand Up @@ -1447,27 +1426,6 @@
"license.php*"
]
},
"page-system-packagemanager": {
"name": "WebCfg - System: Package Manager page",
"descr": "Allow access to the 'System: Package Manager' page.",
"match": [
"pkg_mgr.php*"
]
},
"page-system-packagemanager-installpackage": {
"name": "WebCfg - System: Package Manager: Install Package page",
"descr": "Allow access to the 'System: Package Manager: Install Package' page.",
"match": [
"pkg_mgr_install.php*"
]
},
"page-system-packagemanager-installed": {
"name": "WebCfg - System: Package Manager: Installed page",
"descr": "Allow access to the 'System: Package Manager: Installed' page.",
"match": [
"pkg_mgr_installed.php*"
]
},
"page-system-staticroutes": {
"name": "WebCfg - System: Static Routes page",
"descr": "Allow access to the 'System: Static Routes' page.",
Expand Down
4 changes: 2 additions & 2 deletions src/pkg/miniupnpd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<savetext>Change</savetext>
<include_file>miniupnpd.inc</include_file>
<menu>
<name>UPnP &amp; NAT-PMP</name>
<name>Universal Plug and Play</name>
<tooltiptext>Set UPnP &amp; NAT-PMP settings such as interfaces to listen on.</tooltiptext>
<section>Services</section>
<url>/pkg_edit.php?xml=miniupnpd.xml&amp;id=0</url>
<url>/service_upnp&amp;id=0</url>
</menu>
<service>
<name>miniupnpd</name>
Expand Down
5 changes: 2 additions & 3 deletions src/www/fbegin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ if (empty($pagename)) {
$pagename = "index.php";
}

/* If the filename is pkg_edit.php or wizard.php, reparse looking
for the .xml filename */
if (($pagename == "pkg.php") || ($pagename == "pkg_edit.php") || ($pagename == "wizard.php")) {
/* If the filename is wizard.php, reparse looking for the .xml filename */
if ($pagename == 'wizard.php') {
$param_split = explode('&', $uri_split[2]);
foreach ($param_split as $param) {
if (substr($param, 0, 4) == "xml=") {
Expand Down
5 changes: 2 additions & 3 deletions src/www/help.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@
$pagename = "index.php";
}

/* If the filename is pkg_edit.php or wizard.php, reparse looking
for the .xml filename */
if (($pagename == "pkg.php") || ($pagename == "pkg_edit.php") || ($pagename == "wizard.php")) {
/* If the filename is wizard.php, reparse looking for the .xml filename */
if ($pagename == 'wizard.php') {
$param_split = explode('&', $uri_split[2]);
foreach ($param_split as $param) {
if (substr($param, 0, 4) == "xml=") {
Expand Down
26 changes: 9 additions & 17 deletions src/www/pkg_edit.php → src/www/service_upnp.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,14 @@ function domTT_title($title_msg){
}
}

$xml = htmlspecialchars($_GET['xml']);
if($_POST['xml']) $xml = htmlspecialchars($_POST['xml']);
/* hardcode miniupnpd.xml here, this file is going away */
$xml = 'miniupnpd.xml';

$xml_fullpath = realpath('/usr/local/pkg/' . $xml);

if ($xml == "" || $xml_fullpath === false ||
substr($xml_fullpath, 0, strlen('/usr/local/pkg/')) != '/usr/local/pkg/') {
print_info_box_np(gettext("ERROR: No valid package defined."));
die;
} else {
global $listtags ;
$listtags = array_flip(array('build_port_path', 'depends_on_package', 'onetoone', 'queue', 'rule', 'servernat', 'alias', 'additional_files_needed', 'tab', 'template', 'menu', 'rowhelperfield', 'service', 'step', 'package', 'columnitem', 'option', 'item', 'field', 'package', 'file'));
$pkg = parse_xml_config_raw($xml_fullpath, "packagegui", false);
}
global $listtags;
$listtags = array_flip(array('build_port_path', 'depends_on_package', 'onetoone', 'queue', 'rule', 'servernat', 'alias', 'additional_files_needed', 'tab', 'template', 'menu', 'rowhelperfield', 'service', 'step', 'package', 'columnitem', 'option', 'item', 'field', 'package', 'file'));
$pkg = parse_xml_config_raw($xml_fullpath, "packagegui", false);

if($pkg['include_file'] <> "") {
require_once($pkg['include_file']);
Expand Down Expand Up @@ -237,9 +231,9 @@ function domTT_title($title_msg){
if($pkg['aftersaveredirect'] <> "") {
redirectHeader($pkg['aftersaveredirect']);
} elseif(!$pkg['adddeleteeditpagefields']) {
redirectHeader("pkg_edit.php?xml={$xml}&amp;id=0");
redirectHeader("service_upnp.php?id=0");
} elseif(!$pkg['preoutput']) {
redirectHeader("pkg.php?xml=" . $xml);
redirectHeader("service_upnp.php");
}
exit;
} else {
Expand Down Expand Up @@ -386,9 +380,7 @@ function enablechange() {

<div class="content-box">

<form name="iform" action="pkg_edit.php" method="post">
<input type="hidden" name="xml" value="<?= htmlspecialchars($xml) ?>" />

<form name="iform" action="service_upnp.php" method="post">

<div class="table-responsive">
<table class="table table-striped table-sort">
Expand All @@ -409,7 +401,7 @@ function enablechange() {
$no_drop_down = true;
$urltmp = "";
if($tab['url'] <> "") $urltmp = $tab['url'];
if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
if($tab['xml'] <> "") $urltmp = "service_upnp.php";

$addresswithport = getenv("HTTP_HOST");
$colonpos = strpos($addresswithport, ":");
Expand Down
2 changes: 1 addition & 1 deletion src/www/shortcuts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function get_shortcut_log_link($shortcut_section, $addspace = true) {
}

$shortcuts['upnp'] = array();
$shortcuts['upnp']['main'] = "pkg_edit.php?xml=miniupnpd.xml";
$shortcuts['upnp']['main'] = "service_upnp.php";
$shortcuts['upnp']['log'] = "diag_logs_routing.php";
$shortcuts['upnp']['status'] = "status_upnp.php";
$shortcuts['upnp']['service'] = "miniupnpd";
Expand Down

0 comments on commit 43ae21e

Please sign in to comment.