summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReiner Herrmann <reiner@reiner-h.de>2020-01-19 15:26:26 +0100
committerReiner Herrmann <reiner@reiner-h.de>2020-01-19 15:32:20 +0100
commiteacce736ad2cedb0e65d15f5bd0abcee5405ec01 (patch)
tree9bda7f8f4a637f272fa4f7551891607051d0c5e0
parentfce987792548172c8e09d147d0500529aa7188f1 (diff)
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.
-rw-r--r--src/tftpd.rs6
1 files changed, 6 insertions, 0 deletions
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<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()?