Browse files

Managing uids is annoying.

  • Loading branch information...
1 parent beccbd0 commit 28f46188f2587262417c4f548b043f473982df2d @isaacs isaacs committed Feb 22, 2011
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/cache.js
View
10 lib/cache.js
@@ -425,7 +425,15 @@ function unpackTar_ ( tarball, unpackTarget, dMode, fMode, uid, gid, cb ) {
// then we're done now.
if (er) return log.er(cb,
"Failed unpacking "+tarball+" to "+unpackTarget)(er)
- if (npm.config.get("unsafe-perm")) return cb(er)
+ if (npm.config.get("unsafe-perm")) {
+ if (!process.getuid || !process.getgid) return cb(er)
+ uid = process.getuid()
+ gid = process.getgid()
+ if (uid === 0) {
+ if (process.env.SUDO_UID) uid = +process.env.SUDO_UID
+ if (process.env.SUDO_GID) gid = +process.env.SUDO_GID
+ }
+ }
find(unpackTarget, function (f) {
return f !== unpackTarget
}, function (er, files) {

0 comments on commit 28f4618

Please sign in to comment.