From fce987792548172c8e09d147d0500529aa7188f1 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 19 Jan 2020 15:23:31 +0100 Subject: Update dependencies to versions in Debian unstable --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a1adf0d..0bc7b41 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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]] -- cgit v1.2.3 From eacce736ad2cedb0e65d15f5bd0abcee5405ec01 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 19 Jan 2020 15:26:26 +0100 Subject: Skip canonical path check when running chrooted This works around musl's requirement of mounted /proc for running realpath(3), which is used by std::path::Path.canonicalize(). See also: https://www.openwall.com/lists/musl/2019/10/08/1 The check is not required, as only files inside the chrooted directory can be served. --- src/tftpd.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tftpd.rs b/src/tftpd.rs index 6513367..e135d9f 100644 --- a/src/tftpd.rs +++ b/src/tftpd.rs @@ -63,6 +63,12 @@ impl Tftpd { } fn file_allowed(&self, filename: &Path) -> Option { + 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()? -- cgit v1.2.3 From 16c25588ee55261b9bbd58b5f2c61f3327f7596c Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 19 Jan 2020 15:33:33 +0100 Subject: Some cleanup as suggested by clippy --- src/tftpc.rs | 5 +---- src/tftpd.rs | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/tftpc.rs b/src/tftpc.rs index a134293..1e08982 100644 --- a/src/tftpc.rs +++ b/src/tftpc.rs @@ -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 e135d9f..dcc9f09 100644 --- a/src/tftpd.rs +++ b/src/tftpd.rs @@ -82,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 { let (filename, mode, mut options) = self.tftp.parse_file_mode_options(buf)?; self.tftp.init_tftp_options(&socket, &mut options)?; @@ -129,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 { let (filename, mode, mut options) = self.tftp.parse_file_mode_options(buf)?; self.tftp.init_tftp_options(&socket, &mut options)?; @@ -351,7 +351,7 @@ fn parse_commandline(args: &[String]) -> Option { 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(); } -- cgit v1.2.3 From 0e3122106cd6883e21a507c14d25fd57eaab808c Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 19 Jan 2020 15:35:28 +0100 Subject: Bump copyright years --- src/lib.rs | 2 +- src/tftpc.rs | 2 +- src/tftpd.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6250722..842dcb9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ /* - * Copyright 2019 Reiner Herrmann + * Copyright 2019-2020 Reiner Herrmann * License: GPL-3+ */ diff --git a/src/tftpc.rs b/src/tftpc.rs index 1e08982..d47468f 100644 --- a/src/tftpc.rs +++ b/src/tftpc.rs @@ -1,5 +1,5 @@ /* - * Copyright 2019 Reiner Herrmann + * Copyright 2019-2020 Reiner Herrmann * License: GPL-3+ */ diff --git a/src/tftpd.rs b/src/tftpd.rs index dcc9f09..f056a74 100644 --- a/src/tftpd.rs +++ b/src/tftpd.rs @@ -1,5 +1,5 @@ /* - * Copyright 2019 Reiner Herrmann + * Copyright 2019-2020 Reiner Herrmann * License: GPL-3+ */ -- cgit v1.2.3 From a0129b1fdfc57911bddd93f477c2f12fdd21a371 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 19 Jan 2020 15:38:53 +0100 Subject: Update changelog --- CHANGES | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index f21fa28..8a641c5 100644 --- a/CHANGES +++ b/CHANGES @@ -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 -- cgit v1.2.3 From 55eecac67802301fcc74ffd06a37bc9bae85e5ef Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 19 Jan 2020 15:39:27 +0100 Subject: Bump version to 1.1.1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 0bc7b41..c094591 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rtftp" -version = "1.1.0" +version = "1.1.1" authors = ["Reiner Herrmann "] edition = "2018" license = "GPL-3.0-or-later" -- cgit v1.2.3