Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2011-02-23 05:31:55 +0300
committerisaacs <i@izs.me>2011-02-23 05:31:55 +0300
commit28f46188f2587262417c4f548b043f473982df2d (patch)
tree2645338326669652cd23105317962eaf54589a9d
parentbeccbd064feb5ef2c5ec104781f06117c210299d (diff)
Managing uids is annoying.
-rw-r--r--lib/cache.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/cache.js b/lib/cache.js
index 1f415e82c..d5a3d4865 100644
--- a/lib/cache.js
+++ b/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) {