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.





Computer Science & Information Technology

You might also like to view...

When Alice encounters a ____ statement, it pauses the program's flow, sets an internal timer to a specified number of seconds, and starts this timer counting down towards zero.

A. delay() B. pause() C. halt() D. suspend()

Computer Science & Information Technology

End-of-line comments that should be ignored by the compiler are denoted using

a. Two forward slashes (//). b. Three forward slashes (///). c. A slash and a star (/*). d. A slash and two stars (/**).

Computer Science & Information Technology

Each time you paste, what is made of that saved version?

a. file b. copy c. type d. replace

Computer Science & Information Technology

Each field in the /etc/passwd file is separated by ____.

A. periods B. colons C. semicolons D. spaces

Computer Science & Information Technology