diff --git a/ftp/tftp/Makefile b/ftp/tftp/Makefile new file mode 100644 index 000000000..6ae818903 --- /dev/null +++ b/ftp/tftp/Makefile @@ -0,0 +1,8 @@ +PLUGIN_NAME= tftp +PLUGIN_VERSION= 0.1 +PLUGIN_COMMENT= TFTP server +PLUGIN_DEPENDS= tftp-hpa +PLUGIN_DEVEL= yes +PLUGIN_MAINTAINER= m.muenz@gmail.com + +.include "../../Mk/plugins.mk" diff --git a/ftp/tftp/pkg-descr b/ftp/tftp/pkg-descr new file mode 100644 index 000000000..0fca4a310 --- /dev/null +++ b/ftp/tftp/pkg-descr @@ -0,0 +1,4 @@ +tftp-hpa is portable, BSD derived tftp server. It supports advanced +options such as blksize, blksize2, tsize, timeout, and utimeout. +It also supported rulebased security options. + diff --git a/ftp/tftp/src/etc/inc/plugins.inc.d/tftp.inc b/ftp/tftp/src/etc/inc/plugins.inc.d/tftp.inc new file mode 100644 index 000000000..71a0d9a39 --- /dev/null +++ b/ftp/tftp/src/etc/inc/plugins.inc.d/tftp.inc @@ -0,0 +1,49 @@ + + * 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. + */ + +function tftp_services() +{ + global $config; + + $services = array(); + + if (isset($config['OPNsense']['tftp']['general']['enabled']) && $config['OPNsense']['tftp']['general']['enabled'] == 1) { + $services[] = array( + 'description' => gettext('tftp daemon'), + 'configd' => array( + 'restart' => array('tftp restart'), + 'start' => array('tftp start'), + 'stop' => array('tftp stop'), + ), + 'name' => 'in.tftpd', + 'pidfile' => '/var/run/tftpd.pid' + ); + } + + return $services; +} diff --git a/ftp/tftp/src/opnsense/mvc/app/controllers/OPNsense/Tftp/Api/GeneralController.php b/ftp/tftp/src/opnsense/mvc/app/controllers/OPNsense/Tftp/Api/GeneralController.php new file mode 100644 index 000000000..8e99066c9 --- /dev/null +++ b/ftp/tftp/src/opnsense/mvc/app/controllers/OPNsense/Tftp/Api/GeneralController.php @@ -0,0 +1,37 @@ + + * 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. + */ + +namespace OPNsense\Tftp\Api; + +use OPNsense\Base\ApiMutableModelControllerBase; + +class GeneralController extends ApiMutableModelControllerBase +{ + protected static $internalModelClass = '\OPNsense\Tftp\General'; + protected static $internalModelName = 'general'; +} diff --git a/ftp/tftp/src/opnsense/mvc/app/controllers/OPNsense/Tftp/Api/ServiceController.php b/ftp/tftp/src/opnsense/mvc/app/controllers/OPNsense/Tftp/Api/ServiceController.php new file mode 100644 index 000000000..28efc5ea7 --- /dev/null +++ b/ftp/tftp/src/opnsense/mvc/app/controllers/OPNsense/Tftp/Api/ServiceController.php @@ -0,0 +1,39 @@ + + * 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. + */ + +namespace OPNsense\Tftp\Api; + +use OPNsense\Base\ApiMutableServiceControllerBase; + +class ServiceController extends ApiMutableServiceControllerBase +{ + protected static $internalServiceClass = '\OPNsense\Tftp\General'; + protected static $internalServiceTemplate = 'OPNsense/Tftp'; + protected static $internalServiceEnabled = 'enabled'; + protected static $internalServiceName = 'tftp'; +} diff --git a/ftp/tftp/src/opnsense/mvc/app/controllers/OPNsense/Tftp/GeneralController.php b/ftp/tftp/src/opnsense/mvc/app/controllers/OPNsense/Tftp/GeneralController.php new file mode 100644 index 000000000..baf4c7d0b --- /dev/null +++ b/ftp/tftp/src/opnsense/mvc/app/controllers/OPNsense/Tftp/GeneralController.php @@ -0,0 +1,38 @@ + + * 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. + */ + +namespace OPNsense\Tftp; + +class GeneralController extends \OPNsense\Base\IndexController +{ + public function indexAction() + { + $this->view->generalForm = $this->getForm('general'); + $this->view->pick('OPNsense/Tftp/general'); + } +} diff --git a/ftp/tftp/src/opnsense/mvc/app/controllers/OPNsense/Tftp/forms/general.xml b/ftp/tftp/src/opnsense/mvc/app/controllers/OPNsense/Tftp/forms/general.xml new file mode 100644 index 000000000..85a19059b --- /dev/null +++ b/ftp/tftp/src/opnsense/mvc/app/controllers/OPNsense/Tftp/forms/general.xml @@ -0,0 +1,14 @@ +
+ + general.enabled + + checkbox + Enable TFTP daemon. + + + general.listen + + text + Set the IP addresses to listen to. + +
diff --git a/ftp/tftp/src/opnsense/mvc/app/models/OPNsense/Tftp/ACL/ACL.xml b/ftp/tftp/src/opnsense/mvc/app/models/OPNsense/Tftp/ACL/ACL.xml new file mode 100644 index 000000000..19a816d40 --- /dev/null +++ b/ftp/tftp/src/opnsense/mvc/app/models/OPNsense/Tftp/ACL/ACL.xml @@ -0,0 +1,9 @@ + + + Services: TFTP + + ui/tftp/* + api/tftp/* + + + diff --git a/ftp/tftp/src/opnsense/mvc/app/models/OPNsense/Tftp/General.php b/ftp/tftp/src/opnsense/mvc/app/models/OPNsense/Tftp/General.php new file mode 100644 index 000000000..a1c0a0d3f --- /dev/null +++ b/ftp/tftp/src/opnsense/mvc/app/models/OPNsense/Tftp/General.php @@ -0,0 +1,35 @@ + + * 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. + */ + +namespace OPNsense\Tftp; + +use OPNsense\Base\BaseModel; + +class General extends BaseModel +{ +} diff --git a/ftp/tftp/src/opnsense/mvc/app/models/OPNsense/Tftp/General.xml b/ftp/tftp/src/opnsense/mvc/app/models/OPNsense/Tftp/General.xml new file mode 100644 index 000000000..42284290b --- /dev/null +++ b/ftp/tftp/src/opnsense/mvc/app/models/OPNsense/Tftp/General.xml @@ -0,0 +1,15 @@ + + //OPNsense/tftp/general + TFTP configuration + 0.0.1 + + + 0 + Y + + + 127.0.0.1 + Y + + + diff --git a/ftp/tftp/src/opnsense/mvc/app/models/OPNsense/Tftp/Menu/Menu.xml b/ftp/tftp/src/opnsense/mvc/app/models/OPNsense/Tftp/Menu/Menu.xml new file mode 100644 index 000000000..2c810ee3d --- /dev/null +++ b/ftp/tftp/src/opnsense/mvc/app/models/OPNsense/Tftp/Menu/Menu.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ftp/tftp/src/opnsense/mvc/app/views/OPNsense/Tftp/general.volt b/ftp/tftp/src/opnsense/mvc/app/views/OPNsense/Tftp/general.volt new file mode 100644 index 000000000..23bbd7372 --- /dev/null +++ b/ftp/tftp/src/opnsense/mvc/app/views/OPNsense/Tftp/general.volt @@ -0,0 +1,66 @@ +{# + # Copyright (c) 2019 Deciso B.V. + # Copyright (c) 2021 Michael Muenz + # 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. + #} + +
+
+ + + + +
+ {{ lang._('The root folder for transfering files is /usr/local/tftp.') }} +
+
+ {{ partial("layout_partials/base_form",['fields':generalForm,'id':'frm_general_settings'])}} +
+
+ +
+
+ + diff --git a/ftp/tftp/src/opnsense/service/conf/actions.d/actions_tftp.conf b/ftp/tftp/src/opnsense/service/conf/actions.d/actions_tftp.conf new file mode 100644 index 000000000..5e05be709 --- /dev/null +++ b/ftp/tftp/src/opnsense/service/conf/actions.d/actions_tftp.conf @@ -0,0 +1,23 @@ +[start] +command:/usr/local/etc/rc.d/tftpd start +parameters: +type:script +message:starting tftp + +[stop] +command:/usr/local/etc/rc.d/tftpd stop +parameters: +type:script +message:stopping tftp + +[restart] +command:/usr/local/etc/rc.d/tftpd restart +parameters: +type:script +message:restarting tftp + +[status] +command:/usr/local/etc/rc.d/tftpd status;exit 0 +parameters: +type:script_output +message:request tftp status diff --git a/ftp/tftp/src/opnsense/service/templates/OPNsense/Tftp/+TARGETS b/ftp/tftp/src/opnsense/service/templates/OPNsense/Tftp/+TARGETS new file mode 100644 index 000000000..14cc1b4e3 --- /dev/null +++ b/ftp/tftp/src/opnsense/service/templates/OPNsense/Tftp/+TARGETS @@ -0,0 +1 @@ +tftpd:/etc/rc.conf.d/tftpd diff --git a/ftp/tftp/src/opnsense/service/templates/OPNsense/Tftp/tftpd b/ftp/tftp/src/opnsense/service/templates/OPNsense/Tftp/tftpd new file mode 100644 index 000000000..982879ac7 --- /dev/null +++ b/ftp/tftp/src/opnsense/service/templates/OPNsense/Tftp/tftpd @@ -0,0 +1,6 @@ +{% if helpers.exists('OPNsense.tftp.general.enabled') and OPNsense.tftp.general.enabled == '1' %} +tftpd_enable="YES" +tftpd_flags="-s /usr/local/tftp -a {{ OPNsense.tftp.general.listen }}" +{% else %} +tftpd_enable="NO" +{% endif %}