net/radsecproxy: cleanup service control. os-radsecproxy wasn't used, so we're removing it and hook the required settings in rc.conf.d. To make the grids a bit more usable, make sure to wrap a container arount it. Final change is to hook syslog properly and add a menu item for it. (#3628)

This commit is contained in:
Ad Schellevis
2023-10-23 17:02:45 +02:00
committed by GitHub
parent 3d4c6735ad
commit 26d96b96c7
14 changed files with 166 additions and 213 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
PLUGIN_NAME= radsecproxy
PLUGIN_VERSION= 1.0
PLUGIN_REVISION= 1
PLUGIN_REVISION= 2
PLUGIN_COMMENT= RADIUS proxy provides both RADIUS UDP and TCP/TLS (RadSec) transport
PLUGIN_DEPENDS= radsecproxy
PLUGIN_MAINTAINER= tobias@boehnert.dev
@@ -1,6 +1,7 @@
<?php
/*
* Copyright (C) 2023 Deciso B.V.
* Copyright (C) 2020 Tobias Boehnert
* All rights reserved.
*
@@ -27,39 +28,34 @@
function radsecproxy_enabled()
{
$model = new \OPNsense\RadSecProxy\RadSecProxy();
if ((string)$model->general->enabled == '1') {
return true;
}
return false;
return (string)(new \OPNsense\RadSecProxy\RadSecProxy())->general->enabled == '1';
}
function radsecproxy_syslog()
{
$logfacilities = array();
$logfacilities['radsecproxy'] = array(
'facility' => array('LOG_DAEMON'),
);
return $logfacilities;
return [
'radsecproxy' => [
'facility' => ['radsecproxy']
]
];
}
function radsecproxy_services()
{
$services = array();
$services = [];
if (radsecproxy_enabled()) {
$services[] = array(
$services[] = [
'description' => gettext('Radius Secure Proxy'),
'configd' => array(
'restart' => array('radsecproxy restart'),
'start' => array('radsecproxy start'),
'stop' => array('radsecproxy stop'),
),
'configd' => [
'restart' => ['radsecproxy restart'],
'start' => ['radsecproxy start'],
'stop' => ['radsecproxy stop'],
],
'name' => 'radsecproxy',
'pidfile' => '/var/run/radsecproxy.pid'
);
'pidfile' => '/var/run/radsecproxy/radsecproxy.pid'
];
}
return $services;
}
@@ -1,46 +0,0 @@
#!/bin/sh
# PROVIDE: radsecproxy
# REQUIRE: LOGIN
# KEYWORD: shutdown
# Add the following line to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# radsecproxy_enable (bool): Set to NO by default.
# Set it to YES to enable radsecproxy.
. /etc/rc.subr
name="radsecproxy"
rcvar=radsecproxy_enable
: ${radsecproxy_enable:="NO"}
: ${radsecproxy_user:="root"}
: ${radsecproxy_group:="wheel"}
: ${radsecproxy_pidfile:="/var/run/radsecproxy.pid"}
user=${radsecproxy_user}
group=${radsecproxy_group}
pidfile=${radsecproxy_pidfile}
required_files=/usr/local/etc/radsecproxy.conf
command="/usr/local/sbin/${name}"
command_args="-c /usr/local/etc/radsecproxy.conf -i ${pidfile}"
start_precmd="radsecproxy_prestart"
stop_postcmd="radsecproxy_poststop"
radsecproxy_prestart()
{
mkdir -p $(dirname $pidfile)
chown ${user}:${group} $(dirname $pidfile)
}
radsecproxy_poststop()
{
rm -f ${pidfile}
}
load_rc_config $name
run_rc_command "$1"
@@ -7,6 +7,7 @@
<Realms VisibleName="Realms" order="40" url="/ui/radsecproxy/realms" />
<Tls VisibleName="TLS" order="50" url="/ui/radsecproxy/tls" />
<Rewrites VisibleName="Rewrite-Rules" order="60" url="/ui/radsecproxy/rewrites" />
<Log order="100" VisibleName="Log File" url="/ui/diagnostics/log/core/radsecproxy" />
</RadSecProxy>
</Services>
</menu>
@@ -24,33 +24,35 @@
});
</script>
<table id="grid-addresses" class="table table-condensed table-hover table-striped" data-editDialog="DialogClient">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
<th data-column-id="type" data-type="string">{{ lang._('Type') }}</th>
<th data-column-id="host" data-type="string">{{ lang._('Host') }}</th>
<th data-column-id="identifier" data-type="string">{{ lang._('Identifier') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td>
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
<button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
<div class="tab-content content-box">
<table id="grid-addresses" class="table table-condensed table-hover table-striped" data-editDialog="DialogClient">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
<th data-column-id="type" data-type="string">{{ lang._('Type') }}</th>
<th data-column-id="host" data-type="string">{{ lang._('Host') }}</th>
<th data-column-id="identifier" data-type="string">{{ lang._('Identifier') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td>
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
<button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Apply') }}</b> <i id="saveAct_progress"></i></button>
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Apply') }}</b> <i id="saveAct_progress"></i></button>
</div>
</div>
{{ partial("layout_partials/base_dialog",['fields':formDialogClient,'id':'DialogClient','label':lang._('Edit client')])}}
@@ -23,32 +23,32 @@
});
});
</script>
<div class="tab-content content-box">
<table id="grid-addresses" class="table table-condensed table-hover table-striped" data-editDialog="DialogRealm">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
<th data-column-id="realm" data-type="string">{{ lang._('Realm') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td>
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
<button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
<table id="grid-addresses" class="table table-condensed table-hover table-striped" data-editDialog="DialogRealm">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
<th data-column-id="realm" data-type="string">{{ lang._('Realm') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td>
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
<button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Apply') }}</b> <i id="saveAct_progress"></i></button>
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Apply') }}</b> <i id="saveAct_progress"></i></button>
</div>
</div>
{{ partial("layout_partials/base_dialog",['fields':formDialogRealm,'id':'DialogRealm','label':lang._('Edit realm')])}}
@@ -24,31 +24,33 @@
});
</script>
<table id="grid-addresses" class="table table-condensed table-hover table-striped" data-editDialog="DialogRewrite">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
<th data-column-id="name" data-type="string">{{ lang._('Type') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td>
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
<button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
<div class="tab-content content-box">
<table id="grid-addresses" class="table table-condensed table-hover table-striped" data-editDialog="DialogRewrite">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
<th data-column-id="name" data-type="string">{{ lang._('Type') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td>
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
<button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Apply') }}</b> <i id="saveAct_progress"></i></button>
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Apply') }}</b> <i id="saveAct_progress"></i></button>
</div>
</div>
{{ partial("layout_partials/base_dialog",['fields':formDialogRewrite,'id':'DialogRewrite','label':lang._('Edit rewrite-rule')])}}
@@ -24,33 +24,34 @@
});
</script>
<table id="grid-addresses" class="table table-condensed table-hover table-striped" data-editDialog="DialogServer">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="host" data-type="string">{{ lang._('Host') }}</th>
<th data-column-id="identifier" data-type="string">{{ lang._('Identifier') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="type" data-type="string">{{ lang._('Type') }}</th>
<th data-column-id="tlsConfig" data-type="string">{{ lang._('TLS-Config') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td>
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
<button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
<div class="tab-content content-box">
<table id="grid-addresses" class="table table-condensed table-hover table-striped" data-editDialog="DialogServer">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="host" data-type="string">{{ lang._('Host') }}</th>
<th data-column-id="identifier" data-type="string">{{ lang._('Identifier') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="type" data-type="string">{{ lang._('Type') }}</th>
<th data-column-id="tlsConfig" data-type="string">{{ lang._('TLS-Config') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td>
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
<button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Apply') }}</b> <i id="saveAct_progress"></i></button>
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Apply') }}</b> <i id="saveAct_progress"></i></button>
</div>
</div>
{{ partial("layout_partials/base_dialog",['fields':formDialogServer,'id':'DialogServer','label':lang._('Edit server')])}}
@@ -24,32 +24,33 @@
});
</script>
<table id="grid-addresses" class="table table-condensed table-hover table-striped" data-editDialog="DialogTls">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="name" data-type="string">{{ lang._('Name') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="caCertificateRefId" data-type="string">{{ lang._('CA-certificate') }}</th>
<th data-column-id="proxyCertificateRefId" data-type="string">{{ lang._('Proxy-certificate') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td>
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
<button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
<div class="tab-content content-box">
<table id="grid-addresses" class="table table-condensed table-hover table-striped" data-editDialog="DialogTls">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="name" data-type="string">{{ lang._('Name') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="caCertificateRefId" data-type="string">{{ lang._('CA-certificate') }}</th>
<th data-column-id="proxyCertificateRefId" data-type="string">{{ lang._('Proxy-certificate') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td>
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
<button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Apply') }}</b> <i id="saveAct_progress"></i></button>
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Apply') }}</b> <i id="saveAct_progress"></i></button>
</div>
</div>
{{ partial("layout_partials/base_dialog",['fields':formDialogTls,'id':'DialogTls','label':lang._('Edit TLS-config')])}}
@@ -1,10 +1,10 @@
#!/bin/sh
RADSECPROXY_DIRS="/usr/local/etc/radsecproxy.d /usr/local/etc/radsecproxy.d/certs"
RADSECPROXY_DIRS="/usr/local/etc/radsecproxy.d/certs"
for directory in ${RADSECPROXY_DIRS}; do
mkdir -p ${directory}
chown -R www:www ${directory}
chown -R root:wheel ${directory}
chmod -R 750 ${directory}
done
@@ -12,7 +12,4 @@ done
# export required certs to filesystem
/usr/local/opnsense/scripts/OPNsense/RadSecProxy/generate_certs.php > /dev/null 2>&1
# remove logfile - sometimes it will stop radsecproxy from starting
#rm /var/log/radsecproxy.log
exit 0
@@ -1,11 +1,5 @@
[setup]
command:/usr/local/opnsense/scripts/OPNsense/RadSecProxy/setup.sh;
parameters:
type:script
message:setup radsecproxy service requirements
[start]
command:/usr/local/opnsense/scripts/OPNsense/RadSecProxy/setup.sh;/usr/local/etc/rc.d/radsecproxy start;
command:/usr/local/etc/rc.d/radsecproxy start
parameters:
type:script
message:starting radsecproxy
@@ -17,13 +11,13 @@ type:script
message:stopping radsecproxy
[restart]
command:/usr/local/opnsense/scripts/OPNsense/RadSecProxy/setup.sh;/usr/local/etc/rc.d/radsecproxy restart;
command:/usr/local/etc/rc.d/radsecproxy restart;
parameters:
type:script
message:restarting radsecproxy
[reload]
command:/usr/local/opnsense/scripts/OPNsense/RadSecProxy/setup.sh;/usr/local/etc/rc.d/radsecproxy restart;
command:/usr/local/etc/rc.d/radsecproxy restart;
parameters:
type:script
message:reloading radsecproxy
@@ -5,8 +5,6 @@
# GENERAL
###########################################
#PidFile /var/run/radsecproxy.pid
#LogDestination file:///var/log/radsecproxy.log
LogDestination x-syslog:///LOG_DAEMON
{% if OPNsense.radsecproxy.general.logLevel is defined and OPNsense.radsecproxy.general.logLevel != "" %}
@@ -1,7 +1,8 @@
{% if helpers.exists('OPNsense.radsecproxy.general.enabled') and OPNsense.radsecproxy.general.enabled == '1' %}
{% if not helpers.empty('OPNsense.radsecproxy.general.enabled') %}
radsecproxy_enable="YES"
{% else %}
radsecproxy_enable="NO"
{% endif %}
radsecproxy_user="root"
radsecproxy_group="wheel"
radsecproxy_setup="/usr/local/opnsense/scripts/OPNsense/RadSecProxy/setup.sh"
@@ -0,0 +1,6 @@
###################################################################
# Local syslog-ng configuration filter definition [radsecproxy].
###################################################################
filter f_local_radsecproxy {
program("radsecproxy");
};