aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/tftp2/tftp.inc10
-rw-r--r--config/tftp2/tftp.priv.inc38
-rw-r--r--config/tftp2/tftp.xml18
-rw-r--r--config/tftp2/tftp_files.php135
-rw-r--r--pkg_config.10.xml2
-rw-r--r--pkg_config.8.xml2
-rw-r--r--pkg_config.8.xml.amd642
7 files changed, 122 insertions, 85 deletions
diff --git a/config/tftp2/tftp.inc b/config/tftp2/tftp.inc
index 67054619..75ddaac8 100644
--- a/config/tftp2/tftp.inc
+++ b/config/tftp2/tftp.inc
@@ -50,10 +50,10 @@ function tftp_install_command() {
// Restore backup if it exists
if (file_exists($tftpbackup)) {
- system("/usr/bin/tar xvpfz {$tftpbackup} -C /");
- system("/bin/chmod -R 0744 {$tftpdir}/*");
- unset($tftpbackup);
+ mwexec("/usr/bin/tar xvpfz {$tftpbackup} -C /");
+ mwexec("/bin/chmod -R 0744 {$tftpdir}/*");
}
+ unset($tftpdir, $tftpbackup);
}
function tftp_deinstall_command() {
@@ -68,11 +68,9 @@ function tftp_generate_rules($type) {
return;
}
- // Open inetd.conf write handle
+ // Add tftpd daemon to inetd
$inetd_fd = fopen("/var/etc/inetd.conf", "a+");
- // Add tftp daemon
fwrite($inetd_fd, "tftp\t\tdgram\tudp\twait\t\troot\t/usr/libexec/tftpd\ttftpd /tftpboot\n");
- // Close file handle
fclose($inetd_fd);
if (!empty($config['installedpackages']['tftpd']['config'][0]['tftpdinterface'])) {
diff --git a/config/tftp2/tftp.priv.inc b/config/tftp2/tftp.priv.inc
new file mode 100644
index 00000000..14691924
--- /dev/null
+++ b/config/tftp2/tftp.priv.inc
@@ -0,0 +1,38 @@
+<?php
+/*
+ tftp.priv.inc
+ part of pfSense (http://www.pfSense.org/)
+ Copyright (C) 2015 ESF, LLC
+ 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.
+*/
+global $priv_list;
+
+$priv_list['page-services-tftp'] = array();
+$priv_list['page-services-tftp']['name'] = "WebCfg - Services: TFTP package";
+$priv_list['page-services-tftp']['descr'] = "Allow access to TFTP package GUI";
+$priv_list['page-services-tftp']['match'] = array();
+
+$priv_list['page-services-tftp']['match'][] = "tftp_files.php*";
+
+?>
diff --git a/config/tftp2/tftp.xml b/config/tftp2/tftp.xml
index 2a526a4c..33fb9c3d 100644
--- a/config/tftp2/tftp.xml
+++ b/config/tftp2/tftp.xml
@@ -43,7 +43,7 @@
]]>
</copyright>
<name>tftp Settings</name>
- <version>2.0</version>
+ <version>2.2.2</version>
<title>TFTP: Settings</title>
<include_file>/usr/local/pkg/tftp.inc</include_file>
<menu>
@@ -56,23 +56,21 @@
<service>
<name>tftp</name>
<executable>inetd</executable>
- <description>TFTP daemon</description>
+ <description>TFTP Daemon</description>
</service>
- <tabs>
- <tab>
- <text>Files</text>
- <url>tftp_files.php</url>
- </tab>
- </tabs>
<configpath>installedpackages->$packagename</configpath>
<additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
<item>https://packages.pfsense.org/packages/config/tftp2/tftp.inc</item>
- </additional_files_needed>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/etc/inc/priv/</prefix>
+ <item>https://packages.pfsense.org/packages/config/tftp2/tftp.priv.inc</item>
+ </additional_files_needed>
<additional_files_needed>
<prefix>/usr/local/www/</prefix>
<item>https://packages.pfsense.org/packages/config/tftp2/tftp_files.php</item>
- </additional_files_needed>
+ </additional_files_needed>
<custom_php_install_command>
tftp_install_command();
</custom_php_install_command>
diff --git a/config/tftp2/tftp_files.php b/config/tftp2/tftp_files.php
index eebe4c5e..0352f4a0 100644
--- a/config/tftp2/tftp_files.php
+++ b/config/tftp2/tftp_files.php
@@ -29,6 +29,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("guiconfig.inc");
+require_once("util.inc");
require_once("/usr/local/pkg/tftp.inc");
$pconfig['tftpdinterface'] = explode(",", $config['installedpackages']['tftpd']['config'][0]['tftpdinterface']);
@@ -43,7 +44,7 @@ if (($_GET['a'] == "download") && $_GET['t'] == "backup") {
conf_mount_rw();
$filename = $backup_filename;
$download_dir = $backup_dir;
- system("tar -czC / -f {$backup_path} tftpboot");
+ mwexec("/usr/bin/tar -czC / -f {$backup_path} tftpboot");
conf_mount_ro();
}
@@ -73,8 +74,8 @@ if ($_GET['a'] == "other") {
if (file_exists($backup_path)) {
//echo "The file $filename exists";
conf_mount_rw();
- system("tar -xpzC / -f {$backup_path}");
- system("chmod -R 744 {$files_dir}/*");
+ mwexec("/usr/bin/tar -xpzC / -f {$backup_path}");
+ mwexec("/bin/chmod -R 744 {$files_dir}/*");
header( 'Location: tftp_files.php?savemsg=Backup+has+been+restored.' ) ;
conf_mount_ro();
} else {
@@ -100,7 +101,7 @@ if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_na
conf_mount_rw();
move_uploaded_file($_FILES['ulfile']['tmp_name'], "{$files_dir}/{$_FILES['ulfile']['name']}");
$savemsg = "Uploaded file to {$files_dir}/" . htmlentities($_FILES['ulfile']['name']);
- system('chmod -R 744 {$files_dir}/*');
+ mwexec('/bin/chmod -R 744 {$files_dir}/*');
unset($_POST['txtCommand']);
conf_mount_ro();
}
@@ -122,7 +123,7 @@ include("head.inc");
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
-<p class="pgtitle">TFTP: Files</p>
+<p class="pgtitle">TFTP: Settings/Files</p>
<?php
$savemsg = $_GET["savemsg"];
@@ -137,7 +138,7 @@ if ($savemsg) {
<?php
$tab_array = array();
- $tab_array[] = array(gettext("Files"), false, "tftp_files.php");
+ $tab_array[] = array(gettext("TFTP"), false, "tftp_files.php");
display_top_tabs($tab_array);
?>
@@ -145,14 +146,16 @@ if ($savemsg) {
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td>
+<div id="mainarea">
+ <table id="maintable" class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
- <td class="tabcont">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <td colspan="2" class="listtopic">TFTP Daemon Interfaces</td>
+ </tr>
<tr>
+ <td width="22%" class="vncell">Select TFTP Daemon Interface(s).</td>
<td width="78%" class="vtable">
<form action="tftp_files.php" method="post" enctype="multipart/form-data" name="frmInterfaces" onsubmit="">
- <p><span class="vexpl"><strong>TFTP Daemon Interfaces</strong></span></p>
- <?=gettext("Choose the interfaces where you want the TFTP daemon to accept connections.");?><br/><br/>
<select name="tftpdinterface[]" multiple="multiple" class="formselect" size="3">
<?php
$ifdescs = get_configured_interface_with_descr();
@@ -164,70 +167,46 @@ if ($savemsg) {
echo "\t\t\t<option value=\"{$ifent}\"{$selected}>" . $ifdesc . "</option>\n";
}
?>
- </select><br />
- <input name="submit" type="submit" class="button" id="save" value="Save" />
+ </select><br /><br />
+ <span class="vexpl">
+ Choose the interfaces where you want the TFTP Daemon to accept connections.<br/>
+ <strong>Hint:</strong> If you simply need to (re)start tftpd/inetd, just use the Save button without making any changes here.<br /><br />
+ </span>
+ <input name="submit" type="submit" class="formbtns" id="save" value="Save" title="Save settings" />
</form>
</td>
</tr>
<tr>
- <td>
- <p><span class="vexpl"><span class="red"><strong>TFTP files</strong></span><br />
- Trivial File Transport Protocol is a very simple file transfer protocol.<br />
- Use the file upload to add files to the /tftpboot directory.<br />
- Click on the file from the file list below to download it.<br />
- </span></p>
- </td>
+ <td colspan="2" class="listtopic">TFTP Files Upload</td>
</tr>
- </table>
- <br />
- <div id="niftyOutter">
- <form action="tftp_files.php" method="post" enctype="multipart/form-data" name="frmUpload" onsubmit="">
- <table>
- <tr>
- <td align="right">File to upload:</td>
- <td valign="top" class="label">
- <input name="ulfile" type="file" class="button" id="ulfile" />
- </td>
- </tr>
- <tr>
- <td valign="top">&nbsp;&nbsp;&nbsp;</td>
- <td valign="top" class="label">
- <input name="submit" type="submit" class="button" id="upload" value="Upload" />
- </td>
- </tr>
- </table>
- </form>
- </div>
- <br /><br />
-
- <table width='690' cellpadding='0' cellspacing='0' border='0'>
<tr>
- <td width='80%'>
- <strong>Backup / Restore</strong><br />
- The 'Backup' button compresses /tftpboot/ to /root/backup/tftp.bak.tgz; after that it presents the backup for download.<br />
- If the backup file does not exist in /root/backup/tftp.bak.tgz then the 'Restore' button will be hidden.<br />
- Use Diagnostics -> Command -> File to upload: to browse to the file and then click on upload.<br />
- After that, backup will be ready to be restored.<br /><br />
- </td>
- <td width='20%' valign='middle' align='right'>
- <input type="button" value="Backup" onclick="document.location.href='tftp_files.php?a=download&amp;t=backup'" />
- <?php
- if (file_exists('/root/backup/tftp.bak.tgz')) {
- echo "<input type='button' value='Restore' onclick=\"document.location.href='tftp_files.php?a=other&amp;t=restore';\" />\n";
- }
- ?>
+ <td width="22%" class="vncell">Use the file upload to add files to the /tftpboot directory.</td>
+ <td width="78%" class="vtable">
+ <form action="tftp_files.php" method="post" enctype="multipart/form-data" name="frmUpload" onsubmit="">
+ <span class="vexpl">1. Select file to upload:&nbsp;</span>
+ <input name="ulfile" type="file" class="formbtns" id="ulfile" title="Select file to upload" />
+ <br />
+ <span class="vexpl">2. Upload the selected file:&nbsp;</span>
+ <input name="submit" type="submit" class="formbtns" id="upload" value="Upload" title="Upload file" />
+ </form>
</td>
</tr>
- </table>
- <br /><br />
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
- <td width="25%" class="listhdrr">File Name (download)</td>
- <td width="50%" class="listhdr">Last Modified</td>
- <td width="50%" class="listhdr">Size</td>
+ <td colspan="3" class="listtopic">TFTP Files Download</td>
</tr>
+ <tr>
+ <td colspan="3" class="vexpl">Click on the file from the file list below to download it.</td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="25%" class="listhdrr">File Name (download)</td>
+ <td width="50%" class="listhdr">Last Modified</td>
+ <td width="50%" class="listhdr">Size</td>
+ </tr>
<?php
if ($handle = opendir('/tftpboot')) {
@@ -267,13 +246,37 @@ if ($handle = opendir('/tftpboot')) {
}
?>
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
<tr>
- <td class="list" colspan="3"></td>
- <td class="list"></td>
+ <td colspan="2" class="listtopic">TFTP Backup / Restore</td>
</tr>
- </table>
- </td>
+ <tr>
+ <td width="22%" class="vncell">Use the file upload to add files to the /tftpboot directory.</td>
+ <td width="78%" class="vtable">
+ <span class="vexpl"><strong>Backup:</strong> 'Backup' button compresses /tftpboot/ to /root/backup/tftp.bak.tgz; after that it presents the backup for download.<br />
+ <strong>Restore:</strong> If the backup file does not exist in /root/backup/tftp.bak.tgz then the 'Restore' button will be hidden.
+ To 'Restore' a previously downloaded backup, use <a href="diag_backup.php" title="Upload file">Diagnostics -> Command Prompt -> File to upload</a> to browse to the file and then click on upload.<br />
+ After that, backup will be ready to be restored.<br /><br />
+ </span>
+ <input type="button" value="Backup" title="Create backup" onclick="document.location.href='tftp_files.php?a=download&amp;t=backup'" />
+ <?php
+ if (file_exists('/root/backup/tftp.bak.tgz')) {
+ echo "<input type='button' value='Restore' title='Restore backup' onclick=\"document.location.href='tftp_files.php?a=other&amp;t=restore';\" />\n";
+ }
+ ?>
+ </td>
</tr>
+ </table>
+
+</div>
+</td></tr>
</table>
</div>
diff --git a/pkg_config.10.xml b/pkg_config.10.xml
index d1fb5e52..7a5ac21a 100644
--- a/pkg_config.10.xml
+++ b/pkg_config.10.xml
@@ -325,7 +325,7 @@
<pkginfolink/>
<port_category>ftp</port_category>
<config_file>https://packages.pfsense.org/packages/config/tftp2/tftp.xml</config_file>
- <version>2.2.1</version>
+ <version>2.2.2</version>
<status>Stable</status>
<required_version>2.2</required_version>
<configurationfile>tftp.xml</configurationfile>
diff --git a/pkg_config.8.xml b/pkg_config.8.xml
index 3d0e6a74..b1304606 100644
--- a/pkg_config.8.xml
+++ b/pkg_config.8.xml
@@ -397,7 +397,7 @@
<pkginfolink/>
<config_file>https://packages.pfsense.org/packages/config/tftp2/tftp.xml</config_file>
<depends_on_package_base_url>https://files.pfsense.org/packages/8/All/</depends_on_package_base_url>
- <version>2.1</version>
+ <version>2.2.2</version>
<status>Stable</status>
<required_version>2.0</required_version>
<configurationfile>tftp.xml</configurationfile>
diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64
index 0af89cfc..34b3f7a2 100644
--- a/pkg_config.8.xml.amd64
+++ b/pkg_config.8.xml.amd64
@@ -384,7 +384,7 @@
<pkginfolink/>
<config_file>https://packages.pfsense.org/packages/config/tftp2/tftp.xml</config_file>
<depends_on_package_base_url>https://files.pfsense.org/packages/amd64/8/All/</depends_on_package_base_url>
- <version>2.1</version>
+ <version>2.2.2</version>
<status>Stable</status>
<required_version>2.0</required_version>
<configurationfile>tftp.xml</configurationfile>