diff options
author | isaacs <i@izs.me> | 2011-02-08 03:50:00 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-02-08 04:09:08 +0300 |
commit | a997b3491059a55a04353c904c01e2b891d000d8 (patch) | |
tree | 453c18361a9dc1433eded4ae556e5b5757351045 /npm.js | |
parent | 18166ae8bfeeb90e5136439b72b061c88fb6a5d1 (diff) |
Check for sudo being ok based on node version
Diffstat (limited to 'npm.js')
-rw-r--r-- | npm.js | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -20,6 +20,7 @@ var EventEmitter = require("events").EventEmitter , path = require("path") , abbrev = require("./lib/utils/abbrev") , which = require("./lib/utils/which") + , semver = require("./lib/utils/semver") npm.commands = {} npm.ELIFECYCLE = {} @@ -196,4 +197,16 @@ Object.defineProperty(npm, "tmp", }) // platforms without uid/gid support are assumed to be in unsafe-perm mode. -if (!process.getuid) npm.config.set("unsafe-perm", true) +var sudoOk = !semver.lt(process.version, '0.3.5') +if (!process.getuid || !sudoOk) { + npm.config.set("unsafe-perm", true) +} +if (process.getuid && process.getuid() === 0 && !sudoOk) { + process.nextTick(function () { + log(["" + ,"Please upgrade to node 0.3.5 or higher" + ,"if you are going to be running npm as root." + ,"It is not safe otherwise." + ,""].join("\n"), "", "error") + }) +} |