groups.ha (917B)
1 // SPDX-License-Identifier: MPL-2.0 2 // (c) Hare authors <https://harelang.org> 3 4 use rt; 5 6 // Returns a list of supplementary group IDs for the current process. The 7 // returned slice is statically allocated. 8 export fn getgroups() []uint = { 9 static let gids: [rt::NGROUPS_MAX]uint = [0...]; 10 const n = rt::getgroups(gids)!; 11 return gids[..n]; 12 }; 13 14 // Sets the list of supplementary group IDs which apply to the current process. 15 // This generally requires elevated permissions. 16 // 17 // If the system returns an error, this function will abort the program. Failing 18 // to handle errors from setgroups is a grave security issue in your program, 19 // and therefore we require this function to succeed. If you need to handle the 20 // error case gracefully, call the appropriate syscall wrapper in [[rt::]] 21 // yourself, and take extreme care to handle errors correctly. 22 export fn setgroups(gids: []uint) void = rt::setgroups(gids)!;