How to use the getuid function from process

Find comprehensive JavaScript process.getuid code examples handpicked from public code repositorys.

42
43
44
45
46
47
48
49
50
51
52
    console.log('*** ' + msg);
    process.exit(1);
}


function main() {
    var uid = process.getuid();
    if (process.env.OS !== 'LINUX') {
        fail('This script works on linux only.');
    }
    console.log([
fork icon7
star icon31
watch icon0

358
359
360
361
362
363
364
365
366
/* Permit based on ownership */
if (statBuf.uid === fun.selfStat.uid)
  return true; /* owned by same user as dcp-client */
if (statBuf.uid === fun.mainStat.uid)
  return true; /* owned by same user as main program */
if (statBuf.uid === process.getuid())
  return true; /* owned by user running the code */
if (statBuf.uid === 0)
  return true; /* owned by root */
fork icon1
star icon5
watch icon4

28
29
30
31
32
33
34
35
36
37
}
const process = require('process')
console.log(
  process.pid,
  process.ppid,
  process.getuid(),
  process.getgroups(),
  'PID'
)

fork icon0
star icon2
watch icon1

38
39
40
41
42
43
44
45
46
47
  // Setting user id
  process.setuid(400);

  // Printing getuid() value
  console.log("The user identity of the Node.js"
      + " process:", process.getuid());
}
```

**输出:**
fork icon0
star icon2
watch icon5

+ 3 other calls in file

2
3
4
5
6
7
8
9
10
// console.log(process.getgid())
// console.log("process.ppid", process.binding('credentials'));
console.log('process.ppid', process.ppid);
console.log('process.pid', process.pid);
console.log('process.getgid()', process.getgid());
console.log('process.getuid()', process.getuid());
console.log('process.setuid()', process.setuid);
console.log('process.setuid()', process.initgroups);
console.log('process.getgroups()', process.getgroups());
fork icon0
star icon1
watch icon1

213
214
215
216
217
218
219
220
221
222
223
224


UUID.v2uuid = function v2uuid(id, type, mac) {
  var args = Array.prototype.slice.call(arguments);


  if (args.length === 0) {
    id = process.getuid();
    type = 0; // person
    mac = null;
  } else if (args.length === 1) {
    if (util.isBoolean(args[0])) {
fork icon0
star icon0
watch icon0

+ 5 other calls in file

17
18
19
20
21
22
23
24
25
26
27
28
let url = require("url");
let path = require("path");
const root = "/test1Dir";
let dlj = require("./dir_list_json.js");


let G_port = process.getuid(); /** type "id" on Linux for uid value **/
if (G_port < 1024) G_port += 10000; // do not use privileged ports


function serveApp(request, response) {
  let filename = url.parse(request.url)["pathname"];
fork icon0
star icon0
watch icon0