fs.chown(templates, stats.uid, stats.gid, function (er) { if (er) return cb(er) fs.chown(remotes, stats.uid, stats.gid, function (er) { cb(er, stats) }) })
fs.mkdir(dir, mode, function MKDIRCB (er) { // since stat and mkdir are done as two separate syscalls, // operating on a path rather than a file descriptor, it's // possible that the directory didn't exist when we did // the stat, but then *did* exist when we go to to the mkdir. // If we didn't care about uid/gid, we could just mkdir // repeatedly, failing on any error other than "EEXIST". if (er && er.message.indexOf("EEXIST") === 0) { return fs.stat(dir, STATCB) } // any other kind of error is not saveable. if (er) return cb(er) // at this point, we've just created a new directory successfully. // if we care about permissions if (!npm.config.get("unsafe-perm") // care about permissions // specified a uid and gid && uid !== null && gid !== null ) { // set the proper ownership return fs.chown(dir, uid, gid, function (er) { if (er) return cb(er) // attack the next portion of the path. S(dirs.shift()) }) } else { // either we don't care about ownership, or it's already right. S(dirs.shift()) } }) // mkdir
uidNumber('owner' in this ? this.owner : process.getuid(), 'group' in this ? this.group : process.getgid(), function(err, uid, gid) { if (err) callback(err); FS.chown(self.path, uid, gid, function(err) { if (err) callback(err); callback(); }); });
mkdir(templates, function (er) { if (er) return cb(er) // Ensure that both the template and remotes directories have the correct // permissions. fs.chown(templates, stats.uid, stats.gid, function (er) { cb(er, stats) }) })
fs.rename(tmp, pj, function (er) { if (cs.uid && cs.gid) { fs.chown(pj, cs.uid, cs.gid, function (er) { return done(er, data) }) } else { done(er, data) } })
return function (er) { if (er || ensure === npm.dir || typeof uid !== "number" || typeof gid !== "number" || npm.config.get("unsafe-perm")) return cb(er) uid = Math.floor(uid) gid = Math.floor(gid) fs.chown(ensure, uid, gid, cb) }
return function () { if (writeStream.__atomicClosed) return writeStream.__atomicClosed = true if (writeStream.__atomicChown) { var uid = writeStream.__atomicChown.uid var gid = writeStream.__atomicChown.gid return fs.chown(writeStream.__atomicTmp, uid, gid, iferr(cleanup, moveIntoPlace)) } else { moveIntoPlace() } }
}, function (f, cb) { if (process.platform === "win32") { log.silly(f, "skipping chown for windows") cb() } else if (typeof uid === "number" && typeof gid === "number" && parseInt(uid, 10) === uid && parseInt(gid, 10) === gid) { log.verbose([f, uid, gid], "chown") fs.chown(f, uid, gid, cb) } else { log.verbose([f, uid, gid], "not chowning, invalid uid/gid") cb() } }, function (er) {
}, function (f, cb) { if (process.platform === "win32") { log.silly("chown", "skipping for windows", f) cb() } else if (typeof uid === "number" && typeof gid === "number" && parseInt(uid, 10) === uid && parseInt(gid, 10) === gid) { log.verbose("chown", f, [uid, gid]) fs.chown(f, uid, gid, cb) } else { log.verbose("chown", "skip for invalid uid/gid", [f, uid, gid]) cb() } }, function (er) {
function atomicDoStuff(cb) { if (this.__atomicDidStuff) throw new Error('Already did atomic move-into-place') this.__atomicDidStuff = true if (this.__atomicChown) { var uid = this.__atomicChown.uid var gid = this.__atomicChown.gid return fs.chown(this.__atomicTmp, uid, gid, function (er) { if (er) return cb(er) moveIntoPlace.call(this, cb) }.bind(this)) } else { moveIntoPlace.call(this, cb) } }
function endChown (self, want, current, path, cb) { // Don't even try it unless root. Too easy to EPERM. if (process.platform === 'win32') return cb() if (!process.getuid || process.getuid() !== 0) return cb() if (typeof want.uid !== 'number' && typeof want.gid !== 'number') return cb() if (current.uid === want.uid && current.gid === want.gid) return cb() var chown = (self.props.follow || self.type !== 'SymbolicLink') ? 'chown' : 'lchown' if (!fs[chown]) return cb() if (typeof want.uid !== 'number') want.uid = current.uid if (typeof want.gid !== 'number') want.gid = current.gid fs[chown](path, want.uid, want.gid, cb) }
fs.writeFile(cache, JSON.stringify(data), function (er) { if (er || uid === null || gid === null) { return saved() } fs.chown(cache, uid, gid, saved) })
return new Promise(function (resolve, reject) { fs.chown(tmpfile, options.chown.uid, options.chown.gid, function (err) { if (err) reject(err) else resolve() }) })
}, function (f, cb) { fs.chown(f, uid, gid, cb) }, function (er) {