Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
8b61365f
Commit
8b61365f
authored
Nov 22, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firmware: show license in packages/plugins; closes #1220
parent
c3e84685
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
6 deletions
+114
-6
plist
plist
+1
-0
FirmwareController.php
.../app/controllers/OPNsense/Core/Api/FirmwareController.php
+29
-1
firmware.volt
src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt
+39
-3
license.sh
src/opnsense/scripts/firmware/license.sh
+37
-0
actions_firmware.conf
src/opnsense/service/conf/actions.d/actions_firmware.conf
+8
-2
No files found.
plist
View file @
8b61365f
...
...
@@ -556,6 +556,7 @@
/usr/local/opnsense/scripts/firmware/hotfix.sh
/usr/local/opnsense/scripts/firmware/install.sh
/usr/local/opnsense/scripts/firmware/launcher.sh
/usr/local/opnsense/scripts/firmware/license.sh
/usr/local/opnsense/scripts/firmware/lock.sh
/usr/local/opnsense/scripts/firmware/reinstall.sh
/usr/local/opnsense/scripts/firmware/remove.sh
...
...
src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php
View file @
8b61365f
...
...
@@ -183,6 +183,34 @@ class FirmwareController extends ApiControllerBase
return
$response
;
}
/**
* Retrieve specific license for package in text format
* @param string $package package to retrieve
* @return array with all possible licenses
* @throws \Exception
*/
public
function
licenseAction
(
$package
)
{
$this
->
sessionClose
();
// long running action, close session
$backend
=
new
Backend
();
$response
=
array
();
if
(
$this
->
request
->
isPost
())
{
// sanitize package name
$filter
=
new
\Phalcon\Filter
();
$filter
->
add
(
'scrub'
,
function
(
$value
)
{
return
preg_replace
(
'/[^0-9a-zA-Z]/'
,
''
,
$value
);
});
$package
=
$filter
->
sanitize
(
$package
,
'scrub'
);
$text
=
trim
(
$backend
->
configdRun
(
sprintf
(
'firmware license %s'
,
$package
)));
if
(
!
empty
(
$text
))
{
$response
[
'license'
]
=
$text
;
}
}
return
$response
;
}
/**
* perform reboot
* @return array status
...
...
@@ -428,7 +456,7 @@ class FirmwareController extends ApiControllerBase
{
$this
->
sessionClose
();
// long running action, close session
$keys
=
array
(
'name'
,
'version'
,
'comment'
,
'flatsize'
,
'locked'
);
$keys
=
array
(
'name'
,
'version'
,
'comment'
,
'flatsize'
,
'locked'
,
'license'
);
$backend
=
new
Backend
();
$response
=
array
();
...
...
src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt
View file @
8b61365f
...
...
@@ -115,6 +115,30 @@ POSSIBILITY OF SUCH DAMAGE.
});
}
/**
* read license from backend
*/
function license(package)
{
ajaxCall('/api/core/firmware/license/' + package, {}, function (data, status) {
var license = "{{ lang._('Sorry, the package does not have an associated license file.') }}";
if (data['license'] != undefined) {
license = data['license'];
}
BootstrapDialog.show({
type:BootstrapDialog.TYPE_INFO,
title: "{{ lang._('License details') }}",
message: license,
buttons: [{
label: "{{ lang._('Close') }}",
action: function(dialogRef){
dialogRef.close();
}
}]
});
});
}
/**
* read changelog from backend
*/
...
...
@@ -246,10 +270,10 @@ POSSIBILITY OF SUCH DAMAGE.
$("#packageslist").html("<tr><th>{{ lang._('Name') }}</th>" +
"<th>{{ lang._('Version') }}</th><th>{{ lang._('Size') }}</th>" +
"<th>{{ lang._('Comment') }}</th><th></th></tr>");
"<th>{{ lang._('
License') }}</th><th>{{ lang._('
Comment') }}</th><th></th></tr>");
$("#pluginlist").html("<tr><th>{{ lang._('Name') }}</th>" +
"<th>{{ lang._('Version') }}</th><th>{{ lang._('Size') }}</th>" +
"<th>{{ lang._('Comment') }}</th><th></th></tr>");
"<th>{{ lang._('
License') }}</th><th>{{ lang._('
Comment') }}</th><th></th></tr>");
var local_count = 0;
var remote_count = 0;
...
...
@@ -268,8 +292,12 @@ POSSIBILITY OF SUCH DAMAGE.
'<td>' + row['name'] + '</td>' +
'<td>' + row['version'] + '</td>' +
'<td>' + row['flatsize'] + '</td>' +
'<td>' + row['license'] + '</td>' +
'<td>' + row['comment'] + '</td>' +
'<td>' +
'<button class="btn btn-default btn-xs act_license" data-package="' + row['name'] + '" ' +
' data-toggle="tooltip" title="View ' + row['name'] + ' license">' +
'<span class="fa fa-balance-scale"></span></button> ' +
'<button class="btn btn-default btn-xs act_reinstall" data-package="' + row['name'] + '" ' +
' data-toggle="tooltip" title="Reinstall ' + row['name'] + '">' +
'<span class="fa fa-recycle"></span></button> ' + (row['locked'] === '1' ?
...
...
@@ -299,8 +327,12 @@ POSSIBILITY OF SUCH DAMAGE.
'<tr>' + '<td>' + row['name'] + orphaned_text + '</td>' +
'<td>' + row['version'] + '</td>' +
'<td>' + row['flatsize'] + '</td>' +
'<td>' + row['license'] + '</td>' +
'<td>' + row['comment'] + '</td>' +
'<td>' + (row['installed'] == "1" ?
'<td><button class="btn btn-default btn-xs act_license" data-package="' + row['name'] + '" ' +
' data-toggle="tooltip" title="View ' + row['name'] + ' license">' +
'<span class="fa fa-balance-scale"></span></button> ' +
(row['installed'] == "1" ?
'<button class="btn btn-default btn-xs act_remove" data-package="' + row['name'] + '" '+
' data-toggle="tooltip" title="Remove ' + row['name'] + '">' +
'<span class="fa fa-trash">' +
...
...
@@ -373,6 +405,10 @@ POSSIBILITY OF SUCH DAMAGE.
event.preventDefault();
changelog($(this).data('version'));
});
$(".act_license").click(function(event) {
event.preventDefault();
license($(this).data('package'));
});
// attach tooltip to generated buttons
$('[data-toggle="tooltip"]').tooltip();
});
...
...
src/opnsense/scripts/firmware/license.sh
0 → 100755
View file @
8b61365f
#!/bin/sh
# Copyright (c) 2016 Franco Fichtner <franco@opnsense.org>
#
# 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 BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
LICENSEDIR
=
"/usr/local/share/licenses"
PACKAGE
=
${
1
}
LICENSES
=
$(
pkg query %L
${
PACKAGE
}
)
VERSION
=
$(
pkg query %v
${
PACKAGE
}
)
if
[
-f
"
${
LICENSEDIR
}
/
${
PACKAGE
}
-
${
VERSION
}
/
${
LICENSES
}
"
]
;
then
cat
"
${
LICENSEDIR
}
/
${
PACKAGE
}
-
${
VERSION
}
/
${
LICENSES
}
"
fi
src/opnsense/service/conf/actions.d/actions_firmware.conf
View file @
8b61365f
...
...
@@ -29,6 +29,12 @@ parameters:%s
type
:
script_output
message
:
Viewing
changelog
for
version
%
s
[
license
]
command
:/
usr
/
local
/
opnsense
/
scripts
/
firmware
/
license
.
sh
parameters
:%
s
type
:
script_output
message
:
Viewing
license
for
%
s
[
running
]
command
:/
usr
/
local
/
opnsense
/
scripts
/
firmware
/
running
.
sh
parameters
:
...
...
@@ -84,13 +90,13 @@ type:script_output
message
:
retrieve
upgrade
progress
status
[
local
]
command
:
pkg
query
"%n|||%v|||%c|||%sh|||%k"
command
:
pkg
query
"%n|||%v|||%c|||%sh|||%k
|||%L
"
parameters
:
type
:
script_output
message
:
view
local
packages
[
remote
]
command
:
pkg
rquery
"%n|||%v|||%c|||%sh|||0"
command
:
pkg
rquery
"%n|||%v|||%c|||%sh|||0
|||%L
"
parameters
:
type
:
script_output
message
:
view
remote
packages
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment