I am trying to resolve the logged in user's group numbers into group names.
The BASIC
SYSTEM() function has a number of options to get a user's group details:SYSTEM(29)returns the current "gid" - as a group numberSYSTEM(30)returns the effective "gid" - as a group numberSYSTEM(1017)returns the user's supplemental groups - as a dynamic array of group namesSYSTEM(1403)returns all the local system groups - as a dynamic array of group names
Basing such controls on the group id rather than the name would make the security setup un-portable as there is always the possibility that the group ids will change on different systems.
I have not found a system function that returns the group id and group name together.
I can execute
SH -c "id -gn" in order to get the user's primary group name.I can execute
SH -c "id" in order to get a messy but parse-able string of group numbers and names.Both require that the output be captured and interpreted.
There is the option of reading and parsing the /etc/group file via
OPENSEQ/READSEQ, or even a simple SH -c "cat /etc/group", but given there are already functions that are returning part of the contents it would seem an unnecessary overhead.It seems a bit weird that there are system functions to get the names of the groups but not both the id and name combined.
Is anyone aware of a hidden function or system call that does return the combination of group id and name?
------------------------------
Gregor Scott
Software Architect
Pentana Solutions Pty Ltd
Mount Waverley VIC Australia
------------------------------