Skip to content

Adding setgroups option to process.spawn

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Notice that tests require either run as root or CAP_SETUID, therefore they will fail if run as a normal user. Otherwise, tests pass.

Affected core subsystem(s)

This change affects process, not sure in which subsystem it lives.

Description of change

Adding the possibility of setting extra user groups for a new process

This is a Unix-only feature.

Currently node offers the possibility of setting up both the uid and the gid of the new process. Sometimes one needs to set extra groups, so the new process gets access to resources that are owned by groups other than the group specified by gid.

This commit adds a new option to spawn (groups), which is an array of group ids to be set for the new process. Underneath, this calls setgroups using the list of ids.

There are a couple of unit tests and one js test. However, running these tests requires either running as root or using the CAP_SETUID capability (Linux). Not sure how to handle the situation and I'll be happy to adapt the tests to make them compatible with the build process.

Signed-off-by: Carlos Manuel Duclos Vergara carlos.duclos@tieto.com

Merge request reports

Loading