Permalink
Browse files

Never create un-listable directories

  • Loading branch information...
1 parent 38a9453 commit 2c05f5c3860180d7829ac507f0b42a59e8e8e5f4 @isaacs isaacs committed Mar 12, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/utils/tar.js
View
@@ -205,6 +205,13 @@ function gunzTarPerm (tarball, tmp, dMode, fMode, uid, gid, cb) {
var fst = fs.createReadStream(tarball)
+ function extractEntry (entry) {
+ // never create things that are user-unreadable,
+ // or dirs that are user-un-listable. Only leads to headaches.
+ entry.mode = entry.mode | (entry.type === "Directory" ? dMode : fMode)
+ entry.props.mode = entry.mode
+ }
+
fst.on("error", log.er(cb, "error reading "+tarball))
fst.on("data", function OD (c) {
// detect what it is.
@@ -219,12 +226,14 @@ function gunzTarPerm (tarball, tmp, dMode, fMode, uid, gid, cb) {
.pipe(zlib.Unzip())
.on("error", log.er(cb, "unzip error "+tarball))
.pipe(tar.Extract({ type: "Directory", path: tmp }))
+ .on("entry", extractEntry)
.on("error", log.er(cb, "untar error "+tarball))
.on("close", afterUntar)
} else if (c.toString().match(/^package\//)) {
// naked tar
fst
.pipe(tar.Extract({ type: "Directory", path: tmp }))
+ .on("entry", extractEntry)
.on("error", log.er(cb, "untar error "+tarball))
.on("close", afterUntar)
} else {

0 comments on commit 2c05f5c

Please sign in to comment.