示例#1
0
      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)
        })
      })
示例#2
0
文件: mkdir-p.js 项目: alFReD-NSH/npm
        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
示例#3
0
 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)
      })
    })
示例#5
0
文件: cache.js 项目: fiws/npm
 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)
   }
 })
示例#6
0
文件: mkdir-p.js 项目: alFReD-NSH/npm
 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)
 }
示例#7
0
 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()
     }
 }
示例#8
0
文件: cache.js 项目: AllenWeb/node
 }, 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) {
示例#9
0
文件: cache.js 项目: InfInt/npm
 }, 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) {
示例#10
0
文件: index.js 项目: 10fish/datafari
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)
  }
}
示例#11
0
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)
}
示例#12
0
文件: get.js 项目: morganrallen/npm
 fs.writeFile(cache, JSON.stringify(data), function (er) {
   if (er || uid === null || gid === null) {
     return saved()
   }
   fs.chown(cache, uid, gid, saved)
 })
示例#13
0
 return new Promise(function (resolve, reject) {
   fs.chown(tmpfile, options.chown.uid, options.chown.gid, function (err) {
     if (err) reject(err)
     else resolve()
   })
 })
示例#14
0
文件: cache.js 项目: deanlandolt/npm
 }, function (f, cb) {
   fs.chown(f, uid, gid, cb)
 }, function (er) {