From 9470367515a1110a72b90eb3db95c65f726ff077 Mon Sep 17 00:00:00 2001 From: "Pooja D.P" Date: Wed, 21 Oct 2020 16:35:27 +0400 Subject: [PATCH 1/3] doc: add a example code to API doc property example code added to the process.setgroups() API doc property in process.md --- doc/api/process.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/api/process.md b/doc/api/process.md index 5568adfb6fc203..b580ef29c5d43a 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -2212,6 +2212,18 @@ process to have `root` or the `CAP_SETGID` capability. The `groups` array can contain numeric group IDs, group names or both. +```js +if (process.getgroups && process.setgroups) { + console.log( process.getgroups()); // current groups + try { + process.setgroups([501]); + console.log(process.getgroups()); // new groups + } catch (err) { + console.log(`Failed to set groups: ${err}`); + } +} +``` + This function is only available on POSIX platforms (i.e. not Windows or Android). This feature is not available in [`Worker`][] threads. From 1fa3776daeaf481242e653270d2e82c47035833c Mon Sep 17 00:00:00 2001 From: "Pooja D.P" Date: Wed, 21 Oct 2020 18:18:06 +0400 Subject: [PATCH 2/3] fixup: remove space --- doc/api/process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/process.md b/doc/api/process.md index b580ef29c5d43a..39551d3161cf8f 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -2214,7 +2214,7 @@ The `groups` array can contain numeric group IDs, group names or both. ```js if (process.getgroups && process.setgroups) { - console.log( process.getgroups()); // current groups + console.log(process.getgroups()); // current groups try { process.setgroups([501]); console.log(process.getgroups()); // new groups From d8945fbb8f0d2aad3f296c0eafc7baeb913249d1 Mon Sep 17 00:00:00 2001 From: "Pooja D.P" Date: Thu, 22 Oct 2020 17:15:32 +0400 Subject: [PATCH 3/3] fixup: address review comment --- doc/api/process.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/api/process.md b/doc/api/process.md index 39551d3161cf8f..f8d0a90f15cd32 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -2210,11 +2210,10 @@ The `process.setgroups()` method sets the supplementary group IDs for the Node.js process. This is a privileged operation that requires the Node.js process to have `root` or the `CAP_SETGID` capability. -The `groups` array can contain numeric group IDs, group names or both. +The `groups` array can contain numeric group IDs, group names, or both. ```js if (process.getgroups && process.setgroups) { - console.log(process.getgroups()); // current groups try { process.setgroups([501]); console.log(process.getgroups()); // new groups