Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proper way to get groups of a user in linux using C

I want to know if there is any alternate C library for the unix command groups,

$ groups ---- lists all the group id's of the user.

There is a method called getgroups() but it returns the groups of the user this method. Is there a way to get groups for a particular user using C.

like image 986
Adi GuN Avatar asked Feb 28 '14 19:02

Adi GuN


1 Answers

#include "<grp.h>"
int getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups);
like image 135
Asblarf Avatar answered Oct 20 '22 18:10

Asblarf