From 51e0609222d4f231de7ae68fd44194eeab20ddd7 Mon Sep 17 00:00:00 2001 From: Matthew Ratzke Date: Wed, 3 May 2017 19:22:03 -0600 Subject: [PATCH 1/2] guard against symbolic links --- boot/pod/src/boot/tmpdir.clj | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/boot/pod/src/boot/tmpdir.clj b/boot/pod/src/boot/tmpdir.clj index 6d3cf43b..3d3b6878 100644 --- a/boot/pod/src/boot/tmpdir.clj +++ b/boot/pod/src/boot/tmpdir.clj @@ -13,7 +13,8 @@ (:import [java.io File] [java.util Properties] - [java.nio.file Path Files SimpleFileVisitor])) + [java.nio.file Path Files SimpleFileVisitor] + [java.nio.file.attribute BasicFileAttributes])) (set! *warn-on-reflection* true) @@ -91,16 +92,17 @@ [^Path root ^File blob tree link] (let [m {:dir (.toFile root) :bdir blob}] (proxy [SimpleFileVisitor] [] - (visitFile [^Path path attr] + (visitFile [^Path path ^BasicFileAttributes attr] (with-let [_ fs/continue] (let [p (str (.relativize root path))] - (try (let [h (digest/md5 (.toFile path)) - t (.toMillis (Files/getLastModifiedTime path fs/link-opts)) - i (str h "." t)] + (when-not (.isSymbolicLink attr) + (try (let [h (digest/md5 (.toFile path)) + t (.toMillis (Files/getLastModifiedTime path fs/link-opts)) + i (str h "." t)] (add-blob! blob path i link) (swap! tree assoc p (map->TmpFile (assoc m :path p :id i :hash h :time t)))) (catch java.nio.file.NoSuchFileException _ - (util/dbug* "Tmpdir: file not found: %s\n" (.toString p))))) ))))) + (util/dbug* "Tmpdir: file not found: %s\n" (.toString p))))) )))))) (defn- dir->tree! [^File dir ^File blob] @@ -263,7 +265,7 @@ err? (fatal-conflict? dst) this (or (and (not err?) this) (update-in this [:tree] dissoc p))] - (if err? + (if err? (util/warn "Merge conflict: not adding %s\n" p) (do (util/trace* "Commit: adding %s %s...\n" (id tmpf) p) (file/hard-link src dst))) From 8672013a232c9f3e6c1e92aed547454c66b0cf5b Mon Sep 17 00:00:00 2001 From: Matthew Ratzke Date: Tue, 19 Dec 2017 10:59:35 -0700 Subject: [PATCH 2/2] Update tmpdir.clj --- boot/pod/src/boot/tmpdir.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/pod/src/boot/tmpdir.clj b/boot/pod/src/boot/tmpdir.clj index 17e35aee..babc2569 100644 --- a/boot/pod/src/boot/tmpdir.clj +++ b/boot/pod/src/boot/tmpdir.clj @@ -102,7 +102,7 @@ (add-blob! blob path i link) (swap! tree assoc p (map->TmpFile (assoc m :path p :id i :hash h :time t)))) (catch java.nio.file.NoSuchFileException _ - (util/dbug* "Tmpdir: file not found: %s\n" (.toString p))))))) + (util/dbug* "Tmpdir: file not found: %s\n" (.toString p)))))))) (visitFileFailed [^Path path ^java.io.IOException e] (with-let [_ fs/skip-subtree] (util/dbug* "Tmpdir: failed to visit: %s\n" (str (.relativize root path))))))))