rite a command to print all of the groups to which a speci?ed user belongs.
What will be an ideal response?
We can’t use the getgroups(2) system call, because it can only return information about the calling user,and we probably don’t want to make the program setuid to root. Instead, we need to scan the group ?le using getgrent(3) and comparethe list of members with the user name. We also need to check for the group whose group ID matches the speci?ed user’s primary group ID as listed in the password?le. The solution is shown in Figure16. Note that while the command works on all of the platforms covered in the book, Mac OS X 10.6.8 includes some extra groups that might not be visible to getgrent,s o the list of groups printed is only a subset of the ones reported by the id(1) command.
You might also like to view...
Some operating systems include drivers for peripheral devices
Indicate whether the statement is true or false
Using OOP terminology, the Public members are "exposed" to the application, whereas the ____ members are "hidden" from the application.
A. Private B. Public C. Global D. Class level