Repository: storm Updated Branches: refs/heads/master e5de2558a -> 50c8f8360
[STORM-1407] fix authorize issue for daemon log link in UI Project: http://git-wip-us.apache.org/repos/asf/storm/repo Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/29c910ff Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/29c910ff Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/29c910ff Branch: refs/heads/master Commit: 29c910ff701c3b641a01a8a404ed1c4e9d207b31 Parents: a998c4e Author: zhuol <[email protected]> Authored: Mon Dec 21 15:36:25 2015 -0600 Committer: zhuol <[email protected]> Committed: Mon Dec 21 15:36:25 2015 -0600 ---------------------------------------------------------------------- .../src/clj/backtype/storm/daemon/logviewer.clj | 78 +++++++++----------- 1 file changed, 36 insertions(+), 42 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/storm/blob/29c910ff/storm-core/src/clj/backtype/storm/daemon/logviewer.clj ---------------------------------------------------------------------- diff --git a/storm-core/src/clj/backtype/storm/daemon/logviewer.clj b/storm-core/src/clj/backtype/storm/daemon/logviewer.clj index 78adef6..b58e423 100644 --- a/storm-core/src/clj/backtype/storm/daemon/logviewer.clj +++ b/storm-core/src/clj/backtype/storm/daemon/logviewer.clj @@ -439,49 +439,43 @@ (unauthorized-user-html user)))) (defn daemonlog-page [fname start length grep user root-dir] - (if (or (blank? (*STORM-CONF* UI-FILTER)) - (authorized-log-user? user fname *STORM-CONF*)) - (let [file (.getCanonicalFile (File. root-dir fname)) - file-length (.length file) - path (.getCanonicalPath file) - zip-file? (.endsWith path ".gz")] - (if (and (= (.getCanonicalFile (File. root-dir)) - (.getParentFile file)) - (.exists file)) - (let [file-length (if zip-file? (Utils/zipFileSize (clojure.java.io/file path)) (.length (clojure.java.io/file path))) - length (if length - (min 10485760 length) - default-bytes-per-page) - log-files (into [] (filter #(.isFile %) (.listFiles (File. root-dir)))) ;all types of files included - files-str (for [file log-files] - (.getName file)) - reordered-files-str (conj (filter #(not= fname %) files-str) fname) - log-string (escape-html - (if (is-txt-file fname) - (if start - (page-file path start length) - (page-file path length)) - "This is a binary file and cannot display! You may download the full file.")) - start (or start (- file-length length))] - (if grep - (html [:pre#logContent - (if grep - (->> (.split log-string "\n") - (filter #(.contains % grep)) - (string/join "\n")) - log-string)]) - (let [pager-data (if (is-txt-file fname) (pager-links fname start length file-length) nil)] - (html (concat (log-file-selection-form reordered-files-str "daemonlog") ; list all daemon logs - pager-data - (daemon-download-link fname) - [[:pre#logContent log-string]] - pager-data))))) - (-> (resp/response "Page not found") - (resp/status 404)))) - (if (nil? (get-log-user-group-whitelist fname)) + (let [file (.getCanonicalFile (File. root-dir fname)) + file-length (.length file) + path (.getCanonicalPath file) + zip-file? (.endsWith path ".gz")] + (if (and (= (.getCanonicalFile (File. root-dir)) + (.getParentFile file)) + (.exists file)) + (let [file-length (if zip-file? (Utils/zipFileSize (clojure.java.io/file path)) (.length (clojure.java.io/file path))) + length (if length + (min 10485760 length) + default-bytes-per-page) + log-files (into [] (filter #(.isFile %) (.listFiles (File. root-dir)))) ;all types of files included + files-str (for [file log-files] + (.getName file)) + reordered-files-str (conj (filter #(not= fname %) files-str) fname) + log-string (escape-html + (if (is-txt-file fname) + (if start + (page-file path start length) + (page-file path length)) + "This is a binary file and cannot display! You may download the full file.")) + start (or start (- file-length length))] + (if grep + (html [:pre#logContent + (if grep + (->> (.split log-string "\n") + (filter #(.contains % grep)) + (string/join "\n")) + log-string)]) + (let [pager-data (if (is-txt-file fname) (pager-links fname start length file-length) nil)] + (html (concat (log-file-selection-form reordered-files-str "daemonlog") ; list all daemon logs + pager-data + (daemon-download-link fname) + [[:pre#logContent log-string]] + pager-data))))) (-> (resp/response "Page not found") - (resp/status 404)) - (unauthorized-user-html user)))) + (resp/status 404))))) (defn download-log-file [fname req resp user ^String root-dir] (let [file (.getCanonicalFile (File. root-dir fname))]
