From 43a270b78ccd6605a4531ff164f8684a31a02d8e Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 31 Oct 2015 10:48:35 +0100 Subject: Add privileges configuration to tftp package --- config/tftp2/tftp.priv.inc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 config/tftp2/tftp.priv.inc (limited to 'config') 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 @@ + -- cgit v1.2.3 From 1b29b2b5314452ed4ee16bc89ec3dd2f046f3e68 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 31 Oct 2015 10:51:14 +0100 Subject: Add privileges configuration to tftp package, fix whitespace and cleanup --- config/tftp2/tftp.xml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'config') 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 @@ ]]> tftp Settings - 2.0 + 2.2.2 TFTP: Settings /usr/local/pkg/tftp.inc @@ -56,23 +56,21 @@ tftp inetd - TFTP daemon + TFTP Daemon - - - Files - tftp_files.php - - installedpackages->$packagename /usr/local/pkg/ https://packages.pfsense.org/packages/config/tftp2/tftp.inc - + + + /etc/inc/priv/ + https://packages.pfsense.org/packages/config/tftp2/tftp.priv.inc + /usr/local/www/ https://packages.pfsense.org/packages/config/tftp2/tftp_files.php - + tftp_install_command(); -- cgit v1.2.3 From 0c89aa154393f06c752187896922b5ba058ab1a2 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 31 Oct 2015 10:57:11 +0100 Subject: Use mwexec(), cleanups --- config/tftp2/tftp.inc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'config') 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'])) { -- cgit v1.2.3 From d33e33fc4e9985b7d5cad7ac66553e7497eee1ee Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 31 Oct 2015 13:05:02 +0100 Subject: Make the GUI look a bit civilized --- config/tftp2/tftp_files.php | 135 ++++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 66 deletions(-) (limited to 'config') 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"); -

TFTP: Files

+

TFTP: Settings/Files

@@ -145,14 +146,16 @@ if ($savemsg) { +
+
+ - + + + +
- + + + - + -
TFTP Daemon Interfaces
Select TFTP Daemon Interface(s).
-

TFTP Daemon Interfaces

-


- +

+ + Choose the interfaces where you want the TFTP Daemon to accept connections.
+ Hint: If you simply need to (re)start tftpd/inetd, just use the Save button without making any changes here.

+
+
-

TFTP files
- Trivial File Transport Protocol is a very simple file transfer protocol.
- Use the file upload to add files to the /tftpboot directory.
- Click on the file from the file list below to download it.
-

-
TFTP Files Upload
-
-
-
- - - - - - - - - -
File to upload: - -
    - -
-
-
-

- - - - + -
- Backup / Restore
- The 'Backup' button compresses /tftpboot/ to /root/backup/tftp.bak.tgz; after that it presents the backup for download.
- If the backup file does not exist in /root/backup/tftp.bak.tgz then the 'Restore' button will be hidden.
- Use Diagnostics -> Command -> File to upload: to browse to the file and then click on upload.
- After that, backup will be ready to be restored.

-
- - \n"; - } - ?> + Use the file upload to add files to the /tftpboot directory. +
+ 1. Select file to upload:  + +
+ 2. Upload the selected file:  + +
-

- - - - + + + + + + + + - - + -
File Name (download)Last ModifiedSizeTFTP Files Download
Click on the file from the file list below to download it.
+ + + + + + + + + + +
File Name (download)Last ModifiedSize
+
TFTP Backup / Restore
-
Use the file upload to add files to the /tftpboot directory. + Backup: 'Backup' button compresses /tftpboot/ to /root/backup/tftp.bak.tgz; after that it presents the backup for download.
+ Restore: 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 Diagnostics -> Command Prompt -> File to upload to browse to the file and then click on upload.
+ After that, backup will be ready to be restored.

+
+ + \n"; + } + ?> +
+ +
+
-- cgit v1.2.3