diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2020-01-19 15:41:35 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2020-01-19 15:41:35 +0100 |
| commit | 2823fd993f1f242d3238a552a1f4ef6c7c6f4403 (patch) | |
| tree | 6de2f085851105f490996bb94730c90338d18e3a | |
| parent | 544e5d2581aa85bd60b25673992deb3a704b1f7b (diff) | |
| parent | 55eecac67802301fcc74ffd06a37bc9bae85e5ef (diff) | |
Merge branch 'master' into debian
| -rw-r--r-- | CHANGES | 5 | ||||
| -rw-r--r-- | Cargo.toml | 6 | ||||
| -rw-r--r-- | src/lib.rs | 2 | ||||
| -rw-r--r-- | src/tftpc.rs | 7 | ||||
| -rw-r--r-- | src/tftpd.rs | 14 |
5 files changed, 21 insertions, 13 deletions
@@ -1,3 +1,8 @@ +1.1.1 (2020-01-19) + * Skip canonical path check when running chrooted. + This works around a requirement by musl to have a mounted /proc filesystem + when calling realpath(3). + 1.1.0 (2019-10-05) * Server: - chroot to destination directory if permissions are sufficient @@ -1,6 +1,6 @@ [package] name = "rtftp" -version = "1.1.0" +version = "1.1.1" authors = ["Reiner Herrmann <reiner@reiner-h.de>"] edition = "2018" license = "GPL-3.0-or-later" @@ -10,8 +10,8 @@ lto = true panic = 'abort' [dependencies] -nix = "0.15.0" -getopts = "0.2.19" +nix = "0.16.1" +getopts = "0.2.21" threadpool = "1.7.1" [[bin]] @@ -1,5 +1,5 @@ /* - * Copyright 2019 Reiner Herrmann <reiner@reiner-h.de> + * Copyright 2019-2020 Reiner Herrmann <reiner@reiner-h.de> * License: GPL-3+ */ diff --git a/src/tftpc.rs b/src/tftpc.rs index a134293..d47468f 100644 --- a/src/tftpc.rs +++ b/src/tftpc.rs @@ -1,5 +1,5 @@ /* - * Copyright 2019 Reiner Herrmann <reiner@reiner-h.de> + * Copyright 2019-2020 Reiner Herrmann <reiner@reiner-h.de> * License: GPL-3+ */ @@ -218,10 +218,7 @@ impl Tftpc { }; match err { Ok(msg) => println!("{}", msg), - Err(err) => { - println!("Error: {}", err); - return; - } + Err(err) => println!("Error: {}", err), } } } diff --git a/src/tftpd.rs b/src/tftpd.rs index 6513367..f056a74 100644 --- a/src/tftpd.rs +++ b/src/tftpd.rs @@ -1,5 +1,5 @@ /* - * Copyright 2019 Reiner Herrmann <reiner@reiner-h.de> + * Copyright 2019-2020 Reiner Herrmann <reiner@reiner-h.de> * License: GPL-3+ */ @@ -63,6 +63,12 @@ impl Tftpd { } fn file_allowed(&self, filename: &Path) -> Option<PathBuf> { + if self.conf.dir == PathBuf::from("/") { + /* running either chrooted in requested directory, + or whole root is being served */ + return Some(filename.to_path_buf()); + } + /* get parent to check dir where file should be read/written */ let path = self.conf.dir.join(filename) .parent()? @@ -76,7 +82,7 @@ impl Tftpd { } } - fn handle_wrq(&mut self, socket: &UdpSocket, cl: &SocketAddr, buf: &[u8]) -> Result<(String), io::Error> { + fn handle_wrq(&mut self, socket: &UdpSocket, cl: &SocketAddr, buf: &[u8]) -> Result<String, io::Error> { let (filename, mode, mut options) = self.tftp.parse_file_mode_options(buf)?; self.tftp.init_tftp_options(&socket, &mut options)?; @@ -123,7 +129,7 @@ impl Tftpd { } } - fn handle_rrq(&mut self, socket: &UdpSocket, cl: &SocketAddr, buf: &[u8]) -> Result<(String), io::Error> { + fn handle_rrq(&mut self, socket: &UdpSocket, cl: &SocketAddr, buf: &[u8]) -> Result<String, io::Error> { let (filename, mode, mut options) = self.tftp.parse_file_mode_options(buf)?; self.tftp.init_tftp_options(&socket, &mut options)?; @@ -345,7 +351,7 @@ fn parse_commandline(args: &[String]) -> Option<Configuration> { usage(&opts, &program, Some(String::from("Only one of r (read-only) and w (write-only) allowed"))); return None; } - if matches.free.len() > 0 { + if !matches.free.is_empty() { conf.dir = Path::new(&matches.free[0]).to_path_buf(); } |
